mircscripting.info Forum Index mircscripting.info
#mIRCscripting Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Matrixed Variables

 
Post new topic   Reply to topic    mircscripting.info Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
SeeknDestroy
Major


Joined: 25 Dec 2004
Posts: 81
Location: Marijuanaville, USA

PostPosted: Wed Feb 01, 2006 4:29 am    Post subject: Matrixed Variables Reply with quote

This tutorial will teach you the basics of how to matrixed variables... also known as an array. You should already have a STRONG understanding of using all $variables and setting your own %variables before attempting to matrix.

*** General Rules ***

1) Rules are same as using () or [] = must have even matching pairs
2) [ ] must surround the whole variable name from the start of the first variable.
a) The [ ] are evaluation brackets, same as $eval
3) Space after every [ and every ]
4) $+ between everything to connect it
5) An extra set of [ ] around every variable, either $var or %var, used

*** Example 1 ***

Need to set %top.score.1 and %top.score.2 -
With the number being a variable, we'll use %x

set %top.score. [ $+ [ %x ] ] 150

if (%top.score. [ $+ [ %x ] ] > 100) { echo yippee }

*** Example 2 ***

Need to set score for $nick using %score.$nick

set %score. [ $+ [ $nick ] ] some value

if (%score. [ $+ [ $nick ] ]) { echo yippie $nick has a score above 0 }

*** Example 3 ***

Need to matrix $chan and $nick to keep the scores per-channel

set %score. [ $+ [ $chan ] $+ . $+ [ $nick ] ] some value

if (%score. [ $+ [ $chan ] $+ . $+ [ $nick ] ] > 100) { echo winner! }
Back to top
View user's profile Send private message Visit poster's website
atom_man
Quite Active


Joined: 22 Mar 2005
Posts: 35
Location: Norway

PostPosted: Wed Feb 01, 2006 7:08 am    Post subject: Reply with quote

Ok written, but why use it??

$eval($+(%score.,$chan,.,$nick,),2)
that would return the same..
if I remember correctly
_________________
We came, We saw, We conquered.
Back to top
View user's profile Send private message MSN Messenger
stefys
Major


Joined: 18 Jun 2005
Posts: 89
Location: Romania

PostPosted: Sat Feb 04, 2006 2:13 pm    Post subject: Reply with quote

, Sani
Code:

 if (%score. [ $+ [ $nick ] ]) { echo yippie $nick has a score above 0 }

would be better as
Code:

 if (%score. [ $+ [ $nick ] ] > 0) { echo yippie $nick has a score above 0 }


This is not a problem tho, since scores usually are bigger than 0 Smile
Good job!
Back to top
View user's profile Send private message
SeeknDestroy
Major


Joined: 25 Dec 2004
Posts: 81
Location: Marijuanaville, USA

PostPosted: Wed Mar 29, 2006 4:47 am    Post subject: Re: Matrixed Variables Reply with quote

SeeknDestroy wrote:
This tutorial will teach you the basics of how to use matrixed variables... also known as an array. You should already have a STRONG understanding of using all $variables and setting your own %variables before attempting to matrix.

*** General Rules ***

1) Rules are same as using () or [] = must have even matching pairs
2) [ ] must surround the whole variable name from the start of the first variable.
a) The [ ] are evaluation brackets, same as $eval
3) Space after every [ and every ]
4) $+ between everything to connect it
5) An extra set of [ ] around every variable, either $var or %var, used

*** Example 1 ***

Need to set %top.score.1 and %top.score.2 -
With the number being a variable, we'll use %x

set %top.score. [ $+ [ %x ] ] 150

if (%top.score. [ $+ [ %x ] ] > 100) { echo yippee }

*** Example 2 ***

Need to set score for $nick using %score.$nick

set %score. [ $+ [ $nick ] ] some value

if (%score. [ $+ [ $nick ] ]) { echo yippie $nick has a score above 0 }

*** Example 3 ***

Need to matrix $chan and $nick to keep the scores per-channel

set %score. [ $+ [ $chan ] $+ . $+ [ $nick ] ] some value

if (%score. [ $+ [ $chan ] $+ . $+ [ $nick ] ] > 100) { echo winner! }
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    mircscripting.info Forum Index -> Tutorials All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group