UpdateData (CMS)

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 16:40, 21 August 2022 by AFRLme (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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},
{name = "condition_2", val = false},
{name = "value_1", val = 10},
{name = "value_1", val = "hello world"}

}

updateData(tbl)


Main Script

function updateData(t)
 for i = 1, #t do -- iterate through table stored in the t input variable
  if type(t[i].val) == "boolean" then -- check if condition
   Conditions[ t[i].name ].Value = t[i].val -- update condition
  elseif type(t[i].val) == "number" then -- check if value (number)
   Values[ t[i].name ].Int = t[i].val -- update value
  elseif type(t[i].val) == "string" 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 you want to update it with.