| Name | Typ | Von |
|---|---|---|
| Globaler Befehlsprüfer | Definition | AFRLme |
Mit diesem Skript prüfst du, welche Befehle auf ein Objekt, ein Item oder einen Charakter angewendet werden können. Es wurde für das Coin-Interface entwickelt.
Anweisungen
1. Füge das Hauptskript im Skripteditor von Visionaire Studio hinzu und lege es als Definitionsskript fest.
2. Ersetze die Strings in der Tabelle t durch die Namen deiner Befehle; die Reihenfolge spielt keine Rolle, die Groß-/Kleinschreibung schon.
local t = {"close", "examine", "give", "open", "pick_up", "pull", "push", "talk", "use"}
3a. Lege im Reiter Bedingungen deines Befehls-Interface für jeden Befehl eine Bedingung an; die Namen müssen den Namen der Interface-Buttons und der Einträge in der Tabelle t entsprechen.
3b. Hänge an jede dieser Bedingungen die Endung "_cond" an, also so ...
use_cond talk_cond etc...
4. Lege für jedes Objekt, jedes Item und jeden Charakter beim Betreten mit der Maus einen Aktionsteil Skript ausführen an mit ...
checkObjCmd()
5. Lege für jedes Objekt, jeden Charakter und jedes Item beim Verlassen mit der Maus einen Aktionsteil Skript ausführen an mit ...
resetCmdCond()
Hauptskript
--[[
Global Command Checker [v6] (17/03/2014)
Written by AFRLme [Lee Clarke]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: https://afrl.me
-- + --
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(VGameCurrentObject) -- store the object underneath the cursor
-- * --
if not cmd:isEmpty() then
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
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