Difference between revisions of "UpdateData (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | updateData({t}) || Definition || AF...") |
(No difference)
|
Revision as of 16:23, 21 August 2022
Name | Type | By |
---|---|---|
updateData({t}) | Definition | AFRLme |
This small function allows you to quickly update multiple types of data by passing a linked table through the function.
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. Usage example: update all visobj listed in the linked table.
local tbl = {
{name = "condition_1", val = true, typ = "bool"},
{name = "condition_2", val = false, typ = "bool"},
{name = "value_1", val = 10, typ = "int"},
{name = "value_1", val = "hello world", typ = "str"}
}
updateData(tbl) -- pass the tbl data through the function
Main Script
function updateData(t)
for i = 1, #t do -- iterate through table stored in the t input variable
if t[i].typ == "bool" then -- check if condition
Conditions[ t[i].name ].Value = t[i].val -- update condition
elseif t[i].typ == "int" then -- check if value (number)
Values[ t[i].name ].Int = t[i].val -- update value
elseif t[i].typ == "str" then -- check if value (string)
Values[ t[i].name ].String = t[i].val -- update value
end
end
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
t | table | This should be a table or linked table containing the "names" of the visobj that you want to update, along with the "data type", & the data value. |