Recent Additions

From Immwiki
Revision as of 05:04, 15 August 2003 by 67.123.72.xxx (Talk) (*Added in local variables)

Jump to: navigation, search
Local Variables
What are local variables?  Variables that, unlike the normal $0-$9
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.