What, no simple arrays?
|
|
Serpentine Cosmos
Registered User
Join date: 10 Nov 2006
Posts: 5
|
11-23-2006 07:02
Hi Im a C++ programmer trying to script, and i cant figure out how to do simple array code with LSL. All I need is the ability to read and write into an array like so:
list myList = [0,1,4,5] ;
myList[1] = 10 ;
integer toto = myList[2] ;
for(i=0; i< 4; i++) { toto = i ; }
Anyone can show me how to do this?
thanx, Serp.
|
|
Ralph Doctorow
Registered User
Join date: 16 Oct 2005
Posts: 560
|
11-23-2006 07:14
Right, it sucks. Check out the list functions in the wiki, you have to use them.
|
|
Serpentine Cosmos
Registered User
Join date: 10 Nov 2006
Posts: 5
|
11-23-2006 07:25
I know the LSL wiki and I still wasnt able to figure out how to do it. Do u have any sample code?
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-23-2006 07:32
From: Serpentine Cosmos Hi Im a C++ programmer trying to script, and i cant figure out how to do simple array code with LSL. All I need is the ability to read and write into an array like so:
list myList = [0,1,4,5] ;
myList[1] = 10 ;
integer toto = myList[2] ;
for(i=0; i< 4; i++) { toto = i ; }
Anyone can show me how to do this?
thanx, Serp. Example: list myList = [0,1,4,5];
myList = llListReplaceList(myList, [10], 1, 1);
integer toto = llList2Integer(myList, 2);
integer i = 0; for (i = 0; i < 4; i++) { //I'm not sure what you're trying to do here?.. toto = llList2Integer(myList, i); } In short, no, there are no C-style arrays. Sorry kiddo. 
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-23-2006 07:44
It really sucks though, as lists are woefully inefficient and you have to waste more memory keeping track of list size and trying to work out the memory requirements and so-on. I still don't see why we don't have proper arrays, we don't need pointers, which removes the need for memory protection etc, just simple bounds checking is needed.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Serpentine Cosmos
Registered User
Join date: 10 Nov 2006
Posts: 5
|
11-23-2006 11:11
oops, this is the one that really bugs me:
list myList = [0,1,4,5];
for (i = 0; i < 4; i++) { myList = i }
thanx,
|
|
Serpentine Cosmos
Registered User
Join date: 10 Nov 2006
Posts: 5
|
11-23-2006 11:12
Its really unbelivable, I can't do anything...
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-23-2006 11:17
From: Serpentine Cosmos oops, this is the one that really bugs me:
list myList = [0,1,4,5];
for (i = 0; i < 4; i++) { myList = i }
thanx, integer i; for (i = 0; i < 4; i++) { myList = llListReplaceList(myList, , i, i); } Talk about fun. 
|
|
Serpentine Cosmos
Registered User
Join date: 10 Nov 2006
Posts: 5
|
11-23-2006 11:22
great, thanx, but now if im doing this every second, on a timer, will that be verry ineffichiant?
Serp
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-23-2006 11:23
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
11-23-2006 14:15
From: Serpentine Cosmos will that be verry ineffichiant? Yes; that's LSL in a nutshell, really. silver lining would be, if you can grin and bear it then the dirty feeling eventually goes away, to be replaced by dull "oh, well" ;s
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
11-23-2006 14:22
Oh come on, it's not that bad. There are random-access list functions; we could do with a proper data type rather than using functions but that will come with Mono I suppose....
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Matt Newchurch
Registered User
Join date: 6 Jan 2006
Posts: 215
|
11-23-2006 14:33
I dunno, people seem to get by ok without it....
_____________________
Are you an executive furry, and not a weirdo furry? Join the brand-new "Executive Furries" group!
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
11-23-2006 14:43
From: Ordinal Malaprop Oh come on, it's not that bad. There are random-access list functions; we could do with a proper data type rather than using functions but that will come with Mono I suppose.... I don't mind the functions really, but i'd be much happier if it was possible to do changes to list content or to pass it as argument without creating a copy of the whole shebang... 16 k is tight enough as it is, just frustrating to have it play so reckless with the tiny amount of room it has >.<
|
|
Matt Newchurch
Registered User
Join date: 6 Jan 2006
Posts: 215
|
11-23-2006 16:22
From: Joannah Cramer I don't mind the functions really, but i'd be much happier if it was possible to do changes to list content or to pass it as argument without creating a copy of the whole shebang... 16 k is tight enough as it is, just frustrating to have it play so reckless with the tiny amount of room it has >.< 16k ought to be enough for anybody.
_____________________
Are you an executive furry, and not a weirdo furry? Join the brand-new "Executive Furries" group!
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-23-2006 16:31
Heh, you say that, try to code anything with any real data requirements. I'm coding a system that needs to keep track of and manage 30 prims, so it needs to know which channel each of them is listening to, what it's key is and data associated with it. In a list that amount to some 3k of data, plus 3k so that I have enough room to manipulate and that's 6k of memory gone, in-fact, it might even be 9k, I seem to recall lists taking up 3 times as much memory as required when manipulating (the original, the copy passed into the function, and the result that comes out of the function).
Managing 30 prims isn't the most compact of code for what I'm doing, plus notecard readers etc. I have to use multiple scripts.
Okay so having arrays probably wouldn't stop me from needing to do that, but it's a lot of wasted memory, and comparatively slow access.
My two most wished for LSL features are pass-by-reference and then arrays.
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
11-23-2006 16:51
From: Haravikk Mistral I'm coding a system that needs to keep track of and manage 30 prims, so it needs to know which channel each of them is listening to, what it's key is and data associated with it. I'm in a similar situation, having to keep track of various entities. That's where it's beneficial to move some of the workload outside of SL and into a php-controlled database server format. I'm still new to and learning the benefits of outsourcing data processing via the httprequest-type functions, but I can already see great benefits. For a multi-dimension array within LSL, try this link from the lslwiki.com library: http://lslwiki.com/lslwiki/wakka.php?wakka=LibraryMultidimensionalArray
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-23-2006 17:24
From: DoteDote Edison I'm in a similar situation, having to keep track of various entities. That's where it's beneficial to move some of the workload outside of SL and into a php-controlled database server format. I'm still new to and learning the benefits of outsourcing data processing via the httprequest-type functions, but I can already see great benefits. Storing any data is really the biggest pain. I'm not sure how to describe the exact limits, but for example, any decent script that stores a list of keys probably can't even fit 50 in there. The things that are the slowest which really SHOULDN'T be are list (bleh) and string handling. Parsing strings is ridiculously slow.
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
11-23-2006 17:50
From: Tyken Hightower Storing any data is really the biggest pain. I'm not sure how to describe the exact limits, but for example, any decent script that stores a list of keys probably can't even fit 50 in there. Well, that's why it's better to store them offline. Anyway, the max you can store is relevant to the size of your code. A thin script can hold more data. If you absolutely must keep the data stored in SL, then maybe you could split the task amongst numerous storage scripts. Sorta like a card catalog at the library, make a thin script for each letter and number. Send all keys that begin with A to the A script via link_message from the master script. It's not and end-all solution, but it greatly increases the max limit your system can store. Your 50 UUID storage limit would then convert to 1800 UUIDs, depending on even spread of the first UUID character. LSL has limits, but there are creative ways to deal with them and get the job done.
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-23-2006 17:57
From: DoteDote Edison Well, that's why it's better to store them offline. Anyway, the max you can store is relevant to the size of your code. A thin script can hold more data.
If you absolutely must keep the data stored in SL, then maybe you could split the task amongst numerous storage scripts. Sorta like a card catalog at the library, make a thin script for each letter and number. Send all keys that begin with A to the A script via link_message from the master script. It's not and end-all solution, but it greatly increases the max limit your system can store. Your 50 UUID storage limit would then convert to 1800 UUIDs, depending on even spread of the first UUID character.
LSL has limits, but there are creative ways to deal with them and get the job done. It's all fun and games until you calculate how many scripts could theoretically be loaded by the sim at once, considering most servers only have 512mb RAM and are running multiple sims - at 16kb per script (whether it's all being used or not), does this seem like a potential problem to anyone if you're using scripts for data storage? 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-23-2006 18:21
From: Tyken Hightower It's all fun and games until you calculate how many scripts could theoretically be loaded by the sim at once, considering most servers only have 512mb RAM and are running multiple sims - at 16kb per script (whether it's all being used or not), does this seem like a potential problem to anyone if you're using scripts for data storage?  Don't really have a choice except for doing that or going the external route. But it isn't the real problem anyway. What is a problem is that you go to empty sims and there are 3-5000 scripts running and taking up 18+ ms of script time. Then you start to figure in the load of scripts that AVs walk around with and it is mind numbing. I just take to turning off all of my scripts unless I am using it at the time.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-23-2006 18:30
From: Jesse Barnett Don't really have a choice except for doing that or going the external route. But it isn't the real problem anyway. What is a problem is that you go to empty sims and there are 3-5000 scripts running and taking up 18+ ms of script time. Then you start to figure in the load of scripts that AVs walk around with and it is mind numbing. I just take to turning off all of my scripts unless I am using it at the time. I once saw a pair of prim wings, I believe 170 prims between the two, that were scripted such that calling any of the options on them would bring a sim from 16,000ips to 600,000ips.  And yes, the sheer volume of scripts on some avatars is frightening. >_>
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
11-23-2006 19:04
From: Tyken Hightower And yes, the sheer volume of scripts on some avatars is frightening. >_> One day LL figures out just how much performance they can gain grid-wide just by including llSetLinkPrimitiveParams() in their LSL functions...
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-23-2006 19:19
From: Joannah Cramer One day LL figures out just how much performance they can gain grid-wide just by including llSetLinkPrimitiveParams() in their LSL functions... Yep and the other one I have been waiting on is : llGetTopScripts parsed by property. We would be able to see script performance for scripts only on our property even if just a 512. Amazing the tricks you can learn when you have feedback on different versions of a script down to .001 ms. I recently had access to the estate tools for a short period and it really changes a persons scripting habits. Eventually with education it might change the habits of at least some of the consumers also. I feel without some additional llFunctions and more education, that even when MONO comes and hopefully they bump it up to 34k per script. People will still slowly fill the sims again to max script capacity. OMG what am I saying! They will still probably max everything out 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-24-2006 01:01
From: Matt Newchurch 16k ought to be enough for anybody. Well back in the real world we used to run a full flight simulator with motion system in 8K of core store, code and data. those where the days my friends.... may be we should petition to replace LSL with LA, Linden Assembler....
|