My first script, a RAW validater - reviewer needed
|
|
Vi Shenley
Still Rezzing
Join date: 24 Oct 2006
Posts: 103
|
04-21-2007 10:09
Well, I have just finished the first draft of my very first LSL script (actually, two small scripts), and I was wondering if anyone would care to have a look at them for me. I have been creating files in the RAW image format, using Photoshop CS2, and what I have been trying to do is to understand the format a little better. To aid this I have created a script that can measure the land height at any point, automatically, so I can compare the reported height with the height I believe I created in Photoshop, and see what variations might exist and get to understand the reasons for any correction factors or offsets that may need to be applied. The only problem unresolved (apart from probably a sloppy script) is to find a way to make a script run in a prim (this is my Geoprobe), that is located in the Inventory of another prim (this is my rezzer or deployer prim and script). Any takers? The two scripts are quite short 
|
|
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
|
04-21-2007 10:31
A script can only run in a rezzed prim, and you talk about a rezzer, so what is the unresolved problem ?
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr
SL books http://astore.amazon.com/secondlife-sl-20/
Need a beta tester for quality assurance ? Need a translator for English, French, Spanish ?
|
|
Vi Shenley
Still Rezzing
Join date: 24 Oct 2006
Posts: 103
|
04-21-2007 11:44
From: Simil Miles A script can only run in a rezzed prim, and you talk about a rezzer, so what is the unresolved problem ? The problem is this. I need to put a GeoProbe into my rezzer. The rezzer has its rezzing script, and the GeoProbe has its measuring script. The difficulty is in getting the measuring script into the GeoProbe prim. If I rezz the Geoprobe prim on the ground, then drag the script from inventory into its Contents, the script is not running. If then take the GeoProbe back into inventory, then rezz the rezzer and add the GeoProbe to it contents, when I then touch the rezzer it rezzes the GeoProbe, but it does nothing, because the script in it is not running. I tried running the script after adding it to the GeoProbe, but then it just flies of to do its work, and I cannot get it into the rezzer. This is the rezzer script: From: someone default { state_entry() { llSetText("GeoMeter. Touch me to start....", <0,0,1>, 1.0); } touch_start(integer total_number) { vector rezpos = llGetPos() +<0.0, 2.0, 0.0>; // rezz geoprobes 2m away integer x = 1; // this is the geoprobe number, and is also passed as the param to the geoprobes string xS; llOwnerSay("Rezzing Geoprobes..."  ; while (x<=256) // { llRezObject("GeoProbe", rezpos, ZERO_VECTOR, ZERO_ROTATION, x); //Rezz GeoProbe 1, 2, 3 etc, passing the x value to each GeoProbe llOwnerSay("GeoProbe " + xS + " rezzed.."  ; //Confirmation // llSleep(1) //possible delay could be placed here to avoid the Grey Goo Fence x += 1; xS = (string) x; } } } and this is the GeoProbe script: From: someone default { state_entry() { integer geoprobe = llGetStartParameter(); string geoprobeS = (string) geoprobe; vector origin = <0.5,-0.5,220.0>; origin.y += geoprobe; llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); // phantom while( llVecDist( origin, llGetPos() ) > .01 ) // sends bot to the Origin, i.e <0.5, 0.5 + geoprobe, 220.0> llSetPos(origin); integer xPos = (integer)origin.x; integer yPos = (integer)origin.y; string Pos = "<" + (string)xPos + ", " + (string)yPos + ">"; llInstantMessage(llGetOwner(), "GeoProbe " + geoprobeS + " confirms that it has reached position " + Pos); //confirmation of arrival at Origin state measure; } }
Suggestions welcomed.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
04-21-2007 11:59
On the GeoProbe script... I'd suggest that you have it start by some other mechanism than state_entry (which triggers, as you've found, whenever the script is first started). Instead, why not have the Rezzer script send it a chat command to start its process. The script will then start using the listen Event Handler rather than the state_entry Event Handler. Just in case you've not already seen it, you might also be interested in this: RAW FILES & HEIGHTMAPS[Edit: hm... in fact, using the on_rez Event Handler might be even simpler]
|
|
Vi Shenley
Still Rezzing
Join date: 24 Oct 2006
Posts: 103
|
04-21-2007 12:14
From: Pale Spectre On the GeoProbe script... I'd suggest that you have it start by some other mechanism than state_entry (which triggers, as you've found, whenever the script is first started). Instead, why not have the Rezzer script send it a chat command to start its process. The script will then start using the listen Event Handler rather than the state_entry Event Handler. Just in case you've not already seen it, you might also be interested in this: RAW FILES & HEIGHTMAPS[Edit: hm... in fact, using the on_rez Event Handler might be even simpler] Thank you Pale. I'll start looking at those two suggestions right away. The Knowledge Base article is what I started with before starting to create terrain files, but it is hopelessly inadequate. I am hoping after doing a lot of experiments on a new sim to add to the existing knowledge on this subject.
|
|
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
|
04-21-2007 12:24
When rezzed from your inventory llGetStartParameter() = 0 You can check for this in the GeoProbe script.
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr
SL books http://astore.amazon.com/secondlife-sl-20/
Need a beta tester for quality assurance ? Need a translator for English, French, Spanish ?
|
|
Vi Shenley
Still Rezzing
Join date: 24 Oct 2006
Posts: 103
|
04-21-2007 13:53
From: Simil Miles When rezzed from your inventory llGetStartParameter() = 0 You can check for this in the GeoProbe script. Thanks for the suggestion Simil. I did try that, I placed an if() at the beginning to test for '0' with a branch to an end state to jump over the code that sent it on its way. The compiler kept producing warnings saying that the line with the if condition on it would always be true if(geoprobe = 0); state finish; else { I ignored the warnings, and compiled the code inworld anyway, and the code just refused to start. I removed the 4 lines above, and the state finish at the end of the script, and it worked again (on rezzing, not from the rezzer)
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
04-21-2007 14:13
Out of interest, did you try simply changing the state_entry to on_rez? default { on_rez(integer start_param) { integer geoprobe = llGetStartParameter(); string geoprobeS = (string) geoprobe; vector origin = <0.5,-0.5,220.0>;
origin.y += geoprobe; llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); // phantom while( llVecDist( origin, llGetPos() ) > .01 ) // sends bot to the Origin, i.e <0.5, 0.5 + geoprobe, 220.0> llSetPos(origin);
integer xPos = (integer)origin.x; integer yPos = (integer)origin.y; string Pos = "<" + (string)xPos + ", " + (string)yPos + ">"; llInstantMessage(llGetOwner(), "GeoProbe " + geoprobeS + " confirms that it has reached position " + Pos); //confirmation of arrival at Origin state measure; } }
|
|
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
|
04-21-2007 14:53
For conditional statements you need to use ==
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr
SL books http://astore.amazon.com/secondlife-sl-20/
Need a beta tester for quality assurance ? Need a translator for English, French, Spanish ?
|