Page 1 of 1

Help: replacing empty item with new one?

Posted: Mon Oct 08, 2012 5:38 pm
by uggardian
So my plan is to fill a used venom edge by spawning a "venom_edge" when "venom_edge_empty" is placed on altar.
What am I doing wrong? Here's my script:

Code: Select all

function venomFill()
	for i in altarPoison:containedItems() do
		if i.name == "venom_edge_empty" then
		venom_edge_empty:destroy()
		altarPoison:addItem(spawn("venom_edge"))
		end
	end
end
The editor says "attempt to index global 'venom_edge_empty' (a nil value)".
How to fix this problem? :oops:

Re: Help: replacing empty item with new one?

Posted: Mon Oct 08, 2012 6:09 pm
by Magus
uggardian wrote:So my plan is to fill a used venom edge by spawning a "venom_edge" when "venom_edge_empty" is placed on altar.
What am I doing wrong? Here's my script:

Code: Select all

function venomFill()
	for i in altarPoison:containedItems() do
		if i.name == "venom_edge_empty" then
		venom_edge_empty:destroy()
		altarPoison:addItem(spawn("venom_edge"))
		end
	end
end
The editor says "attempt to index global 'venom_edge_empty' (a nil value)".
How to fix this problem? :oops:
You try to delete venom_edge_empty instead of the item. Try "i:destroy()" instead of venom_edge_empty:destroy(), this should work

Re: Help: replacing empty item with new one?

Posted: Mon Oct 08, 2012 6:12 pm
by Lilltiger
uggardian wrote:So my plan is to fill a used venom edge by spawning a "venom_edge" when "venom_edge_empty" is placed on altar.
What am I doing wrong? Here's my script:

Code: Select all

function venomFill()
	for i in altarPoison:containedItems() do
		if i.name == "venom_edge_empty" then
		venom_edge_empty:destroy()
		altarPoison:addItem(spawn("venom_edge"))
		end
	end
end
The editor says "attempt to index global 'venom_edge_empty' (a nil value)".
How to fix this problem? :oops:
The error says it all, there is no variable that is named 'venom_edge_empty', you check if the item 'i' is name "venom_edge_empty", if so you should use the item 'i'.
So change 'venom_edge_empty:destroy()' to 'i:destroy()'

Re: Help: replacing empty item with new one?

Posted: Mon Oct 08, 2012 6:33 pm
by uggardian
I'm a complete idiot.. :oops:
Anyways thanks for help :)