Scripting for dummies Eng-Ru

You have typo in function gamelpay_msg_code_init()
This code show GPS activated on fire from gun and GPS deactivated on sprint
Code:
local My_Thread_Handle = INVALID_THREAD_HANDLE
a = "deactivated"
b = "activated"

function function_msg_off_on()
    if player_action_is_pressed("CBA_OFC_ATTACK_PRIMARY")  then
    mission_help_table("GPS " .. b, LOCAL_PLAYER)
    end
    if player_action_is_pressed("CBA_OFC_SPRINT") then
    mission_help_table("GPS " .. a, LOCAL_PLAYER)
    end
end

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

function my_thread_manager()
 while true do
function_msg_off_on()
delay(1)
end
end
 
You have typo in function gamelpay_msg_code_init()
This code show GPS activated on fire from gun and GPS deactivated on sprint
Code:
local My_Thread_Handle = INVALID_THREAD_HANDLE
a = "deactivated"
b = "activated"

function function_msg_off_on()
    if player_action_is_pressed("CBA_OFC_ATTACK_PRIMARY")  then
    mission_help_table("GPS " .. b, LOCAL_PLAYER)
    end
    if player_action_is_pressed("CBA_OFC_SPRINT") then
    mission_help_table("GPS " .. a, LOCAL_PLAYER)
    end
end

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

function my_thread_manager()
 while true do
function_msg_off_on()
delay(1)
end
end
Wow thats cool! Thank you very much for this solution.
Edit: works pretty cool man.Now i'm able to create the mod a lot more comfortable.
Btw.:If i start the gps in mod A and set a variable to true/false could this be recognized by mod B ? And if yes should it be set to global?
 
Last edited:
Btw.:If i start the gps in mod A and set a variable to true/false could this be recognized by mod B ? And if yes should it be set to global?
In theory yes but I didn't try this. Also I can't imagine any situation where it will be useful. All code you can realise in one lua file.
 
In theory yes but I didn't try this. Also I can't imagine any situation where it will be useful. All code you can realise in one lua file.
Thought that could be used for example to check if another mod is running or not if you make something like a modular mod.
 
Thought that could be used for example to check if another mod is running or not if you make something like a modular mod.
Global variables is dangerous because we don't have name all of them also we don't know which variables have created modders Maybe LUA chunk structure prevent name collision but I still don't understand how it works.
 
Global variables is dangerous because we don't have name all of them also we don't know which variables have created modders Maybe LUA chunk structure prevent name collision but I still don't understand how it works.
Yeah,thats what i thought and read about now.I'll make a few further experiments,thats fun.So thanks again for your help with coding the switch and all that information i learned a lot out of it. :)
 
Hi,
I have another question.Is mission help table the only way to make a text output in this lua version or can we use print or hopefully io.read or something to get a text from text file on screen.Does the mission help table have some settings in any xtable?I noticed that the mission help table makes a cr after 27 characters.
 
Hi,
I have another question.Is mission help table the only way to make a text output in this lua version or can we use print or hopefully io.read or something to get a text from text file on screen.Does the mission help table have some settings in any xtable?I noticed that the mission help table makes a cr after 27 characters.
I'm not very experienced in this. I know that SR4 has few text fields that allow to print some string. Help table can print some raw string so it's useful for debugging but maybe it show more if you using precompiled string, there are other functions for printing mission target that i have found in mission lua files but they doesn't print raw string. Maybe there is some way to output text to subtitle field but I am not sure.
 
I'm not very experienced in this. I know that SR4 has few text fields that allow to print some string. Help table can print some raw string so it's useful for debugging but maybe it show more if you using precompiled string, there are other functions for printing mission target that i have found in mission lua files but they doesn't print raw string. Maybe there is some way to output text to subtitle field but I am not sure.
Ok.Thanks.I'll try to experiment with the strings i already read about this a few things on the lua wiki.
 
Precompiled string. Message help table 331 chars. I don't thing that you can change text field size for it but you can try to find something in hud lua files
20180429190547_1.jpg
 
Last edited:
Back
Top