-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcreate_parameter.lua
61 lines (48 loc) · 1.83 KB
/
create_parameter.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- Description: This script shows how to create and use a parameter
-- create and use a parameter
function create_parameter()
-- define the table key
local TABLE_KEY = 93
-- create parameter table
if not param:add_table(TABLE_KEY, "ASD_", 3) then
gcs:send_text(7, "Unable to add ASD_ table")
return
end
gcs:send_text(7, "Successfully added ASD_ table")
-- add first parameter
if not param:add_param(TABLE_KEY, 1, "PARM_1", 1.0) then
gcs:send_text(7, "Unable to add ASD_PARM_1 parameter")
return
end
gcs:send_text(7, "Added ASD_PARM_1 parameter successfully")
-- add second parameter
if not param:add_param(TABLE_KEY, 2, "PARM_2", 2.0) then
gcs:send_text(7, "Unable to add ASD_PARM_2 parameter")
return
end
gcs:send_text(7, "Added ASD_PARM_2 parameter successfully")
-- add third parameter
if not param:add_param(TABLE_KEY, 3, "PARM_3", 3.0) then
gcs:send_text(7, "Unable to add ASD_PARM_3 parameter")
return
end
gcs:send_text(7, "Added ASD_PARM_3 parameter successfully")
-- create ASD_PARM_1 parameter object
local ASD_PARM_1 = Parameter()
if not ASD_PARM_1:init("ASD_PARM_1") then
gcs:send_text(7, "Failed to initialize the parameter")
return
end
-- notify the user about the parameter value
gcs:send_text(7, "Value of ASD_PARM_1: " .. ASD_PARM_1:get())
-- set the parameter
local result = ASD_PARM_1:set(1.5)
-- notify the user about the result
gcs:send_text(7, "Parameter set operation result: " .. tostring(result))
-- notify the user about the parameter value
gcs:send_text(7, "Value of ASD_PARM_1: " .. ASD_PARM_1:get())
-- schedule the next call to this function
-- return create_parameter, 1000
end
-- start the script
return create_parameter()