Page 1 of 1

How do I spawn items with a spell?

Posted: Mon Oct 08, 2012 6:52 pm
by Lollgramoth
I try to make a spell which spawns an item. But all I get is a very ugly way to exit Grimrock(Program shuts down if the onCast function is executed). What do I do wrong?
The Idea is to be able to select a hero with this item, so effects can take place.

Code: Select all

defineSpell{
   name = "Spawn_it",
   uiName = "Shmendrik",
   skill = "spellcraft",
   level = 1,
   runes = "EF",
   manaCost = 20,
   onCast = function(caster, x, y, direction, skill)
	 setMouseItem(spawn(healwave_item))
   end
}

Re: How do I spawn items with a spell?

Posted: Tue Oct 09, 2012 9:04 pm
by Edsploration
I haven't played with this myself, but I can at least point out that the spawn function should have a string as its first argument:

Code: Select all

setMouseItem(spawn("healwave_item"))

Re: How do I spawn items with a spell?

Posted: Wed Oct 10, 2012 5:41 pm
by Lollgramoth
hooray. That was the solution. Puzzel solved, Edsploration thank you very much.

Re: How do I spawn items with a spell?

Posted: Wed Oct 10, 2012 6:31 pm
by Montis
Lollgramoth wrote:I try to make a spell which spawns an item. But all I get is a very ugly way to exit Grimrock(Program shuts down if the onCast function is executed). What do I do wrong?
The Idea is to be able to select a hero with this item, so effects can take place.
Keep in mind that any mouse-held item will be overridden if you use setMouseItem.

Re: How do I spawn items with a spell?

Posted: Mon Oct 15, 2012 10:30 pm
by msyblade
U need to have quotes around the item you want to spawn in the string.
Example: setMouseItem(spawn("snail_slice"))
end
yer missing those quotes ", otherwise you got it right ! :)