Skip to content

Commit

Permalink
AP_Scripting: add example usage of send_named_int
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-xD committed Jan 3, 2025
1 parent b6a5f6a commit 1824458
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libraries/AP_Scripting/examples/simple_loop.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
-- This script is an example of saying hello. A lot.
-- Pick a random number to send back
local number = math.random()
local number_float = math.random()
local number_int = math.random(1, 100)

function update() -- this is the loop which periodically runs
gcs:send_text(0, "hello, world") -- send the traditional message

gcs:send_named_float('Lua Float',number) -- send a value
number = number + math.random() -- change the value
gcs:send_named_float('Lua Float',number_float) -- send a float value
gcs:send_named_float('Lua Int',number_int) -- send an int value
number_float = number_float + math.random() -- change the float value

return update, 1000 -- reschedules the loop
end
Expand Down

0 comments on commit 1824458

Please sign in to comment.