User Tools

Site Tools


string

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
string [2017/05/30 10:43]
justin
string [2021/04/21 20:07] (current)
justin
Line 2: Line 2:
 ---- ----
  
-A **string** is a scripting data type consisting of a string of characters enclosed by double quotes on each end. Strings are typically used to represent a message, for example in the [[Display Message]] function, or when referencing an entity name or property name within a script. [[Placeholder expressions]] can be used within a string as a way to generate dynamic values at game runtime.+A **string** is a scripting data type consisting of a string of characters enclosed by double quotes on each end. Strings are typically used to represent a message, for example in the [[Display Message]] function, or when referencing an entity name or property name within a script. [[placeholder_expression|Placeholder expressions]] can be used within a string as a way to generate dynamic values at game runtime.
  
 ====Example:==== ====Example:====
-<code lua+<code bauxite
-display_message("Hello world! This is a string.")+display_message("Helloworld! This is a string.");
 </code> </code>
 +
 +The above example demonstrates a string passed to the [[Display Message]] function as an argument.
 +
 +<WRAP center round info 100%>
 +**Note:** Any double quotation marks within a string (excluding the quotation marks used to enclose it) must be escaped with a preceding backslash.
 +</WRAP>
  
 ====Example:==== ====Example:====
-<code lua+<code bauxite
-set_entity_property(entity["treasure_chest_01"], "property", "value")+set_entity_property(entity["sign_01"], "message", "The sign's \"message\".");
 </code> </code>
  
 +The above example demonstrates 3 different cases of a string being used: an entity by ID reference, the name of the property, and a text value to store in the property.
  
 +=====String Concatenation=====
 +Strings can be concatenated, or connected together, using the plus symbol between two or more values. These values can be either a literal string (e.g. "Hello!"), variable name (e.g. my_string), or a reference to a property (e.g. global.property["my_string"]). The assumption is made that the variable or property contains a valid string value. This syntax can be used in most places where a string value is expected.
 +
 +====Example:====
 +<code bauxite>
 +display_message("Hello, " + global.property["player_name"] + "!");
 +</code>
  
 ~~NOTOC~~ ~~NOTOC~~
string.1496166233.txt.gz · Last modified: 2017/05/30 10:43 by justin