Difference between revisions of "SetVal (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "wikitable" to "ts")
Line 1: Line 1:
{| class="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
Line 31: Line 31:
  
 
== Syntax Breakdown ==
 
== Syntax Breakdown ==
{| class="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description

Revision as of 18:21, 19 August 2014

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.