SetVal (CMS)

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 18:21, 19 August 2014 by David Stoffel (talk) (Text replacement - "wikitable" to "ts")
Name Type By
setVal("v", n) Definition AFRLme

This small function allows you to quickly set the string or integer value of a value; automatically determines if n 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. To use this function you should create an execute a script action containing...

setVal("value_name", 7) -- set integer value of "value_name" to 7

2b. Alternatively to set string value of a value...

setVal("value_name", "hello world") -- set string value of "value name" to "hello world"

Main Script

function setVal(v, n)
 if type(n) == "number" then
  getObject("Values[" .. v .. "]"):setValue(VValueInt, n)
 elseif type(n) == "string" then
  getObject("Values[" .. v .. "]"):setValue(VValueString, n)
 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.
n "string" or integer (number) This should contain a "string" or integer value.