Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

gravity changer... help?

Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
10-24-2007 17:47
I've been asking a lot of questions on these forums, and I'd like everyone to know that I'm very grateful; almost everyone is helpful!

Anyways... This time I've got a question about my script that I wrote. I wrote a script that goes in an attachment on the HUD, and it listens to commands from the owner in the form "/2 gravity (%grav here)". I thought I had it all set up correctly, but for some reason this script I wrote simple blows both the >100 and <100 if statements at once, and I get both confirmation messages and it does nothing to the gravity of my avatar. Can anyone figure out what's wrong?

From: someone

default
{
on_rez(integer start_param)
{
llResetScript();
}
attach(key id)
{
llResetScript();
}
state_entry()
{
llListen(2,"",llGetOwner(),"";);
}
listen(integer channel, string name, key id, string message)
{
string num = llGetSubString(message, 8,-1);
integer numdivt = (integer)num/10;
if (message == "reset";)
{
llResetScript();
}
if ( llGetSubString(message,0,7) == "gravity ";)
{
if ((integer)num > 300)
{
llOwnerSay("Too strong of a gravity force. Please choose a number between 1 - 300";);
llResetScript();
}
if ((integer)num <100)
{
llSetForce(<0,0,numdivt>, TRUE);
llOwnerSay("Gravity set to "+num+"%.";);
}
if (100< (integer)num < 300)
{
llSetForce(<0,0,-numdivt>, TRUE);
llOwnerSay("Gravity set to "+num+"%.";);
}
if (message == "gravity 100";)
{
llSetForce(<0,0,0>, TRUE);
llOwnerSay("Gravity effects discharged.";);
}
}
}
}
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-24-2007 19:13
Keep Asking!!!!!!!!!!!!!!!!!!!!
Eventually you will get to the point where you will keep answering :)

1st change this little bit so you don't make the simulator keep converting it with every if test:

string num = llGetSubString(message, 8,-1);
integer numdivt = (integer)num/10;
integer num_int = (integer)num;

Then you are using a binary operator to compare 3 statements. Hint, hint: "bi" in "binary" means two :rolleyes: (heehee I am laughing as I typed that!)

Try this instead:

if (100 < num_int && num_int < 300)
_____________________
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