Page 1 of 1

Trouble Set Mouse Item

Posted: Wed Dec 10, 2014 9:40 am
by Mysterious
Hi I am having trouble trying to set the mouse item eg:

spawn("coin_gold",3,22,6,1,0,"wiz_coin1")
setMouseItem("wiz_coin1.item")

The error says: invalid item. The coin is areal item when placed somewhere on the floor etc.. What am I doing wrong? Thxs :)

Re: Trouble Set Mouse Item

Posted: Wed Dec 10, 2014 9:45 am
by Aisuu
Can't you just do?

setMouseItem(spawn("coin_gold").item)

Re: Trouble Set Mouse Item

Posted: Wed Dec 10, 2014 9:54 am
by minmay
Mysterious wrote:Hi I am having trouble trying to set the mouse item eg:

spawn("coin_gold",3,22,6,1,0,"wiz_coin1")
setMouseItem("wiz_coin1.item")

The error says: invalid item. The coin is areal item when placed somewhere on the floor etc.. What am I doing wrong? Thxs :)
"wiz_coin1.item" is a string. setMouseItem() takes an ItemComponent as an argument, not a string. It looks like this is what you intended to do:

Code: Select all

spawn("coin_gold",3,22,6,1,0,"wiz_coin1")
setMouseItem(wiz_coin1.item)
You might find it useful to look at the Lua 5.1 Reference Manual and the Grimrock 2 Scripting Reference.

Also there is no point in adding the object to the map if you are going to just set it as the mouse item anyway. So you might as well do this instead:

Code: Select all

setMouseItem(spawn("coin_gold",nil,nil,nil,nil,nil,"wiz_coin1").item)

Re: Trouble Set Mouse Item

Posted: Wed Dec 10, 2014 9:55 am
by Mysterious
Yes that's it damm.. I saw this code before but could not remember it thxs a bunch for that guys :)