I actually wrote a global control script for Thomas (marvel) recently for the directors cut of Zak McKracken 2, for a coin interface in which we have it on mouse over an object get all actions associated with the object to determine which actions of the ring interface should be active.
Yeah sure it's potentially possible to use Lua & the mouseEvent handler instead of creating cursor enter actions for each object.
You would use the mouse move listener & then on mouse move you would query if an object exists underneath the cursor which you could then add some queries & code inside to determine what to do.
here is the script I created for Zak 2... it's not what you are after but you can see how I created a global function with hardly any lines of code.
--[[
Globally check what commands for object, character or items are available (v5)
Written by AFRLme
-- * --
label@alternatingfrequencies.com | aim, skype, trillian @ AFRLme
--]]
-- * let's create some local variables & tables to store some init stuff * --
local tblCond = {"ziehe", "benutze", "gib", "schau_an", "rede_mit", "oeffne", "nimm", "druecke", "schliesse"} -- add command/condition names here (should both have same name)
--local prefix = "_tasche_de"
-- * let's create the function which will determine what type of object is currently underneath the mouse cursor * --
function checkObjCmd()
tblObj = {} -- create an empty table
tblObj["_temporary_"] = "" -- set the table to temporary
tblObj["cmd"] = game:getLink(VGameSavedObject) -- store the object underneath the cursor
print(tblObj["cmd"]) -- print the objects name & table id numbers
if tblObj["cmd"]:getId().tableId == eCharacters then tblObj["cmd"] = tblObj["cmd"]:getLinks(VCharacterActions) else tblObj["cmd"] = tblObj["cmd"]:getLinks(VObjectActions) end
for i=1, table.maxn(tblObj["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 & check if condition is true or not * --
function getCmdCond(val)
--print(tblObj["cmd"][val]:getName()) -- prints out all of the commands for the object/character
for i=1, table.maxn(tblCond) do
if tblObj["cmd"][val]:getName() == "'" .. tblCond[i] .. "' executed" or tblObj["cmd"][val]:getName() == "'" .. tblCond[i] .. "' angewandt" or tblObj["cmd"][val]:getName() == "'" .. tblCond[i] .. "' executed (immediate)" or tblObj["cmd"][val]:getName() == "'" .. tblCond[i] .. "' angewandt (sofort)" then if not getObject("Conditions[" .. tblCond[i] .. "_cond]"):getBool(VConditionValue) then getObject("Conditions[" .. tblCond[i] .. "_cond]"):setValue(VConditionValue, true) end 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(tblCond) do
--print(tblCond[i] .. " before = ", getObject("Conditions[" .. tblCond[i] .. "_cond]"):getBool(VConditionValue) )
if getObject("Conditions[" .. tblCond[i] .."_cond]"):getBool(VConditionValue) ~= false then getObject("Conditions[" .. tblCond[i] .. "_cond]"):setValue(VConditionValue, false) end
--print(tblCond[i] .. " after = ", getObject("Conditions[" .. tblCond[i] .. "_cond]"):getBool(VConditionValue) )
end
end
I could look into it when I have some free time... maybe.
P.S: you must close any if queries with the same amount of
end. functions & loops must also be closed with an
end.
examples:
function func_name()
-- some code
end
if cond then
-- do something
else
-- do something else
end
if cond then
if cond2 then
-- do something
end
end
if cond then
-- do something
elseif cond2 then
-- do something else
elseif cond 3 then
-- do something else
end
if cond and not cond2 or cond == true and cond2 == false then
-- do something
end
P.P.S: you would be better off considering using values instead of conditions as you can create infinite values in a single value as opposed to true/false in a single condition.
P.P.P.S: start/stopAction can be done like you did (I think) or like so...
startAction("Actions[action_name]")