Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Advice needed on data structures / memory

bucky Barkley
Registered User
Join date: 15 May 2006
Posts: 200
12-10-2006 19:35
I want an associative array where values are records :-)

I am writing a generalized imagemap. Think of a web
imagemap, where regions correspond to links or javascript
actions. Now think of transparent prims over a texture,
where clicking on them implies an event (give an LM,
a notecard, do a tp, change the background texture,
and so on...)

So in SL: Maps and other textures as the background,
and transparent overlays firing off events..

Each state would have a number of regions, such as
what I would put in a notecard:

CODE

StartTile
c 2,2,3,3 // coordinates
n nytTarg // name of this..
t Web // command type
a http://nyt.com // arguments for the command
EndTile


So one notecard would have all of the tiles/regions
for one state.. same as a client side imagemap in XHTML...
One notecard == one imagemap
I would name the notecards 1_map, 2_map, 3_map, and so on.

So to visualize:

CODE

a bunch of states
map 1
tile 1
coords
command and args
tile 2
....

map 2
tile 1
coords
command and args
tile 2
....
tile 3


When touched, the individual tile prims fire off linked messages
to a controller, which in turn decides what command to run ...

The Big Question: how to store all of this at runtime? I dont
want to keep referring to notecards for every touch event..
A tile could be a strided list of attributes and vals
the map it is in then contains all the tiles ...
and something contains all of the maps ...
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
12-10-2006 20:53
I think this tip involves reading only the titles of empty notecards for name/value pairs. Therefor no dataserver required and no time penalties.
/15/2e/142972/1.html
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
12-10-2006 21:54
i dont find the time really noticable, altho going back to a dataserver event each time can be a pita

i like ed's idea, large list's and strings are alot slower than an inventory lookup or a dataserver

also you could keep an index of the notecard, that way it knows map 1 is between lines 1-6, if your data is fairly constant in its formating you know that title1 would be line 2 of any given map ect ...
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-11-2006 00:25
Squirrel's notecard lookup using the titles (as suggested by ed44) will be quicker than a dataserver and easier over all. The only limit will be the amount of data that can be stored. Using a seperate notecard per tile would get around this but make the selection logic a tiny bit more convoluted.
bucky Barkley
Registered User
Join date: 15 May 2006
Posts: 200
12-11-2006 10:38
The idea of storing tile data via parsed notecard titles (and possibly descriptions) is interesting. One thing I did not mention in my initial post is the idea of command sequences (i.e. clicking gives you a popup tp, and advances the background texture to something else, and so on)

So getting back to the notecards... let's say I have 10 states, each with 3-6 tiles.
Each tile has its own key/value list. On the one hand, I could use something like:

map_1+tile_1 c:1,1,2,2~t:web~a:http://example.org
map_1+tile_2 c:3,3,3.4,7~t:sound~a:crickets.wav

and so on. and hopefully not run into the length limit for a title.. (and deal
with URL escaping..)

or, define tiles separately, and have maps refer to them symbolically:

tile_webex <keys and values>
tile_soundcricket <keys and values>

map_1 tile_webex
map_1 tile_soundcricket
map_2 tile_whatever
map_2 tile_tpme
map_3 tile_LMtoShop

I did have the brief idea of storing states in scripts named 'memory_1',
'memory_2', and so on... not sure if I am ready to discard that. I'm
keenly aware that it wont take a heck of a lot of maps/tiles to hit
the 16k limit ...
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-11-2006 12:02
Hardcodeing the data into memory scripts isnt to bad an idea depending on how often you expect to update it.

Another way would be to use a single line per tile in a notecard, where the line number can be calculated from the map and tile number, a sort of dummy hash table may be.
Introduces a dataserver event but only one line per item.

Personally i still think the notecard name idea should probably work ok, unless your data does get particularly long.