Topper81 Posted February 19, 2022 Share Posted February 19, 2022 Hello, is it possible somehow to run a "COCKPIT PERFORM CLICKABLE ACTION" from lua script? Or is there another way to get a Device on misson startup? When I use "DO SCRIPT" and I put "local dev = GetDevice(9)" in the box, I get this error message: I want to create a script to change the cockpit configuration on startup and I prefere to use one script insted of multiple actions in the ME like here... Thank you! Link to comment Share on other sites More sharing options...
PravusJSB Posted February 28, 2022 Share Posted February 28, 2022 The function behind this is 'a_cockpit_perform_clickable_action' which lives in the global env on a client's 'mission luaState' and whilst I've never had a play with it myself I don't see why you couldn't use it on yourself / your own aircraft with a script but it would not work on a MP server for a client for example. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb Link to comment Share on other sites More sharing options...
Habu_69 Posted February 28, 2022 Share Posted February 28, 2022 (edited) For this purpose I have been trying to adapt snippets from the Macro_sequencies.lua (auto start) file, so far with no joy. Action lines take this form: push_start_command(dt, {device = devices.AMPCD, action = AMPCD_commands.AMPCD_off_brightness, value = 0.85}) I think the key is some editing of the functions and variables at the start of the script, but I have been unable to figure it out. If we can get this script to work, then invoke it with a do script trigger. Edited Macro-sequencies scripts do work in multi-player environment. Edited February 28, 2022 by Habu_69 Link to comment Share on other sites More sharing options...
PravusJSB Posted March 1, 2022 Share Posted March 1, 2022 You cannot just call any function you find, they all exist in different environments. I would hazard a guess that function would reside in the actual code for the module and thus its own lua state youre not going to get access to. And yes, things work on 'self' in MP, but not to call on other Clients. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb Link to comment Share on other sites More sharing options...
Habu_69 Posted March 1, 2022 Share Posted March 1, 2022 10 hours ago, PravusJSB said: You cannot just call any function you find, they all exist in different environments. I would hazard a guess that function would reside in the actual code for the module and thus its own lua state youre not going to get access to. And yes, things work on 'self' in MP, but not to call on other Clients. I think this is the key function. I can't find the definition of sequence anywhere, so it may be buried in the code and inaccessible from the scripting API. function push_command(sequence, run_t, command) sequence[#sequence + 1] = command sequence[#sequence]["time"] = run_t end Link to comment Share on other sites More sharing options...
PravusJSB Posted March 1, 2022 Share Posted March 1, 2022 No, you're trying to call a C function that isn't exposed to the mission luaState, you cannot do that. The function above is the correct one for the OP's question, it resides in 'gui' and 'export' luaState so scripting in those states will achieve what he wants. Further to that I've not looking into this at all, just shooting from the hip so to speak. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb Link to comment Share on other sites More sharing options...
Recommended Posts