Thought I'd start this for general questions, since my last thread was mostly about in game mechanics instead of Mudlet. Anyways, here goes.
Currently starting small and making key bindings on my keypad for movement. However, when I encounter an obstacle (such as water), I would want the script to catch it, such as
send("N")
if (cant walk that way, water)
send("SWIM N")
end
is this possible?
0
Comments
waterExit = true
Set the above in a perl regex trigger, then put into your keybind:
if not waterExit then
send("n")
else
send("swim n")
waterExit = false
end
There are probably better ways of doing it, but that's a quick off-the-top idea. Although if you're dealing with rivers and seas, you might be better off just investing in a waterwalk enchant.
After trying your suggestion, you'd have to try to swim once before the boolean would change, therefore wasting a keystroke. I want to see if I can make it more robust, so I've got this as the main code:
movement = {waterExit = false, direction = {}, keyPressed = false}
function movement.move(dir)
movement.direction = dir
send(dir)
--if movement.waterExit then
--send("swim "..dir)
--movement.waterExit = false
--end
movement.keyPressed = false
end
this for encountering water:
--if movement.keyPressed then
send("SWIM "..movement.direction)
--end
and this for the keystrokes:
movement.keyPressed = true
movement.move("N")
With this, it works fine, until I use the automapper and all hell breaks loose. I could easily combine the code for when the mapper encounters water, but I wanted to make this as unobtrusive as possible so that if/when I release it, it can just be plugged in and run. Any ideas?
edit. the code button for the forums doesn't seem to work =S
edit: whoops, delete the send("SW") line on the South West keybinding, heh
player = {
balance = true,
equilibrium = true,
right_arm = true,
left_arm = true,
right_leg = true,
left_leg = true,
psisuper = true,
psisub = true,
psiid = true,
afflicted = true,
maxhp = {},
maxmp = {},
maxego = {},
maxep = {},
maxwp = {},
hp = {}
}
--Should run only once when the character logs in (using gmcp.Char.StatusVars)
function getVitals()
-- Vitals and statistics for the player.
player = {
--True = has balance
balance = true,
--True = has equilibrium
equilibrium = true,
--And so on...
right_arm = true,
left_arm = true,
right_leg = true,
left_leg = true,
psisuper = true,
psisub = true,
psiid = true,
--Not afflicted with dibilitating affliction, such as paralysis, aeon, broken limb, blindness, etc
afflicted = true,
maxhp = tonumber(gmcp.Char.Vitals.maxhp),
maxmp = tonumber(gmcp.Char.Vitals.maxmp),
maxego = tonumber(gmcp.Char.Vitals.maxego),
maxep = tonumber(gmcp.Char.Vitals.maxep),
maxwp = tonumber(gmcp.Char.Vitals.maxwp),
hp = tonumber(gmcp.Char.Vitals.hp)
}
end
New question! (you people must be hating me right now)
Its possible to use:
gmcp.Char.Vitals
To trigger a function any time a vitals stat changed, but is it possible to use:
gmcp.Char.Vitals.hp
To only trigger when hp is lowered? (in this case a potion sipper. Reduces functions called and should hopefully reduce any associated lag in the long run).
function getVitals()
-- Vitals and statistics for the player.
--True = has balance
player.balance = gmcp.Char.Vitals.balance == "1"
--True = has equilibrium
player.equilibrium = gmcp.Char.Vitals.equilibrium == "1"
--And so on...
player.right_arm = gmcp.Char.Vitals.right_arm == "1"
player.left_arm = gmcp.Char.Vitals.left_arm == "1"
player.right_leg = gmcp.Char.Vitals.right_leg == "1"
player.left_leg = gmcp.Char.Vitals.left_leg == "1"
player.psisuper = gmcp.Char.Vitals.psisuper ~= "0"
player.psisub = gmcp.Char.Vitals.psisub ~= "0"
player.psiid = gmcp.Char.Vitals.psiid ~= "0"
player.prone = gmcp.Char.Vitals.prone == "1"
player.maxhp = tonumber(gmcp.Char.Vitals.maxhp)
player.maxmp = tonumber(gmcp.Char.Vitals.maxmp)
player.maxego = tonumber(gmcp.Char.Vitals.maxego)
player.maxep = tonumber(gmcp.Char.Vitals.maxep)
player.maxwp = tonumber(gmcp.Char.Vitals.maxwp)
player.hp = tonumber(gmcp.Char.Vitals.hp)
player.mp = tonumber(gmcp.Char.Vitals.mp)
player.ego = tonumber(gmcp.Char.Vitals.ego)
player.ep = tonumber(gmcp.Char.Vitals.ep)
player.wp = tonumber(gmcp.Char.Vitals.wp)
player.pow = tonumber(gmcp.Char.Vitals.pow)
player.momentum = tonumber(gmcp.Char.Vitals.momentum)
player.hp_percent = player.hp/player.maxhp
player.mp_percent = player.mp/player.maxmp
player.ego_percent = player.ego/player.maxego
endPlayer and all its variables are initialised in another script, and that works fine. Just doesn't work for this part =\
As for your script triggering, make sure the script name is set to getVitals. No brackets in the name.
You have received a new honour! Congratulations! On this day, you have shown your willingness to ensure a bug-free Lusternia for everyone to enjoy. The face of Iosai the Anomaly unfolds before you, and within you grows the knowledge that you have earned the elusive and rare honour of membership in Her Order.
Curio Exchange - A website to help with the trading of curio pieces in Lusternia.