The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IF constructs: Selection of multiple objects or numbers
Author Message
Kyrbis
Journeyman
*

Posts: 54
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Mar 2012
Reputation: 0



Post: #1
IF constructs: Selection of multiple objects or numbers
Hi there. I have problems with some IF constructs, as i simply don't get it how to select multiple numbers for an argument. I know it has to be simple, but...i don't get it ^^

Here's an example of what i want to do:

ON=@SpellCast

IF <SRC.ISGM>
RETURN 0
ELIF <ARGN1>== (spell number one to spell number 16 for example)
MESSAGE This is beyond your Rank.
RETURN 1
ENDIF

So, if I want to select Spell 1 and 2, might it be
ELIF <ARGN1>== 1 || <ARGN1>== 2 || and so on?
or can i simplify it anyways?

I want to hold it simple for learning and very basic scripting, but seems i need some help here :/
06-21-2012 05:45 AM
Find all posts by this user Like Post Quote this message in a reply
Anarch Cassius
Master
**

Posts: 273
Likes Given: 19
Likes Received: 10 in 9 posts
Joined: Mar 2012
Reputation: 2



Post: #2
RE: IF constructs: Selection of multiple objects or numbers
Look up the programming concept Comparisions http://en.wikipedia.org/wiki/Comparison_...ogramming)

So we could actually do this...

Code:
<ARGN1> == 1 || <ARGN1> == 2 || <ARGN1> == 3 || <ARGN1> == 4 ...

Those || mean OR so this works.

But a quick glance at that link should show there's a better way.

Code:
<ARGN1> < 17
(This post was last modified: 06-21-2012 07:12 AM by Anarch Cassius.)
06-21-2012 07:12 AM
Find all posts by this user Like Post Quote this message in a reply
Kyrbis
Journeyman
*

Posts: 54
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Mar 2012
Reputation: 0



Post: #3
RE: IF constructs: Selection of multiple objects or numbers
As I read it, and tried....math is simply logical. Haven't thought of using this comparison, while it is so simple and compact. Thanks alot ^^
06-21-2012 08:11 AM
Find all posts by this user Like Post Quote this message in a reply
xwerswoodx
Journeyman
*

Posts: 86
Likes Given: 4
Likes Received: 7 in 4 posts
Joined: Jun 2012
Reputation: 0

UoMMO

Post: #4
RE: IF constructs: Selection of multiple objects or numbers
(06-21-2012 07:12 AM)Anarch Cassius Wrote:  
Code:
<ARGN1> < 17

This is better one Smile

But if you use complex; for example
1,6,12,60 etc

you can use this

Code:
[function f_seperator]
if (<argv[0]> == 0)
return <eval <argv> - 1>
else
return <argv[<argv[0]>]>
endif

[Defname d_asd]
asd=1,6,12,60

and in-code
Code:
for 1 <f_seperator 0,<def.asd>>
if <f_seperator <dlocal._for>,<def.asd>> == <ARGN1>
MESSAGE This is beyond your Rank.
RETURN 1
ENDIF
endfor
(This post was last modified: 06-21-2012 08:15 AM by xwerswoodx.)
06-21-2012 08:13 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)