Data storage in tiles

Post here your questions about the OpenSpace 1.x or notify bugs and suggestions.

Moderators: Lapo, Bax

bfeinberg
Posts: 2
Joined: 25 Aug 2010, 23:56

Data storage in tiles

Postby bfeinberg » 26 Aug 2010, 00:32

My protect uses tiles to represent objects or equipment. These objects have sets of actions that can be applied to them which are dependent upon the current state of the item (ie: off, on setting 1, on setting 2, etc). These states also affect the points earned in different categories over time.

I've noticed in the openspace editor that custom parameters can be applied to each of the tiles, but I do not see a way to access these custom parameters at runtime (either getting or setting them) besides listening for a triggered event.

For my project, I need to be able to access and update these parameters for the tiles based on certain events that may triggered by time or other non interactive methods. Is there a way to access and set these parameters at runtime? Can the .map files store these parameters as well so I would be able to keep track of the current state of each tile (object)?
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 26 Aug 2010, 08:34

This is not so easy to achieve... Tile objects are passed in events and you can access the Tile.customParams property. But OpenSpace 1 is not supposed to give direct access to tiles.
As a workaround you could give a name to the skin contained in the tile (but this means you can't have duplicate items on the map), then at runtime get a reference to it using the OpenSpace.getMapObject method. Once you have the skin displayobject, calling "parent" twice returns a reference to the Tile container.
But also using this workaround, you wouldn't be able to write those parameters at runtime, because there's no way to save them.
The only possibility is that you keep all the data in your own data structures, outside OpenSpace, and use a unique identifier to keep the reference with tiles.

In OS 2 this could be simpler. You still have to keep your data outside OpenSpace, in your own data structures, but in the Editor you can assign an instance name to each tile, and retrieve them easily by calling the OpenSpace.getTileByName method. In this way the instance name (must be unique) is the id linking your external data with the tile.
Paolo Bax
The SmartFoxServer Team
bfeinberg
Posts: 2
Joined: 25 Aug 2010, 23:56

Postby bfeinberg » 26 Aug 2010, 17:41

Thanks, Bax. I'm using OS2 and the second option sounds like the route I'll be taking.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 27 Aug 2010, 11:49

Ok.
Please next time post in the right forum please.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v1 discussions and help”

Who is online

Users browsing this forum: No registered users and 19 guests