Solania Duport
Registered User
Join date: 17 Jul 2005
Posts: 4
|
07-24-2005 10:10
Im working on scripting a system that will control a series of objects based on data on each line of the note card, sound in theory but I ran into one major snag...
The info gained from the notecard is a string, and i have no ideas on how to convert the data parsed out of it into integers and floats. For instance.
string string = 0020 0110 1.0; string onoroff = llGetSubString(string,0,0); string delay = llGetSubString(string, 10,12);
Now I can easily enough pull the data I want into strings, but I cant seem to figure out how to transfer that data into integers like onoroff as an integer and delay to float so it can be used in llSleep().
Any help would be appriciated.
|
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
|
07-24-2005 10:17
string string = "0020 0110 1.0"; integer onoroff = (integer)llGetSubString(string,0,0); float delay = (float)llGetSubString(string, 10,12); http://secondlife.com/badgeo/wakka.php?wakka=Typecast
|
Solania Duport
Registered User
Join date: 17 Jul 2005
Posts: 4
|
07-24-2005 10:21
I love you! thank you very much!
|
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
|
07-24-2005 10:22
Check out the LSL WIKI for Typecastingfor example, this would produce the desired results: default { state_entry() { llSay(0, "Hello, Avatar!"); }
touch_start(integer total_number) { string _string = "0020 0110 1.0"; integer onoroff = (integer)llGetSubString(_string,0,0); float delay = (float)llGetSubString(_string, 10,12); llSay(0, (string)onoroff + " " + (string)delay); } }
|
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
|
07-24-2005 10:26
you're going to have a problem using "string" as a variable. "string" is a reserved name in LSL. That's why I changed my example to "_string"
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
07-24-2005 13:23
(Also note that you can't name a string "string". That's what the underscore's about in Champie's example.)
|
Solania Duport
Registered User
Join date: 17 Jul 2005
Posts: 4
|
07-24-2005 14:47
Oh yeah I know string is reserved I was just trying to type something out and didnt feel like naming it all lol
And I got the code working, thanks very much that is a life saver, wish id known about it sooner.
|