Tutorial - Variables – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{Ylands editor navbox}}" to "{{Navbox/Ylands}}")
m (Text replacement - "Category: Tutorial" to "Category: Ylands Tutorial")
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
If you want to script you will need to get your hands dirty with '''variables''', '''numbers''', '''strings''' and similar elements. In this scene we demonstrate some of the basic operations.
If you want to script you will need to get your hands dirty with '''variables''', '''numbers''', '''strings''' and similar elements. In this scene we demonstrate some of the basic operations.


Line 32: Line 31:
{{DEFAULTSORT:{{#sub:{{PAGENAME}}|18}}}}
{{DEFAULTSORT:{{#sub:{{PAGENAME}}|18}}}}


[[Category: Tutorial]]
[[Category: Ylands Tutorial]]

Latest revision as of 17:44, 16 November 2022

If you want to script you will need to get your hands dirty with variables, numbers, strings and similar elements. In this scene we demonstrate some of the basic operations.


The Red Trigger Zone

We have created a variable called Number of Entries in this Trigger Zone script. Whenever the player enters it, the variable is incremented and its value written to the chat window. All number operations can be found under Numbers section.


The Blue Trigger Zone

Here we write out who has just entered the Trigger Zone. The parameter Trigger entity value is set to whoever has entered the zone so we can easily have it printed out. Notice that we actually print two strings merged together - the first part is made of the entity (when the script finds we are trying to use it as a string it automatically converts it into one) and a text string.


The Green Trigger Zone

As you can see in the script, we can easily detect if a variable has been set to some value by simply checking, if it is true.


Note:

There are two types of variables (and arrays)


Local variable, which exist only within a scope of certain custom instruction

Member variable (or simply “variable”) which exist in the scope of given entity’s script and can be accessed from any event or custom instruction existing in this script. If this variable is located within a Global Storage Game Logic, it can be accessed from any other script in the game.