I is it possible do have the hero say some thing like this hero.say("help”)
and a bunch of soldiers will come? If so, how would I do that?
Do you mean in the level editor (hence the artisan tag?)? If so, then yes. I’m pretty sure you could. You could look at the referee code of some levels where a precise message is needed (secret names in the mountain and others.). I think it’s always a good plan to check out other levels’ code to see how certain things are done.
Also @Chaboi_3000 might be able to help you.
Danny
Ok then let me try (you are really bugging me 20 chars)
yes that is what I mean
Calm yourself… . @ing chaboi isn’t going to make him help you faster. Is this problem of the upmost urgency? I don’t really see why it would be, so why the rush? Why not spend your time looking at other levels’ code and setup and maybe forking a level (top right corner button somewhere) and making some changes?
5 mins isn’t really enough time to learn something quite hard.
Danny
I also do not really know how to use a referee could you help me with that @Deadpool198?
Here’s an example of an action triggered by a hero saying a phrase(Cell Commentary). Try to work out the code from here. :
{
password: "Achoo"
setUpLevel: ->
@omarn = @world.getThangByID("Omarn")
@hero.actions.say.cooldown = 3
@hero.oSay = @hero.say
@hero.saidMessages = saidMessages = []
@hero.ref = @
@hero.say = (a, b, c) ->
if a is "achoo"
throw new Error @ref.icontext.capital
@saidMessages.push a
@oSay a, b, c
@configOmarn()
configOmarn: ->
@omarn.oSay = @omarn.say
@omarn.oSay2 = @omarn.sayWithoutBlocking
@omarn.say = (message, data, _excess) ->
return if message is "Take that!"
@oSay message, data, _excess
@omarn.sayWithoutBlocking = (message, duration) ->
return if message is "Take that!"
@oSay2 message, duration
hear: (who, what, data) ->
if who is @hero
if what is @password
@hasHeard = true
@setGoalState "say-password", "success"
if @omarn.spriteName is "Potion Master"
@omarn.throw "Dungeon Door"
else
@omarn.cast "fireball", "Dungeon Door"
else if what isnt @hero.saidMessages[0]
@hasHeardWrong = true
onFirstFrame: ->
@hero.voiceRangeSquared = 9001 * 9001
if @hero.spriteName is "Potion Master"
backup = @world.getThangByID "Nalfar"
backup.pos = @omarn.pos.copy()
@omarn.setExists false
backup.keepTrackedProperty "pos"
@omarn = backup
@configOmarn()
chooseAction: ->
if @world.age > 1 and not @hasHeard
if @hasHeardWrong
@omarn.say @icontext.inBlue
else
# In Hebrew it should be: "קרא את ההערות בריבוע הכחול!"
#@omarn.say "Read the blue comments!"
@omarn.say @icontext.read_comments
if @world.rand.rand(10) is 1
munchkin = @instabuild "munchkin-"+["m","f"][@world.rand.rand 2], 34, 35
munchkin.moveXY(34,-10)
for munchkin in @world.thangs when munchkin.type is 'munchkin' and munchkin.exists
if munchkin.x < -2
munchkin.setExists false
if @omarn.action is 'throw' and @omarn.actionHeats.throw > 0
@omarn.sayWithoutBlocking @icontext.ges
@omarn.setAction 'idle'
@blownUpDoor = true
if @blownUpDoor and @world.age > 6
@omarn.sayWithoutBlocking @icontext.grab
#checkVictory: ->
}
I actually will try making that in a level and send you the link! thanks!
how would I put that in?
the level will not load
Did you put it in the referee ExtraCode?
yes I did but for some reason It does not work.
it gives me an infinite loop warning and I have never played the level
{
password: "Achoo"
setUpLevel: ->
@omarn = @world.getThangByID("Omarn")
@hero.actions.say.cooldown = 3
@hero.oSay = @hero.say
@hero.saidMessages = saidMessages = []
@hero.ref = @
@hero.say = (a, b, c) ->
if a is "achoo"
throw new Error @ref.icontext.capital
@saidMessages.push a
@oSay a, b, c
@configOmarn()
configOmarn: ->
@omarn.oSay = @omarn.say
@omarn.oSay2 = @omarn.sayWithoutBlocking
@omarn.say = (message, data, _excess) ->
return if message is "Take that!"
@oSay message, data, _excess
@omarn.sayWithoutBlocking = (message, duration) ->
return if message is "Take that!"
@oSay2 message, duration
hear: (who, what, data) ->
if who is @hero
if what is @password
@hasHeard = true
@setGoalState "say-password", "success"
if @omarn.spriteName is "Potion Master"
@omarn.throw "Dungeon Door"
else
@omarn.cast "fireball", "Dungeon Door"
else if what isnt @hero.saidMessages[0]
@hasHeardWrong = true
onFirstFrame: ->
@hero.voiceRangeSquared = 9001 * 9001
if @hero.spriteName is "Potion Master"
backup = @world.getThangByID "Nalfar"
backup.pos = @omarn.pos.copy()
@omarn.setExists false
backup.keepTrackedProperty "pos"
@omarn = backup
@configOmarn()
chooseAction: ->
if @world.age > 1 and not @hasHeard
if @hasHeardWrong
@omarn.say @icontext.inBlue
else
#@omarn.say "Achoo!"
@omarn.say @icontext.read_comments
if @world.rand.rand(10) is 1
munchkin = @instabuild "munchkin-"+["m","f"][@world.rand.rand 2], 34, 35
munchkin.moveXY(34,-10)
for munchkin in @world.thangs when munchkin.type is 'munchkin' and munchkin.exists
if munchkin.x < -2
munchkin.setExists false
if @omarn.action is 'throw' and @omarn.actionHeats.throw > 0
@omarn.sayWithoutBlocking @icontext.ges
@omarn.setAction 'idle'
@blownUpDoor = true
if @blownUpDoor and @world.age > 6
@omarn.sayWithoutBlocking @icontext.grab
#checkVictory: ->
}
Please take a closer look at the code. For example, look at line 4. In your level, there’s no thang called Omarn, that’s one error. I do not expect you to copy/paste the code at all. I advise actually looking deeper into the code and use the pieces of it and change it to fit your own situation.
I changed that there is, Look at the potion masters id