FANDOM



Script variablesEdit

Script variables are normally either numbers or text. For example the condition playerIsClose has a single variable, distance, which expects a number value. All variables that expect a number can also substitute an object variable or a global flag. Instead of writing 8 as the distance, you could use player.health to input the distance as the player's current health. You can also use fizz.health for named objects, or 123.health for unnamed objects. And this.health for the script owners health. You can also write the name of any flag from globalflags.ini.

Note that when creating a new script for a certain object/bot, you need to at least:

(1) select from "Activation Type" (up center) when the script will be triggered (eg. upon starting the map/when the bot dies/randomly/at a timed interval),

(2) Choose under "Actions" the script(s) you wish to use from the list of scripts. (You often need to specify a certain target via "SelectCompanionAsTarget" or another targeting script, to make sure that the actual active script you wish to use refers to the correct object/bot.) You can have a long list of scripts here, and time their occurance by adding waiting time in between (possible to add time right after the name of script).

(3) You may often wish to set certain conditions for your script, unless you wish to create a script which is not limited by any conditions.


Some useful, important scripts (which may not be self-explainatory): 

SetGlobalFlag: Use this script is you want something which happens on MAP A to influence another spesific thing which happens on MAP B. (An example: If John-the-bot dies, SetGlobalFlag "JohnIsDead" =1. Open another map, where John's daughter Jill lives. Jill can have a Script for exclaiming her intense sorrow, with a condition set as GlobalFlagIs  "JohnIsDead" =1.)

SetVariable: Can be used like SetGlobalFlag (above), but within one single map - NOT across maps. (Tip: You can also use it as "AddToVariable" so that a certain condition will only come true when the Variable has a bigger value, like 5. This may be needed for example if the player needs to gain the trust of five different villagers, before (s)he is able to convince the gatekeeper that (s)he is indeed trustworthy.)


Variable special names:

this script owner's id
caller script caller's id
target target's id
player player's id
spawned (from 0.99) the most recently spawned object
this.health script object's health
caller.health script caller's health
target.health / health target's health
123.health

object number 123's health

james.health health of the object named james

TODO:

  • scripting with scripts.ini, using IF and ELSE

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.