Usage:

execute "actions to be performed"

Example:

execute "goto city" + city.timeSlot

Allows you to force the bot to evaluate variables and perform functions or commands using the results. This is useful with older commands that do not support expressions by default.

In the example above, if you had a script that you wanted to perform differently depending on which city it was being run in, you could set labels for each one...

label city1
do stuff
end

label city2
do other stuff
end

label city3
do this stuff
end

label city4 
do this other stuff
end

You could check which city you're in with the object city.timeSlot. However if you did goto city.timeSlot you would see the error "Label 'city.timeSlot' not found". This is because the Goto command does not support the evaluation of city.timeSlot on it's own.

With execute you could make it evaluate it...

execute "goto city" + city.timeSlot

The above line would evaluate first city.timeSlot into (for example "2") and then execute the line goto city2, which would jump to the label city2 and perform whatever was there.

There are unlimited more uses for Execute, the above is merely one example.


ScriptControlStructures

Execute (last edited 2014-02-10 18:24:34 by Inanna)