rex_gridfreezer
Plugin, ACE table, Discussion thread
Dependence: One of them -
Dependence: One of them -
Introduction
Save/load instances with grids.
It could be used in a game which has many many instances in a very large layout. To save instances in level editor, then create part of instances in the game.
Save/load instances with grids.
It could be used in a game which has many many instances in a very large layout. To save instances in level editor, then create part of instances in the game.
Usage
Sample capx
Sample capx
Concept
The concept of this plugin comes from rex_logicmask plugin.
Each instance could map to a logic position by the layout object (rex_board_squareTx , or rex_board_hexTx). And this plugin maintain a logic mask like rex_logicmask plugin.
Instances will be saved into correspond grid (logic position) in JSON striong and destroyed if they are not in the current logic mask. The saved instances in new coverage area (entered area) will be created. i.e.
The concept of this plugin comes from rex_logicmask plugin.
Each instance could map to a logic position by the layout object (rex_board_squareTx , or rex_board_hexTx). And this plugin maintain a logic mask like rex_logicmask plugin.
Instances will be saved into correspond grid (logic position) in JSON striong and destroyed if they are not in the current logic mask. The saved instances in new coverage area (entered area) will be created. i.e.
Save and destroy instances which not in current logic mask,
Create instances which in entered area when logic mask moved.
Restrictions
The saving feature of this plugin only save each instance itself individually. So that it could not keep the relationships of UID (for example, official pin behavior) , or objects in the same container.
The saving feature of this plugin only save each instance itself individually. So that it could not keep the relationships of UID (for example, official pin behavior) , or objects in the same container.
Prepare
User needs to put one of the layout object (rex_board_squareTx , or rex_board_hexTx) into project, since this plugin will transfer physical position to logic position.
User needs to put one of the layout object (rex_board_squareTx , or rex_board_hexTx) into project, since this plugin will transfer physical position to logic position.
Monitor target object type
Call "Action:Add object to target" to add object type to monitor. Logic position of monitored instances which not in current logic mask will be saved then destroyed.
Call "Action:Add object to target" to add object type to monitor. Logic position of monitored instances which not in current logic mask will be saved then destroyed.
Define mask
Like rex_logicmask plugin, the logic mask needs to define first by one of these actions -
Like rex_logicmask plugin, the logic mask needs to define first by one of these actions -
- Action:Fill a rectangle
- Action:Flood fill
- Action:Clean
Put mask
Call "Action:Put mask" to put this mask by physical position. This logic mask will be used to create or save/destroy instances.
Call "Action:Put mask" to put this mask by physical position. This logic mask will be used to create or save/destroy instances.
Display mask
"Condition:For each masked LXY" could be used to retrieve each point of logic mask. Then create sprite at (Expression:CurPX, Expression:CurPY) under this for-loop condition.
"Condition:For each masked LXY" could be used to retrieve each point of logic mask. Then create sprite at (Expression:CurPX, Expression:CurPY) under this for-loop condition.
Save and destroy instances
Logic position of monitored instances which not in current logic mask will be saved in JSON string, then destroyed.
Set "Save mode" in properties table to "All properties", will save each instance using official save feature. Set "Manual" will save nothing, user needs to save information of each instance manually by "Condition:On save" and "Action:Set extra data".
( Here is a sample capx for saving manually)
"Condition:On save" will be triggered when saving each instance individually. Call "Action:Set extra data" to append extra data to save.
Logic position of monitored instances which not in current logic mask will be saved in JSON string, then destroyed.
Set "Save mode" in properties table to "All properties", will save each instance using official save feature. Set "Manual" will save nothing, user needs to save information of each instance manually by "Condition:On save" and "Action:Set extra data".
( Here is a sample capx for saving manually)
"Condition:On save" will be triggered when saving each instance individually. Call "Action:Set extra data" to append extra data to save.
Save all
Call "Action:Save all" to save all monitor instances into correspond grids (logic position), then destroy them. It will also trigger "Condition:On save" and be effected by "All properties" in properties table.
This action uses in level editor to save instances. Exporting will be discuss latter.
Call "Action:Save all" to save all monitor instances into correspond grids (logic position), then destroy them. It will also trigger "Condition:On save" and be effected by "All properties" in properties table.
This action uses in level editor to save instances. Exporting will be discuss latter.
Save global data
Call "Action:Set global data" to save global data, get them back by "Expression:GlobalData".
Call "Action:Set global data" to save global data, get them back by "Expression:GlobalData".
Load instances
Instances which saved in grid of entered area will be created, when the logic mask moved by "Action:Put mask", if "Save mode" sets to "All properties".
"Condition:On load" will be triggered for each instance. Get extra data by "Expression:ExtraData" under this condition, add key of extra data at 2nd parameter, default value at 3rd parameter which returns if the key could not be found in current extra data.
Get created instance by "Expression:LoadInstUID" , if "Save mode" sets to "All properties", otherwise user needs to create instance manually by current extra data.
Instances which saved in grid of entered area will be created, when the logic mask moved by "Action:Put mask", if "Save mode" sets to "All properties".
"Condition:On load" will be triggered for each instance. Get extra data by "Expression:ExtraData" under this condition, add key of extra data at 2nd parameter, default value at 3rd parameter which returns if the key could not be found in current extra data.
Get created instance by "Expression:LoadInstUID" , if "Save mode" sets to "All properties", otherwise user needs to create instance manually by current extra data.
Load all instances
Call "Action:Load all instances" to load all instances. Performance might be dropped when loading a lot of instances.
Call "Action:Load all instances" to load all instances. Performance might be dropped when loading a lot of instances.
Enable
Sets "Initial state" to "Enabled" in properties table, or sets by "Action:Set enabled" to enable save-load. It will not check logic position or create instances in entered area if "Disable".
Sets "Initial state" to "Enabled" in properties table, or sets by "Action:Set enabled" to enable save-load. It will not check logic position or create instances in entered area if "Disable".
Import/export grids data
Export saved grids data by "Expression:GridData". Saves it after call "Action:Save all". Used in level editor for example.
Import grids data by "Action:Import grids". Loads it when game starts. The configuration of layout will also be reset when loaded.
Export saved grids data by "Expression:GridData". Saves it after call "Action:Save all". Used in level editor for example.
Import grids data by "Action:Import grids". Loads it when game starts. The configuration of layout will also be reset when loaded.
Save/load instances with object-type independent
Export / Import
Instances will be created automatically if "Save mode" sets to "All properties" when saved. In this mode, object-type will be remembered by "SID", the mapping of object-type to SID will be the same in a project. On the other hand, the level editor and the body of game needs to be the same project.
To separate level editor and the body of game into different projects, one possible solution is using "Manual" save mode, and save object-type by nickname.
Export / Import
Instances will be created automatically if "Save mode" sets to "All properties" when saved. In this mode, object-type will be remembered by "SID", the mapping of object-type to SID will be the same in a project. On the other hand, the level editor and the body of game needs to be the same project.
To separate level editor and the body of game into different projects, one possible solution is using "Manual" save mode, and save object-type by nickname.