Alishen Posted April 16, 2020 Share Posted April 16, 2020 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 More sharing options...
Rolig Loon Posted April 16, 2020 Share Posted April 16, 2020 (edited) 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 April 16, 2020 by Rolig Loon 1 Link to comment Share on other sites More sharing options...
Alishen Posted April 16, 2020 Author Share Posted April 16, 2020 Thank you, I been locked in a house going oon 5 weeks, I probably would have seen the silly in the normal mind set. 3 Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 16, 2020 Share Posted April 16, 2020 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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