SetVal (CMS)
From The Official Visionaire Studio: Adventure Game Engine Wiki
Name | Type | By |
---|---|---|
setVal("v", d) | Definition | AFRLme |
This small function allows you to quickly set the string or integer number belonging to a value with optional duration for integers, in case you need it.
Quick note: automatically determines if d is a string or integer. |
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Usage Example #1: immediately update integer value of specified value to 7.
setVal("value_name", 7)
2b. Usage Example #2: update integer value of specified value from current value to 7 over 250ms.
setVal("value_name", 7, 250)
2c. Usage Example #3: update string belonging to the specified value to "hello world!".
setVal("value_name", "hello world!")
Main Script
function setVal(v, d, duration)
duration = duration or 0 -- fallback in case duration equals nil
-- + --
if type(d) == "number" then -- check if number
Values[v]:to(duration, {Int = d}) -- update integer belonging to the specified value
elseif type(d) == "string" then -- check if string
Values[v].String = d -- update string belonging to the specified value
end
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
v | "string" | This should be a "string" value containing the name of the value you want to affect. |
d | "string" or integer | This should contain a "string" or number value. |
duration | integer | This should contain a number value in milliseconds of how long you want the current integer value to take to get from the current value to the target value. |