User Tools

Site Tools


script_syntax

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
script_syntax [2023/02/13 22:56] justinscript_syntax [2023/02/13 23:09] justin
Line 232: Line 232:
  
 ====Duplicate==== ====Duplicate====
-The **duplicate** function creates a unique copy of an [[array]] or [[codex]].+The **duplicate** function creates a unique copy of an [[array]] or [[codex]]. Since the copy is unique, you can modify its data without affecting the original [[array]] or [[codex]]. 
 + 
 +Using the code below, $items_copy will contain a reference to the original $items [[codex]], so any changes to one will affect the other. 
 +<code bauxite> 
 +$items = codex["id": "ITEM_0001", "count": 5]; 
 +$items_copy = $items; 
 +$items_copy["count"] = 10; 
 +</code> 
 + 
 +In the example below, a copy of $items is made using the "Duplicate" function. Since it's now a unique copy of the [[codex]], if the "count" key is changed to 10 for $items_copy, the original $items [[codex]] will remain unchanged. 
 +<code bauxite> 
 +$items = codex["id": "ITEM_0001", "count": 5]; 
 +$items_copy = duplicate($item_data); 
 +$items_copy["count"] = 10; 
 +</code>
  
 ====Inverse==== ====Inverse====
script_syntax.txt · Last modified: 2023/11/06 14:13 by justin