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!
function checkOnUp1()
if getMouseItem("torch") then
counter_tree_1.counter:decrement()
end
end
Sadly the script runs even it is any item in the mouse. What to do?
THOM formaly known as tschrage _______________________________________________ My MOD (LoG1):Castle RingfortThread My MOD (LoG2):Journey To JusticeThread | Download
THOM formaly known as tschrage _______________________________________________ My MOD (LoG1):Castle RingfortThread My MOD (LoG2):Journey To JusticeThread | Download
Since we have to use getMouseItem().go.name instead of getMouseItem().name, I guess that means getMouseItem() returns a component. Not an entity like you would expect, and like it did in LoG1: viewtopic.php?f=14&t=3472&p=35426&hilit ... tem#p35426
Which component does it return, and why doesn't it return the entity?
It returns the ItemComponent held by the mouse. It does so because it's named "getMouseItem" and you'd expect a function named "get...item" to return an item.
Just to further clarify what it does... getMouseItem() can return nil; if it does, then getMouseItem().go will cause a halt. By first checking for nil, the second check never happens unless getMouseItem() returned other than nil.