Difference between revisions of "Recent Additions"

From Immwiki
Jump to: navigation, search
(*Added in local variables)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<b>Local Variables</b>
+
Nothing... yet.
  
What are local variables?  Variables that, unlike the normal $0-$9
+
[[category:Leviticus]]
mobvalues, persist only for the duration of the prog in which they're
+
created.  They can hold numeric or string values.  They are prefixed
+
with a % (as opposed to $ for mobvalues) and can be given any alphanumeric
+
name that is not a number.
+
 
+
They are otherwise used just like mobvalues, and work with:
+
 
+
mpvalueset
+
mpvalueup (*)
+
mpvaluedown (*)
+
mpvaluerand
+
mpmath
+
mpgetroomvnum
+
 
+
and with
+
 
+
if (mob/obj/room)value
+
 
+
NOTE!  You no longer need to use "mobvalue/objvalue/roomvalue" for
+
any of your if checks.  Just "value" should suffice.
+
 
+
Here is an example of the local variables in action:
+
 
+
mpvalueset gstr Hello, I am a local variable.
+
mpecho %gstr
+
mpvaluerand apples 1 3
+
mpecho I have %apples apples.
+
if value(apples) == 3
+
  mpecho Wow, that's a lot of apples!
+
endif
+
mpmath apples %apples * 2
+
mpecho I now have %apples apples.  That's twice as many as before!
+
 
+
I'm sure you can figure out what the above would do.
+

Latest revision as of 23:46, 26 April 2011

Nothing... yet.