Author Topic: Plus or Minus...  (Read 3021 times)

0 Members and 1 Guest are viewing this topic.

Offline KryzTopic starter

  • Jr. Member
  • **
  • Posts: 33
  • Activity:
    0%
  • Reputation Power: 1
  • Kryz has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Plus or Minus...
« on: August 22, 2015, 09:17:46 PM »
0
Im looking for a quick way to use a range in an expression.

IE if A = B +-1
 
If A is equal to B, B+1, B-1

Am I stuck with If A = B || A = B + 1 || A = B - 1 Or is there a quicker way to do it?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Plus or Minus...
« Reply #1 on: August 22, 2015, 09:58:03 PM »
0
If you do a little bit of algebra, you can simplify what you're looking for:

Code: [Select]
set %a 6
set %b 5
set %c 1 ; range
if ( abs ( %a - %b ) <= %c )
{
  display ok within range
}
stop
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Plus or Minus...
« Reply #2 on: August 22, 2015, 09:59:14 PM »
0
set %A 1
set %B 2
set %Range 1
If abs( %A - %b ) <= %Range
Display ITS IN RANGE
Display its not in Range
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Plus or Minus...
« Reply #3 on: August 22, 2015, 09:59:42 PM »
0
Tm beat me by seconds!
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Plus or Minus...
« Reply #4 on: August 22, 2015, 10:00:38 PM »
0
Tm beat me by seconds!

Nearly exact same code!  Great minds DO think alike!  :)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KryzTopic starter

  • Jr. Member
  • **
  • Posts: 33
  • Activity:
    0%
  • Reputation Power: 1
  • Kryz has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Plus or Minus...
« Reply #5 on: August 22, 2015, 10:31:56 PM »
0
Thank you all!

Offline KaliOfLS

  • That's "Dr." Kali to you!
  • Sr. Member
  • *
  • Posts: 406
  • Activity:
    0%
  • Reputation Power: 6
  • KaliOfLS has no influence.
  • Gender: Male
  • Respect: +33
  • Referrals: 2
    • View Profile
Re: Plus or Minus...
« Reply #6 on: August 23, 2015, 04:06:43 AM »
0
You two are just so cute. 

I would do it one step further and make a sub routine.

Code: [Select]
gosub InRange 6 5 1
if #result
   display ok It's in range!
else
   display ok come a little closer baby.
halt

sub InRange
    if abs ( %1 - %2 ) <= % 3
        return #true
return #false
R~~~~ B~~~~~~~~ 
^ real life signature for sure

Tags: