Global Command Checker (CMS)

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 19:24, 17 March 2014 by AFRLme (talk)
Name Type By
Global Command Checker Definition AFRLme

This script allows you to check which commands can be executed on each object, item or character.

* The content below is a temporary placeholder - the current version of the main script has not yet been tested! *

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. Add/Remove language tables to/from the iw & cj tables inside of the main script; as required.
3. Edit the string values inside of the iw table; as required. iw stands for initial word. It is the word that will be displayed before the currently held items name. The order of the strings inside of the table should reflect the integer value of the conjunction_class value. There should be a space after the word like so: "word ".

iw = {} -- initial word table
iw["English"] = {"Use ", "Give ", "Show ", "Combine "}
iw["French"] = {"Usage ", "Donner ", "Montrer ", "Combiner "}
iw["German"] = {"Benutzen ", "Geben ", "Zeigen ", "Kombinieren "}
iw["Spanish"] = {"Usar ", "Dar ", "Mostrar ", "Combinar "}

4. Edit the string values inside of the cj table; as required. cj stands for conjunction word. It is the word that is displayed after the currently held items name. The order of the strings inside of the table should reflect the integer value of the conjunction_class value. There should be a space on both side of each word like so: " word ".

cj = {} -- conjunction word table
cj["English"] = {" on ", " to ", " to ", " with "}
cj["French"] = {" en ", " à ", " à ", " avec "}
cj["German"] = {" auf ", " zu ", " zu ", " mit "}
cj["Spanish"] = {" en ", " a ", " a ", " con "}

5. Create a new value in the Visionaire Studio editor & call it: conjunction_class.
6. On mouse enter for each object/character/item, set conjunction_class value; as required.

Main Script

--[[
Global Command Checker [v6] (17/03/2014)
Written by AFRLme [Lee Clarke]
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]

-- * local variables * --
local cmd -- empty variables...

-- * tables * --
local t = {"close", "examine", "give", "open", "pick_up", "pull", "push", "talk", "use"} -- add command/condition names here (should both have same name)

-- * let's create the function which will determine what type of object is currently underneath the mouse cursor * --
function checkObjCmd()
 cmd = game:getLink(VGameSavedObject) -- store the object underneath the cursor
 -- * --
 if cmd:getId().tableId == eCharacters then cmd = cmd:getLinks(VCharacterActions) else cmd = cmd:getLinks(VObjectActions) end
 for i=1, table.maxn(cmd) do getCmdCond(i) end -- for each command listed in the table check if condition exists...
end

-- * let's create the function which determines if command equals one of the stored conditions & sets condition accordingly * --
function getCmdCond(val)
 for i=1, table.maxn(t) do
  if cmd[val]:getName() == "'" .. t[i] .. "' executed" or cmd[val]:getName() == "'" .. t[i] .. "' executed (immediate)" then getObject("Conditions[" .. t[i] .. "_cond]"):setValue(VConditionValue, true) end
 end
end

-- * let's create the condition for on mouse out which checks which conditions are true & resets them back to false * --
function resetCmdCond()
 for i=1, table.maxn(t) do
  if getObject("Conditions[" .. t[i] .."_cond]"):getBool(VConditionValue) then getObject("Conditions[" .. t[i] .. "_cond]"):setValue(VConditionValue, false) end
 end
end