Scripting for dummies Eng-Ru

Not sure it can be also problem with function that have running code.


Ed.:Nevermind got it!:)
Thanks again for your help.
The function names have had same name parts my_code and my_info.After changing that both scripts running fine. :)
Mods.png

Also i didn't realized that it's simple like that to make a function call in lua.:eek:
 

Attachments

  • gameplay_the_code.vpp_pc
    449 bytes · Views: 327
  • gameplay_my_info_panel.vpp_pc
    160 bytes · Views: 327
Last edited:
Ed.:Nevermind got it!:)
Thanks again for your help.
The function names have had same name parts my_code and my_info.After changing that both scripts running fine. :)
View attachment 18767
Also i didn't realized that it's simple like that to make a function call in lua.:eek:
You don't need two lua files, this code will activate and deactivate gps on the crouching
Code:
local My_Thread_Handle = INVALID_THREAD_HANDLE
local my_hud_switcher = false

function my_mod_message(msg)
  mission_help_table(msg, LOCAL_PLAYER)
end

function my_info_panel_code()
 if player_action_is_pressed("CBA_OFC_CROUCH") then
    if my_hud_switcher == false then
        show_location(true)
        my_mod_message("GPS activated")
        my_hud_switcher = true
    elseif my_hud_switcher == true then
    show_location(false)
    my_mod_message("GPS dectivated")
    my_hud_switcher = false
    end
    end
end


function gameplay_my_info_panel_init()
    My_Thread_Handle = thread_new("my_thread_manager")
 end

 function my_thread_manager()
 while true do
my_info_panel_code()
delay(1)
end
end
 
You don't need two lua files, this code will activate and deactivate gps on the crouching
Code:
local My_Thread_Handle = INVALID_THREAD_HANDLE
local my_hud_switcher = false

function my_mod_message(msg)
  mission_help_table(msg, LOCAL_PLAYER)
end

function my_info_panel_code()
 if player_action_is_pressed("CBA_OFC_CROUCH") then
    if my_hud_switcher == false then
        show_location(true)
        my_mod_message("GPS activated")
        my_hud_switcher = true
    elseif my_hud_switcher == true then
    show_location(false)
    my_mod_message("GPS dectivated")
    my_hud_switcher = false
    end
    end
end


function gameplay_my_info_panel_init()
    My_Thread_Handle = thread_new("my_thread_manager")
 end

 function my_thread_manager()
 while true do
my_info_panel_code()
delay(1)
end
end
Yeah,I know it was just a test.I would like to make a few experiments with Keyboard inputs cause i think we don't have "Input A$" or similar right?
And thanks for the example i will experiment with it. :)
 
Yeah,I know it was just a test.I would like to make a few experiments with Keyboard inputs cause i think we don't have "Input A$" or similar right?
No, we can't use some keys directly but we have action list in control_schemes.xtbl each action binded to some key. You can use this actions in your Lua script as I have used "CBA_OFC_CROUCH" here. Also you can create your own actions(I belive) in control_binding_set.xtbl but I am not sure.
 
No, we can't use some keys directly but we have action list in control_schemes.xtbl each action binded to some key. You can use this actions in your Lua script as I have used "CBA_OFC_CROUCH" here. Also you can create your own actions(I belive) in control_binding_set.xtbl but I am not sure.
Ok.Thanks.I read in some thread that the lua interpreter is a customized one.Do we have a list of the instruction set that is implemented in this lua version exept of the SR3 functions list?
 
Ok.Thanks.I read in some thread that the lua interpreter is a customized one.Do we have a list of the instruction set that is implemented in this lua version exept of the SR3 functions list?
Sadly but no, there is some file game_lib.lua with main functions and info for SR4 but that all. Also from my experience neither additional LUA library is working even math lib.
 
No, we can't use some keys directly but we have action list in control_schemes.xtbl each action binded to some key. You can use this actions in your Lua script as I have used "CBA_OFC_CROUCH" here. Also you can create your own actions(I belive) in control_binding_set.xtbl but I am not sure.
Yeah,i see.I found some interesting functions in the sandbox+ ETD version made by Fan of Saint's like vehicle_lights_on/off and also i will investigate the control schemes and control binding sets.Thanks for the hints.
 
Last edited:
I tried out your suggestions with action player but it doesn't work i think i have no typo but maybe it has to do something with other mods which are changing key bindings like sandbox+?
 

Attachments

  • gameplay_my_info_panel.lua
    1.5 KB · Views: 312
Also i experimented with concatenation but not with PRINT but with mission_help_table and it works like expected.Thats cool. :)
 

Attachments

  • gameplay_msg_code.lua
    375 bytes · Views: 314
Back
Top