persistent error...ERROR - logic.lua:9: attempt to call a nil value

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
NikTB
Posts: 1
Joined: Wed Sep 11, 2024 7:12 pm

persistent error...ERROR - logic.lua:9: attempt to call a nil value

#1 Post by NikTB »

Hi
So, I'm getting to grips (read: reacquainting myself) with script writing to build switch panels for my Flight deck, migrating from SimVim.
I've managed to geta few switches working without an image on the panel. Whilst building the panel, want to add the image of the switch or button...

So, run the videos and copied the switch and button scripts/amended, your basic as follows:

function propsync_pressed()
print("I am pressed!")
end

function propsync_released()
print("I am released!")
end

propsync = button_add("press_off.png", "press_on.png", 50,50,100,100,propsync_pressed, propsync_released)

RUN the script and get - ERROR - logic.lua:9: attempt to call a nil value (global 'button_add') I've written several scripts for variations of adding an image and xxx-add persists in this error...

The .png are located in the correct resource folder and I just cannot fathom why I get this error.

Its gota be a basic mistake ... can you point me in the right direction, please.

Thank
Nik

User avatar
Ralph
Posts: 8156
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: persistent error...ERROR - logic.lua:9: attempt to call a nil value

#2 Post by Ralph »

The button add is the virtual button. In hardware functions you'll need to use hw_button_add

User avatar
Sling
Posts: 5284
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: persistent error...ERROR - logic.lua:9: attempt to call a nil value

#3 Post by Sling »

What you posted should work if it's used in an instrument script rather than a hardware function script.

As Ralph said you can't generate any graphics from a hardware function script.

Nik201
Posts: 7
Joined: Fri Aug 19, 2022 10:23 am
Location: Alicante

Re: persistent error...ERROR - logic.lua:9: attempt to call a nil value

#4 Post by Nik201 »

Hi Guys
Thanks.. for refreshing my knackered old memory!!
Yeh.. worked with instruments... Duh
Still thrashing around ... Getting there slowly. 🫤
As ever grateful ...
Cheers
Nik

Post Reply