Jump to content

comparing integer help


Alishen
 Share

You are about to reply to a thread that has been inactive for 1523 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am trying to compare 2 integers , trying to see if one is higher than the other.

So far I have failed, any help would be great.

integer Spin_Number;

integer Lucky_Number;

integer rand(integer min, integer max)
{
 return min + (integer)(llFrand(max - min + 1));
}

default
{
   state_entry()
   {  

Lucky_Number = rand(1,20);

Spin_Number = rand(1,20);

 {

 if((Lucky_Number == Spin_Number ) && ((Lucky_Number >= Spin_Number)))

 llSay(0,"Spin_Number Is Higher then Lucky_Number, You Win!");

else

llSay(0,"Spin_Number Is Lower then Lucky_Number, You Lost");
}
}
on_rez(integer h){llResetScript();}
}
 

Link to comment
Share on other sites

15 minutes ago, Alishen said:

 if((Lucky_Number == Spin_Number ) && ((Lucky_Number >= Spin_Number)))

That doesn't work, logically.  Say it out loud: "If Lucky_number is equal to Spin_number AND Lucky_number is greater than or equal to Spin_number...."  The only way that both conditions can be TRUE at once is if Lucky_number == Spin_number.  So, if a pair of numbers fails your test, either one might be greater than or less than the other. What you really want to ask is simply

if (Spin_number > Lucky_number)
{
    llSay(0,"Yea! You win!");
}
else
{
    llSay(0,"Crud!  You lose.");
}

If you also want to allow people to win when Spin_number == Lucky_number, then say

if (Spin_number >= Lucky_number)
{
    llSay(0,"Yea! You win!");
}
else
{
    llSay(0,"Crud!  You lose.");
}

 

Edited by Rolig Loon
  • Like 1
Link to comment
Share on other sites

28 minutes ago, Alishen said:

I been locked in a house going oon 5 weeks, I probably would have seen the silly in the normal mind set.

You and everyone else. 😉  If there's a small bright spot in our days of social distancing and isolation, it's that we have plenty of time to focus on the challenging creative tasks that we don't normally give ourselves time for, like scripting.  Good luck.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1523 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...