ID:173547
 
i need help can you tell me whats wrong with my code

var/obj/gold/G = new(loc)


it keeps givving me this error


loading testworld.dme
testworld.dm:26:error::invalid expression

testworld.dmb - 1 error, 0 warnings (double-click on an error to jump to it)
var/obj/gold/G = new/obj/gold(loc)

you need to give the loc a ref i think, like src.loc
In response to Repiv
Repiv wrote:
var/obj/gold/G = new/obj/gold(loc)

you need to give the loc a ref i think, like src.loc

<code>mob/verb/Create(item_type in typesof(/item) - /item) new item_type (loc)</code>

That would work just fine. I don't think the error is in the line of code he posted. Either that or I'm just missing something very obvious.
In response to Foomer
ok i kind of fixed that problem

that code was when a monster dies it drops gold this is my whole code



obj
gold
icon = 'gold.dmi'
icon_state = "gold"
var
amount
verb
get()
set src in view(1)
var/obj/gold/G = new(loc)
G.amount = rand(1,100)
..()
usr << "you picked up [amount] gold"
usr.wealth += amount
del(src)







now im not getting any errors but when i kill a monster the gold wont come up

and i made the gold icon under gold.dmi so it should be working but its not can you tell me what the problem is
In response to Blades
Blades wrote:
verb
get()
set src in view(1)
var/obj/gold/G = new(loc)
G.amount = rand(1,100)
..()
usr << "you picked up [amount] gold"
usr.wealth += amount
del(src)

That looks like a nice little verb that creates a gold object, gives it a random value, gives you a message saying you picked it up, increases your wealth, then deletes the gold object, all in one instant.

Since you create and delete the gold in the same tick, you'll never see it.
In response to Foomer
Not really, no... the new obj is G, not src... plus, the way he describes the problem is that the gold item you'd be Get()ing doesn't appear to begin with.

I'm still not sure why he's creating a Gold item inside the player and then adding the amount of that Gold to the player's wealth, though...
In response to Blades
that code was when a monster dies it drops gold

Really? It does?

now im not getting any errors but when i kill a monster the gold wont come up

Oh, so it doesn't? But... but... you just said that it does! Did you actually mean to say, "When a monster dies, it's supposed to drop gold"?

So the monsters are supposed to do something, and it doesn't happen. Huh. Anyone ever tell the monsters about this? How can they do what they're supposed to if they don't know?

You say that's your "whole code"... well, I see code describing a gold object that you can get. What I don't see is any code instructing the game to make or drop one of these gold objects when a monster dies, do you? If you do have code to do that, why don't you show that to us, since that's what's not working? If you don't, then that's the problem.