CallRoomScript (int value)
Calls the on_call function in the current room script. This is useful for things
like the text parser, where you want to check for general game sentences, and then ask
the current room if the sentence was relevant to it.
The on_call function will be called in the current room script, with its value
parameter having the value you pass here. This allows it to distinguish between different
tasks, and saves you having to use a GlobalInt to tell it what to do.
If the current room has no on_call function, nothing will happen. No error will occur.
You write the on_call function into the room script ("Edit script" button on Room Settings
pane), similar to the way you do dialog_request in the global script:
function on_call (int value) {
if (value == 1) {
// Check text input
if (Parser.Said("get apple"))
Display("No, leave the tree alone.");
}
}
The function doesn't get called immediately; instead, the engine will run it in due course,
probably during the next game loop, so you can't use any values set by it immediately.
Once the on_call function has executed (or not if there isn't one), the
game.roomscript_finished variable will be set to 1, so you can check for that in your
repeatedly_execute script if you need to do something afterwards.
SeeAlso: The text parser documentation
|