General Mudlet Questions

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?

Comments

  • edited June 2014
    ^There is water that way.\$ (Or whatever the text is, can't remember offhand)

    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.


    image
  • edited June 2014
    Thanks!

    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
  • edited June 2014
    Ok, got it working. Shouldn't interfere with any outside system, including the map autowalker. Super simple stuff, but if anyone wants it here it is. Just uses keys around your number pad to move and should autoswim you around if you don't have waterwalking. If you want to change keys, just select the direction you want to change and then press "Grab New Key" on the right

    edit: whoops, delete the send("SW") line on the South West keybinding, heh
  • Ok, new question. Trying to get a script to start once the character logs in to log all the important data so that I can have a basis to build other systems off (ie if I want to check this or that, I'd check from here). However, it doesn't seem to work at all. I can't even manually see the initial values for balance (should be true) using the lua command. Any ideas or tips?

    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

  • SynkarinSynkarin Nothing to see here
    What are you using to make this run? Events? Triggers? 

    There isn't a whole lot of information to go off of here. I'd recommend using echo's and the like to see what's working. Also, check the errors and see if anything comes up there.

    Everiine said:
    "'Cause the fighting don't stop till I walk in."
    -Synkarin's Lament.
  • It was an idea to store all your characters vitals in one place so it would be easier to maintain and call needed values. But I've since edited it since I didn't take this and that into account. Thanks though =)

    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).
  • edited June 2014
    Has anyone got any advice as to why the current script wont run when gmcp.Char.Vitals is updated? I do have gmcp.Char.Vitals in the event handlers box and I do have gmcp enabled:

    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

    end

    Player and all its variables are initialised in another script, and that works fine. Just doesn't work for this part =\
  • Zael said:
    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).
    You receive gmcp.Char.Vitals on each prompt already so it shouldn't be an issue.

    As for your script triggering, make sure the script name is set to getVitals. No brackets in the name.
    image
    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.
  • Thanks a billion, that did the trick! Don't know why I didn't realise that on my own =\
  • So, a new question for a new day. The autobasher I have will trigger when I check rooms or when creatures move in or out. However it wont trigger if I am following someone or I am in someones squad. I have tried using gmcp.Room.Info and gmcp.Char.Items, but neither seem to work. Any ideas?
  • edited June 2014
    Following somebody doesn't fire gmcp.Char.Items which is what holds what's in the room.

    What I do in this case is trigger: "You follow" to fire off sendGMCP("Char.Items.Room"). I also set a flag, since stuff happens in different order if you're walking yourself or following.

    Then a script is set to consume gmcp.Char.Items.List, it checks to see if that flag is set - if so, reset it and process whatever needs processing.
Sign In or Register to comment.