ID:149811
 
If you don't know what this is about, read my post in the bug forum...

obj
// Verbs are commands that players can type in to manipulate this object.
verb
Pick_Up()
if (src.name=="Gold Coins")
set src in view(1)
usr << "You pick up [src:amount] gold coins!."
usr.GOLD += src:amount
del(src)
else
set src in oview(1)
if(Move(usr))
usr << "You pick up the [src]."
else
usr << "You are unable to pick up the [src]."


It works for some players, not for others. And all players have started with the same stuff (aka I didn't add variables mid-way, it's been the same for a long time)...

[edit]
And remember on some players it just says "You pick up (ammount) gold coins!" and then shoots a type mismatch. And yes the ammount is correct.
You need to never use ":" use "." instead.
And it gets even better. When a player gets killed by an enemy, it calls the function RzLib_WarpToHome(usr). When a player gets killed by another player, it calls the function RzLib_WarpToHome(usr). Now when a player gets killed by an enemy, it gets warped to the start like normal. If a player gets killed by another player, neither player gets warped back home!

    // Warps back home...
RZLIB_WarpBackHome(mob/M)
STATSLIB_SetStats(M)
M.loc = locate(RzLib_HomeLoc_X,RzLib_HomeLoc_Y,RzLib_HomeLoc_Z)
M << "You have been magically warped back to the starting area!"
RZLIB_PlaceEquipment(M)
STATSLIB_SetStats(M)
In response to Nadrew
RancerZero.dm:83:error:src.amount:undefined var

.ammount wouldn't work unless i gave the var 'amount' to EVERY object...

[Edit]
And remember on some players it just says "You pick up (ammount) gold coins!" and then shoots a type mismatch. And yes the ammount is correct.

Does it put in an actual, non-zero number for (amount) here?

If so, the type mismatch might actually be coming from the line usr.GOLD += src:amount (src:amount wouldn't give a type mistmatch error if src didn't have an amount variable, anyway).
That would happen if GOLD was somehow set to something other than a number. You might want to put in some debug statements to check what GOLD is before it gets added to.
Also, I reccomend compiled in DEBUG mode, so you can see which line is causing the error.

Anyway, as Nadrew said, its usually not a good idea to use the : operator. In this case, that can be completely avoided by overriding PickUp() for your gold object, rather than doing it in the root PickUp() verb. Thats better object-oriented practice anyway.

-AbyssDragon
Dreq wrote:
obj
verb/Pick_Up()
if (src.name=="Gold Coins")
set src in view(1)
usr << "You pick up [src:amount] gold coins!."
usr.GOLD += src:amount
del(src)
else
set src in oview(1)
if(Move(usr))
usr << "You pick up the [src]."
else
usr << "You are unable to pick up the [src]."

Okay, you have a couple of problems here. The first, though it's not responsible for your bug: "set src" can only be used once; put it at the beginning of your verb.

Second: The : operator is to be avoided at all costs. It's usually a culprit behind these types of errors, and what's happening is that the amount var is incorrect. Very likely, the amount var is a text value, not a number. (I believe you can use "var/amount as num" to specify that amount has to be a number. Then your type mismatch error will move to wherever this is being set incorrectly.) Anyway, though this might not immediately solve your bug, you should change the code to use istype() instead of name to figure out if the object is a gold coin, and then set a var equal to src thus:
obj
verb/Pick_Up()
set src in oview(1)
if(istype(src,/obj/coins))
var/obj/coins/O=src
usr << "You pick up [O.amount] gold coin\s."
usr.GOLD += O.amount
del(src)
else
if(Move(usr))
usr << "You pick up [src]."
else
usr << "You are unable to pick up [src]."

In general, though, it's probably a better idea not to do this at all. Your Pick_Up() verb for ordinary objs should just use that second portion that ordinary objs use, and you should define the coins like this instead:
obj/coins
var/amount as num

Pick_Up() // this overrides obj/verb/Pick_Up()
set src in oview(1)
usr << "You pick up [amount] gold coin\s."
usr.GOLD += amount
del(src)

Lummox JR
In response to Lummox JR
(I believe you can use "var/amount as num" to specify that amount has to be a number. Then your type mismatch error will move to wherever this is being set incorrectly.)

"blah as type" only works in verb arguments (you can do it in proc arguments too, but that's only useful if you plan on adding the proc to a verbs list at some point). While it compiles in other code, it doesn't actually do anything.

-AbyssDragon
In response to AbyssDragon
AbyssDragon wrote:
(I believe you can use "var/amount as num" to specify that amount has to be a number. Then your type mismatch error will move to wherever this is being set incorrectly.)

"blah as type" only works in verb arguments (you can do it in proc arguments too, but that's only useful if you plan on adding the proc to a verbs list at some point). While it compiles in other code, it doesn't actually do anything.

I believe I read once that "as num" in a var declaration will actually force it to use only numerical input from the input() proc.

Lummox JR
In response to Lummox JR
Ok that makes sense, but what about my other problem? (thanks ^_^)
In response to Dreq
Dreq wrote:
Ok that makes sense, but what about my other problem? (thanks ^_^)

So, just for the record, are you still having this trouble?

If so, please insert the following before you do the addition.

ASSERT(isnum(amount) || amount == null)