Remedial programmer gets crash in tutorial

Have trouble running Legend of Grimrock 2 or do you have questions about the purchasing options? Look for help here.
Post Reply
IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Remedial programmer gets crash in tutorial

Post by IttaBitta »

So I got this error and I don't know why.
...Help?

Code: Select all

function checkLevers()
print(frontdoorswitch_1:getLeverState(), frontdoorswitch_2:getLeverState(), frontdoorswitch_3:getLeverState(), frontdoorswitch_4:getLeverState())
end
attempt to call method 'getLeverState' (a nil value)???
.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Remedial programmer gets crash in tutorial

Post by Isaac »

Welcome to the forum. 8-)

LoG scripting changed with version 2. Most method/functions are now part of their respective components. A lever object now has a lever component.

So, what you want looks like this:

Code: Select all

function checkLevers()
print(frontdoorswitch_1.lever:isDeactivated(), frontdoorswitch_2.lever:isDeactivated(), frontdoorswitch_3.lever:isDeactivated(), frontdoorswitch_4.lever:isDeactivated())
end
Component names are user assignable, but their default name is usually the lowercase class name.

Here is a more recent and up-to-date scripting resource.

https://github.com/JKos/log2doc/wiki/Co ... -component
attempt to call method 'getLeverState' (a nil value)???
It's nil because it doesn't exist in LoG2.
User avatar
Sir Tawmis
Posts: 980
Joined: Mon Jul 30, 2012 8:15 am
Contact:

Re: Remedial programmer gets crash in tutorial

Post by Sir Tawmis »

I, for one, am very thankful Isaac is around here. :)
Define ... 'Lost.' Neverending Nights - The Neverwinter Machinima that WILL make you laugh!
Also read: Legend of Grimrock: Destiny's Chance here on the forum! Check out the site I made for Legend of Grimrock: Destiny's Chance.
Post Reply