Why my lua not printing repeatedly

I have a code like this:
local PARAM_TABLE_KEY = 100
assert(param:add_table(PARAM_TABLE_KEY, “SPREAD_”, 1), ‘Could not add parameter table’)
assert(param:add_param(PARAM_TABLE_KEY, 1, ‘TRG_RTE’, 150), ‘Could not add TARGET_RATE parameter’)

local TRG_RTE = Parameter()
TRG_RTE:init(‘SPREAD_TRG_RTE’)
local TARGET_RATE = TRG_RTE:get()

function update()

gcs:send_text(6, "TARGET_RATE is: " .. tostring(TARGET_RATE))

end
return update, 1000
Log output:
11/21/2024 2:54:41 PM : Lua: No scripts to run
11/21/2024 2:54:40 PM : Lua: No scripts to run
11/21/2024 2:54:39 PM : Lua: No scripts to run
11/21/2024 2:54:38 PM : Lua: No scripts to run
11/21/2024 2:54:38 PM : TARGET_RATE is: 100.0
11/21/2024 2:54:37 PM : Scripting: restarted
11/21/2024 2:54:36 PM : Scripting: stopped
My aim is to add a custom parameter and when the machine running I can modified this param without reload the Lua.
My question is why it only print once? Isn’t it suppose to print repeatedly?

You must also let the function call itself:

function update()
 ... ...
 return update, 1000
end

Note: By calling it every second, you fill the GCS with text every second. I would only output the text when the value of current_trick_id changes.

Rolf

1 Like

Yesssss, thank u Rolf
Can i ask how can u make these come as a code block:
function update()
… …
return update, 1000
end

Rolf

1 Like