ID:179912
 
how could I incorporate gold as an item with FIREkings new weapon system? THis has been bugging the heck outta me
To tell you the truth, I wouldn't use it with FIREking's weapon system (unless, in your game, gold is a weapon)

Here is what I would suggest:

mob
var/gold = 0 as num
obj
gold
var
gold_amount = 100 as num
verb
get()
set src in oview(1)
usr.gold += src.gold_amount
usr << "You just picked up [gold_amount] gold! You now have [usr.gold] gold!"
del(src)


This makes a gold variable for the player. When they pick up gold, it adds the amount of gold in the gold to the players' gold total. It then deletes the gold icon so that you dont' have to worry about it.

Good luck, Lord of Water
In response to Lord of Water
LoW, why in the name of a all the holy cows out there do you initialize a variable like so

mob/var/gold = 0 as num

if you set it equal to a number, it IS a number by default, its the same as doing this(although this wont compile)

mob/verb/Lalala() as verb

No point, because you've already said its a verb..

You never cease to amaze me :)

Alathon
In response to Alathon
I almost always define var types, even when no definition is needed. It's just a habbit I got into.

Personally, Alathon, I suggest that you get a mug and some steamy water, make yourself some calming, caffeen-free herb tea, and relax with a book in a chair. Get a few nights of good sleep. Then, maybe you will be a little more laid back.

Good luck, LoW.
In response to Alathon
Alathon wrote:
LoW, why in the name of a all the holy cows out there do you initialize a variable like so

mob/var/gold = 0 as num

if you set it equal to a number, it IS a number by default, its the same as doing this(although this wont compile) [snip]

Actually, believe it or not, it isn't. The 'as whatever' declaration after a variable tells the mapper's instance editor what acceptable values that variable accepts.

However, I'm fairly certain that isn't documented anywhere, so LoW is either a master of digging through the forums, or very lucky for happening upon a feature by accident. =)
In response to Spuzzum
Spuzzum wrote:
Alathon wrote:
LoW, why in the name of a all the holy cows out there do you initialize a variable like so

mob/var/gold = 0 as num

if you set it equal to a number, it IS a number by default, its the same as doing this(although this wont compile) [snip]

Actually, believe it or not, it isn't. The 'as whatever' declaration after a variable tells the mapper's instance editor what acceptable values that variable accepts.

In this case, the map editor would have happily accepted numbers without the extra bit at the end.
In response to Spuzzum
Oh, I see. Guess you learn something new every day. Sorry for the rough-sounding post, but at the time I had just finished a 6 hour math test, with a 6 hour biology test the day before and was very tired. And I guess I just figured it defined the variable type by setting it equal to a value(text string, number, etc) anyways, er...oops I guess :p

Alathon
In response to Lord of Water
much abliged...lol
thankyou

CrypTic
In response to Spuzzum
No, actually I had a lot of trouble trying to declare vars

var/number_A as number

so, I tried

var/number_A as num

and it worked!
In response to Skysaw
In this case, the map editor would have happily accepted numbers without the extra bit at the end.

True, but it would also accept any other variable type -- text and the like.

I have to admit, I haven't tested out this feature myself too much so I'm not actually sure if this is indeed what it does (or, if it should but is currently bugged). But from what I remember of the introduction of instance-editing, that's the case.
In response to Spuzzum
Spuzzum wrote:
In this case, the map editor would have happily accepted numbers without the extra bit at the end.

True, but it would also accept any other variable type -- text and the like.

I have to admit, I haven't tested out this feature myself too much so I'm not actually sure if this is indeed what it does (or, if it should but is currently bugged). But from what I remember of the introduction of instance-editing, that's the case.

I'm not disputing that there is a technical difference here, just that there might be a practical difference. For my work, I can't imagine accidentally giving a variable the wrong value type in the map editor, and having it be a problem. Especially for something that is pretty obviously supposed to be a number.
In response to Skysaw
Especially for something that is pretty obviously supposed to be a number.

Unless you do what I like to do... reuse variables. That's probably really bad programming style, but it's so much fun... =P