Game logic - Entity storage – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
=Description=
=Description=
Special game logic to store data specific to one entity (e.g player). When assigned trough instruction Add Storage, it will create a copy witch will be attached to selected entity instance.
Special game logic to store data specific to one entity (e.g player). When assigned trough instruction [[Ylands Tile - Add-Remove entity storage|'''Add Storage''']], it will create a '''copy''' witch will be '''attached''' to selected entity '''instance'''.


*Storage has to be attached to entity via Add storage instruction, target entity becomes storage owner
*Storage has to be attached to entity via '''Add Storage''' instruction, target entity becomes '''Storage Owner'''
*Any storage can have unlimited number of owners, each owner will have its unique copy of attached storage
*Any storage can have unlimited number of owners, each owner will have its unique copy of attached storage
*Entities can have unlimited number of storages
*Entities can have unlimited number of storages
*Each owner will have unique values in each storage
*Each owner will have '''unique values''' in each storage
*To access variable, storage owner has to defined
*To access variable, storage owner has to defined
*Storage data (variables) can be then found in Variables category
*Storage data (variables) can be then found in Variables category


Note: In case a script will try to access non-existent storage this will stop the script. So it is crucial to do a storage check using Has storage instruction before accessing storage on unknown entity  (e.g Trigger object)
'''Custom instructions'''
*Instruction in a storage are executed only within currently called storage instance and it will affect only variables of this instance.


Example - adding storage
'''Storages in compositions'''
 
Example - accessing storage
 
=Custom instruction=
*Instruction in a storage are executed only within currently called storage instance and it will affect only variables of this instance
 
Example
 
=Storages in compositions=
*When composition using any storage will get exported, it will save with a copy of that storage (even if not selected)
*When composition using any storage will get exported, it will save with a copy of that storage (even if not selected)
*When such composition is placed in other scenario, it will make new independent copy of included storage under new name (e.g Global (2))
*When such composition is placed in other scenario, it will make new independent copy of included storage under new name (e.g Global (2))
*In case of multiple instances of same composition, references in all compositions will be set to one storage
*In case of multiple instances of same composition, references in all compositions will be set to one storage


=Properties=
'''Notes'''
N/A
*In case a script will try to access non-existent storage this will stop the script. So it is crucial to do a storage check using Has storage instruction before accessing storage on unknown entity  (e.g Trigger object).
 
=Events=
N/A
 
=Instructions=
*Has storage - returns whenever target entity has desired storage
*Add storage -  attaches storage to target entity
*Remove storage - removes storage from target entity


=Literals=
=Related Instructions=
*Storage - target entity storage
*[[Ylands Tile - Add-Remove entity storage|Add / Remove Entity Storage]]
*Storage owner - pointer to entity owning the current storage instance
*[[Ylands Tile - Has entity storage|Has Entity Storage]]
*[[Ylands Tile - Get entity storage|Get Entity Storage]]




----
----
{{Ylands scripting navbox}}
{{Ylands scripting navbox}}

Revision as of 17:52, 2 December 2018

Description

Special game logic to store data specific to one entity (e.g player). When assigned trough instruction Add Storage, it will create a copy witch will be attached to selected entity instance.

  • Storage has to be attached to entity via Add Storage instruction, target entity becomes Storage Owner
  • Any storage can have unlimited number of owners, each owner will have its unique copy of attached storage
  • Entities can have unlimited number of storages
  • Each owner will have unique values in each storage
  • To access variable, storage owner has to defined
  • Storage data (variables) can be then found in Variables category

Custom instructions

  • Instruction in a storage are executed only within currently called storage instance and it will affect only variables of this instance.

Storages in compositions

  • When composition using any storage will get exported, it will save with a copy of that storage (even if not selected)
  • When such composition is placed in other scenario, it will make new independent copy of included storage under new name (e.g Global (2))
  • In case of multiple instances of same composition, references in all compositions will be set to one storage

Notes

  • In case a script will try to access non-existent storage this will stop the script. So it is crucial to do a storage check using Has storage instruction before accessing storage on unknown entity (e.g Trigger object).

Related Instructions



Template:Ylands scripting navbox