Page 1 of 1

Remedial programmer gets crash in tutorial

Posted: Sun Oct 25, 2020 6:16 am
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)???
.

Re: Remedial programmer gets crash in tutorial

Posted: Sun Oct 25, 2020 8:51 am
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.

Re: Remedial programmer gets crash in tutorial

Posted: Mon Nov 09, 2020 8:27 pm
by Sir Tawmis
I, for one, am very thankful Isaac is around here. :)