This thread summarizes attributes that are needed for fun.
Fun attribute
First of all, a fun array can only be defined within a context. That means you can only define and use it from within a building or road plugin. To define it, you there are different attributes which decide on when the fun is evaluated:
- "fun" - Will be evaluated for each building/road that's placed on the map on a daily basis.
- "on click fun" - Will be evaluated if the user taps on a building./road
- "random fun" - Will be evaluated daily, regardless of whether there are real instanced of this building/road. The context (that means x,y) will be chosen randomly. Might be useful to spawn stuff from nowhere.
Code: Select all
"fun":[
// Transitions
]
A transition is an object that consists of a condition and actions that might be executed if the condition is true:
Code: Select all
"fun":[
{ // A transition object
"condition": ..., // A condition that will be evaluated
"actions":[...] // The action list that might be executed if the condition is true
},
... // More transitions
]
- "condition" - A condition object that can be evaluated to true or false. To learn more about conditions, see here. If this tag isn't defined the transition will act as there's a condition that is always true.
- "actions" - An array of action objects that may be executed if the condition is true. To learn more about actions, see here.
- "p" - A floating point number from 0 to 1. A probability to actually execute the actions if the condition is true. Is 1 by default.
- "double check" - If true, the condition will be checked again before action execution. For performance reasons, condition evaluation is decoupled from action execution by default. So this attribute is false by default. Only change this if you know what you're doing.
If there is only one transition for a fun object execution is trivial: If the condition is true, the action list will be executed with probability "p". However, if there are multiple transitions, things begin to become a bit complicated. First of all, only one action list can be executed at a time. So if multiple transitions have a condition that is true, the game will select one of them randomly (using the probability "p" of each transition) to execute it's action list. The sum of all probabilities determines if a actions list will be executed at all. If the sum is >=1 an action array will be executed in any case.