[Ohrrpgce] thinking out loud about magic variables in hamsterspeak
James Paige
Bob at HamsterRepublic.com
Fri Jan 9 16:11:05 PST 2009
So in python you can do something pretty cool where you set up get/set
functions for a property name, and then you can read and write to it as
if it was a variable, buty all your reads and writes go through the
get/set functions
Why couldn't we do something kinda like this in HamsterSpeak?
Suppose we create a new class of variables. To distinguish them from
global and local variables, I'm going to call them "magic variables"
So maybe you create one with a command like this:
magic variable(v, get v, set v)
where v is the name of the new magic variable, "get v" is a script that
returns something, and "set v" is a script that takes 1 argument. See
how that could be cool?
magic variable(money, party money, set money)
Then you could set money by saying:
money := 100
Or retieve money by saying:
show value(money)
Now what would make this even cooler is if arguments could be added.
Maybe something like:
magic variable(spell, 3, read spell, write spell)
So you could specify 3 arguments to the "spell" magic variable,
something like this:
spell(who, 0, 0) := atk:Punch
or
get attack name(0, spell(who, 0, 0))
The above two examples operating on the first spell in the first spell
list of the hero specified in the "who" variable.
Anyway, I just wanted to share that idea while I had it, in case anyone
has any comments on whether or not it seems like a good idea, how how it
might be done better.
---
James Paige
More information about the Ohrrpgce
mailing list