Trouble Set Mouse Item

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Trouble Set Mouse Item

Post 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 :)
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: Trouble Set Mouse Item

Post by Aisuu »

Can't you just do?

setMouseItem(spawn("coin_gold").item)
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Trouble Set Mouse Item

Post 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)
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Trouble Set Mouse Item

Post by Mysterious »

Yes that's it damm.. I saw this code before but could not remember it thxs a bunch for that guys :)
Post Reply