ST expression

From Of Life and Land Wiki
Jump to navigation Jump to search

For advanced conditions, a context free grammar can be used for state expressions defined below. The lexer uses spaces, (, ), and ! to tokenise the input to generate the terminal symbols for the parser. The parser is realised as a LEFT BOUND parser with recursive descendant for extra fast parsing.

Definition BooleanExpression

Let G_T = { V, T, P, S } with Π := V \T
T = { >, >=, <, <=, =, ==, not, NOT, Not, !, and, AND, And, &&, &, or, OR, Or, ||, |, (, ), +, -, *, / } ∪ b ∪ n
Π = { S, B, E, I, R, N, A }

With the production rules P:
S → B
B → B E B | I B | N R N | ( B )
E → and | AND | And | && | & | or | OR | Or | || | |
I → not | NOT | !
R → > | >= | < | <= | = | ==
B → b
N → n | n A N
A → + | - | * | /

The set n consists of all words in the .Net Int32 parse method (see https://docs.microsoft.com/en-us/dotnet/api/system.int32.tryparse), as well as any numeric variable defined in the scenario.

The set b consists of all constant boolean terminal symbols (true, True, TRUE, false, False, FALSE) and defined scenario keys (returns true if they are currently active).

"A" operation remarks: We use the .NET Int32 arithmetic operators.

Generation example "x and ( y or ! z )"

B
B E B
B E (B)
B E (B E B)
B E (B E I B)
x and ( y or ! z )

Examples

Expression Result
MyCounter >= 10 Returns true if the game variable "MyCounter" is greater or equal to 10
QuestMeetTheKing and not (FailedQuests > 10 or HelpedWithTheFire == 1) Returns true if the Quest "QuestMeetTheKing" is running and

neither "FailedQuests" is greater than 10 nor "HelpedWithTheFire" equals 1

QuestA && !QuestB Returns true if 'QuestA' is running but not 'QuestB'
QuestA && !( failed > MyCounter - 1) Returns true if 'QuestA' is running and failed is not higher than MyCounter minus 1.
1 + 1 Is not part of the language. You will find an error in the DetailLog.txt and this expression will always result in true (to not block).
true >= &&-1 Hello! No, please stop. This is definitely not part of the language. :(


Definition AssignmentExpression

Let G_A = { V, T, P, S } with N := V \T
T = { =, :=, +, -, *, / } ∪ n ∪ n_REF ∪ b ∪ b_REF
N = {S, X, A, O, B, N }
With the production rules P:
S → X
X → b_REF O B | n_REF O N | b_REF
O → = | :=
B → b_REF | b
N → n_REF | n | n A N
A → + | - | * | /

b are all valid expressions in the language defined above with S.

For set n: See above

In the set b_REF are all defined scenario keys.

In the set n_REF are all numeric variables defined in the scenario.

Examples

Expression Result
MyVariable = 10 MyVariable is set to 10 (the variable is created if it does not exist)
QuestA = QuestB && MyVariable == 0 QuestA is activated if QuestB is active and MyVariable equals 0.
QuestA QuestA is activated
MyVariable = MyVariable + 1 MyVariable is incremented by 1.
MyVariable = 3 * 3 + 3 + 1 MyVariable will be 21! It is a left bound descending parser using the given production rules. There are no priority rules.

So think of it as MyVariable = (3 * ( 3 + (3 + 1))), which equals n_REF = (n A ( n A (n A n)))

MyCounter >= 10 Is not part of the language. We assign / activate things here as it is a result of a ScenarioEntry.


Predefined Variables

All variables are read only if not stated otherwise.

UI user triggers

Key Info
UI_AchievementWindowController_Open > 0 if the achievement UI was opened.
UI_IntroductionWindowController_Open > 0 if the help UI was opened.
UI_MissionWindowController_Open > 0 if the mission UI was opened.
UI_FactionWindowController_Open > 0 if the faction UI was opened.
UI_ConstructionWindowController_Open > 0 if any construction UI was opened.
UI_StaticObjectController_Open > 0 if the static UI was opened.
UI_EnvironmentWindowController_Open > 0 if the environment UI was opened.
UI_PopulationWindowController_Open > 0 if the population UI was opened. Currently not in use.
UI_DynamicObjectController_Open > 0 if any dynamic UI was opened.
UI_MapController_Open > 0 if the map UI was opened.
UI_Window_TitleWasEdited > 0 if any window title was edited.
UI_StaticObjectController_Altar > 0 if the altar UI was opened.
UI_StaticObjectController_MushroomCircle > 0 if the mushroom circle UI was opened.
UI_StaticObjectController_AncientTree > 0 if the ancient tree UI was opened.
UI_StaticObjectController_FoundersRock > 0 if the rock of the ancestors UI was opened.
UI_PlayerMenu_FactionNameEdited > 0 if a region name was edited.
UI_Upgrades_Activated > 0 if a upgrade was activated.
UI_Upgrades_FisheryPassiveFeeding_Activated > 0 if the fishery upgrade "passive feeding" was activated.
UI_Reallocation_NewEntry > 0 if a new reallocation entry is added.
UI_Needs_HumanView > 0 if the need UI of a human was opened.
UI_TransferTab_Open > 0 if the reallocation/transfer UI was opened.
UI_TransferHelp_Open > 0 if the reallocation/transfer help UI (F1) was opened.
UI_TemperatureOverlay_Open > 0 if the temperature overlay was activated.
UI_WaterOverlay_Open > 0 if the water overlay was activated.
UI_DirtOverlay_Open > 0 if the dirt overlay was activated.
UI_ShowThingsOnMap > 0 if the user displayed things on the mini-map.

Camera user triggers

Key Info
UI_Camera_WasZoomed > 0 if the user zoomed in or out
UI_Camera_WasRotated > 0 if the user rotated the camera
UI_Camera_WasMoved > 0 if the user moved the camera

Building things user triggers

Key Info
UI_Builder_WasRotated > 0 if any construction was rotated in the edit mode.
UI_Builder_WasPlaced > 0 if any construction was placed.

Production user UI triggers

Key Info
UI_Production_PriorityEdited > 0 if the priority was changed in any production location.
UI_Production_FireEmployee > 0 if the user fired someone.
UI_Production_HireEmployee > 0 is the user hired someone.

Street user trigger

Key Info
UI_ConstructionSite_Modification >= 0 if the user changed the floor.

Trading UI user trigger

Key Info
UI_TradingView_Add > 0 if a new trade entry was added.
UI_TradingView_Sell > 0 is a selling point was set.
UI_TradingView_Buy > 0 if a buying point was set.

Faction info

Key Info
Faction_MaxHumanTier The maximum human tier of the player in the past in the world
Faction_Player_Coins Players wealth
Faction_Human_IsPregnant > 0 if a human from the player faction got pregnant in this session
World_SettleNewRegion > 0 if the player can settle another region (discovered a new region and has the diplomatic right to settle)

World info

Key Info Example
World_FILENAME_AnimalCount_ANIMALID Number of animals in the region (by filename and animals ID) updated every day "World_Hills.bin_AnimalCount_0" returns the number of red deer on the map Hills.bin