[Mudlet] Quick Question

I could have sworn there used to be a thread for quick Mudlet questions, but can't seem to find it. Anyways, I have a question.

If I wanted a trigger to fire only if in a particular room, how would I go about doing that? Isn't there some sort of gmcp.Room.Info.area but without the area, and only for the room?
Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

Thanks!

Current position of some of the playerbase, instead of expressing a desire to fix problems:

Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


«1

Comments

  • gmcp.Room.Info.name
  • KlendathuKlendathu Eye of the Storm
    I would use either gmcp.Room.Info.num or mmp.currentroom, which returns the numeric ID of the room. Multiple rooms can have the same name, but their ID is unique.

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • How would I code that in an if statement?

    if gmcp.Room.Info.num == ## ?
    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • edited May 2018
    Pretty much exactly that.

    Personal example:
    <div>if gmcp.Room.Info.name=="Rally Point" then
       <span>send("queue addclear eqbal perform deliverance "..matches[2])
    end</span></div>
  • Stupid deliver bots.
  • Another similar question. I want to do two different things with the same script, based on being in dragon or lesser form. For example:

    if gmcp.(in dragon) then
    send("do thing")
    elseif gmcp.(not in dragon)
    send("do other thing")

    What's the gmcp for dragon/lesser forms?
    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • If gmcp.Char.Vitals.class == "Silver Dragon" then send("rend...") else send("whatever..?) end.

    Not in game right now, so my gmcp reference might be wrong. Class might be held in Charstats instead of vitals, can't recall off top of head.



         He is a coward who has to bring two friends as backup to jump people hunting.

  • Apologies it's 

    gmcp.Char.Status.class == "Silver Dragon"

    Just got into work to check now.
         He is a coward who has to bring two friends as backup to jump people hunting.

  • CyrCyr
    edited May 2018
    gmcp.Char.Status.class
    e: Didn't refresh, Xaden beat me to it. 

    Dunn tells you, "I hate you."
    (Party): You say, "Bad plan coming right up."
  • if gmcp.Char.Status.class:find("Dragon") then<br>   send( stuff )<br>else<br>   send( lesser form stuff )<br>end<br>

    In the event you get multiple dragon colours.

  • Antonius said:
    Should turn it into a function so you don't have to keep repeating that same piece of code everywhere (you'll likely do lots of checks for whether or not you're in Dragon in triggers, aliases, etc.):
    function inDragon()
        return string.find(gmcp.Char.Status.class, "Dragon")
    end
    
    Then you'd do:
    if inDragon() then
        send("something")
    else
        send("something else")
    end
    
    To go off my above one, and this... Can also do:
    function inDragon(colour)<br>   return ( gmcp.Char.Status.class:find("Dragon") and gmcp.Char.Status.class:find(colour:title()) )<br>end<br>
    And follow with:
    if inDragon("red") then<br>   send("red dragon stuff")<br>elseif inDragon("black") then<br>   send("black dragon stuff")<br>else<br>   send("lesserform stuff")<br>end<br>

  • Coding is my sworn enemy...

    I've been working on this, but can't get it any faster. I need just a tad bit more speed.

    This is a rend alias that I have, which is too slow:

    (Please note that the 'venoms' variable is a toggle that I made to switch between sensitivity/curare and impatience/prefarar.)


    if gmcp.Char.Status.class == "Black Dragon" and venoms == true then

    send("clearalias dragonalias|setalias dragonalias dragoncurse " ..target.. " sensitivity 1/rend "..target.. " left leg curare")
    send("clearqueue all|queue add eqbal stand|queue add eqbal dragonalias")
    send("breathgust " .. target)

    elseif gmcp.Char.Status.class == "Black Dragon" and venoms == nil then

    send("clearalias dragonalias|setalias dragonalias dragoncurse " ..target.. " impatience 1/rend "..target.. " left leg prefarar")
    send("clearqueue all|queue add eqbal stand|queue add eqbal dragonalias")
    send("breathgust " .. target)

    elseif gmcp.Char.Status.class == "Monk" then

    sendAll("clearqueue all", "queue add eqbal stand", "queue add eqbal combo " .. target .. " snk left hfp left hfp left")

    end


    And this is my bite alias:


    if gmcp.Char.Status.class == "Black Dragon" then

    send("clearalias dragonbite|setalias dragonbite bite "..target)
    send("clearqueue all|queue add eqbal dragonbite")

    elseif gmcp.Char.Status.class == "Monk" then

    send("clearqueue all|queue add eqbal stand|queue add bbt " .. target)

    end


    Can someone please help clean this up to give it some speed?
    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • What do you mean by too slow? Unless you've somehow managed to install Mudlet on something that is literally a potato, that code shouldn't take a noticeable amount of time to execute.
  • KlendathuKlendathu Eye of the Storm
    edited May 2018
    Prepend your dragonalias with stand instead of adding it separately to the queue. Use queue addclear instead of clear queue/queue add. No need to clearalias if you're redefining. Check for dragon once, then check for venoms:

    local&nbsp;cmds&nbsp;= {"stand"} -- table to which to add commands
    if gmcp.Char.Status.class:find("Dragon") then -- works for all colours now, wheee!
      local curse = "impatience" -- default curse
      local venom = "prefarar" -- default venom
      if venoms then
        curse = "sensitivity"
        venom = "curare"
      end
      table.insert(cmds,#cmds+1,"dragoncurse ".. target .. " " .. curse .. " 1")
      table.insert(cmds,#cmds+1,"rend " .. target .. " left leg " ..venom}&nbsp;
      send("set alias dragonalias " .. table.concat(cmds,"/"))
      send("queue addclear eqbal&nbsp;dragonalias")
    
    elseif&nbsp;gmcp.Char.Status.class == "Monk" then -- you get the idea

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • @Klendathu table.insert automatically adds to the end of the table if you don't specify an index, so table.insert(cmds, "dragoncurse " ...) is equivalent to table.insert(cmds, #cmds+1, "dragoncurse " ...), but saves on typing.
  • Ismay said:
    (Please note that the 'venoms' variable is a toggle that I made to switch between sensitivity/curare and impatience/prefarar.)


    if gmcp.Char.Status.class == "Black Dragon" and venoms == true then

    send("clearalias dragonalias|setalias dragonalias dragoncurse " ..target.. " sensitivity 1/rend "..target.. " left leg curare")
    send("clearqueue all|queue add eqbal stand|queue add eqbal dragonalias")
    send("breathgust " .. target)

    elseif gmcp.Char.Status.class == "Black Dragon" and venoms == nil then

    send("clearalias dragonalias|setalias dragonalias dragoncurse " ..target.. " impatience 1/rend "..target.. " left leg prefarar")
    send("clearqueue all|queue add eqbal stand|queue add eqbal dragonalias")
    send("breathgust " .. target)

    elseif gmcp.Char.Status.class == "Monk" then

    sendAll("clearqueue all", "queue add eqbal stand", "queue add eqbal combo " .. target .. " snk left hfp left hfp left")

    end

    Do you really need to use a serverside alias? Your command would not hit the limit afaik. Be a model citizen and not spam with write/overwrites. Maybe that is where you are losing speed, because as Antonius says, your code should execute in no time.

    Look at the timestamps.

    41:15:369 ∘ You have cleared alias "roflmao".
    41:15:369 ∘ Alias "roflmao" will now execute: "yawn"
    41:15:369 ∘ You are exhausted and open your mouth in an enormous yawn.
    41:15:369 ∘ 5980 (100) (99) [ex] ckdb-
    41:15:727 ∘ You have cleared alias "roflmao".
    41:15:727 ∘ Alias "roflmao" will now execute: "yawn"
    41:15:727 ∘ You are exhausted and open your mouth in an enormous yawn.
    41:15:727 ∘ 5980 (100) (99) [ex] ckdb-
    41:16:181 ∘ You have cleared alias "roflmao".
    41:16:181 ∘ Alias "roflmao" will now execute: "yawn"
    41:16:182 ∘ You are exhausted and open your mouth in an enormous yawn.

    41:59:283 ∘ 5980 (100) (99) [ex] ckdb-
    42:00:954 ∘ You are exhausted and open your mouth in an enormous yawn.
    42:00:954 ∘ 5980 (100) (100) [ex] ckdb-
    42:01:062 ∘ You are exhausted and open your mouth in an enormous yawn.
    42:01:062 ∘ 5980 (100) (100) [ex] ckdb-
    42:01:195 ∘ You are exhausted and open your mouth in an enormous yawn.
    "All we have to decide is what to do with the time that is given to us."

  • Anyone know how to change this:


    send("unenemy all")
    if matches[3]:find(",") then enemies = string.split(matches[3], ", ") else
    enemies = string.split(matches[3], " ") end
    -- display(enemies)
    for k,v in pairs(enemies) do
    send("enemy " .. v)

    end



    To where it only fires when in dragon? Tried to do this and it didn't work:

    if gmcp.Char.Status.class == "Black Dragon" then

    send("unenemy all")
    if matches[3]:find(",") then enemies = string.split(matches[3], ", ") else
    enemies = string.split(matches[3], " ") end
    -- display(enemies)
    for k,v in pairs(enemies) do
    send("enemy " .. v)


    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • Ismay said:
    if gmcp.Char.Status.class == "Black Dragon" then

    send("unenemy all")
    if matches[3]:find(",") then enemies = string.split(matches[3], ", ") else
    enemies = string.split(matches[3], " ") end
    -- display(enemies)
    for k,v in pairs(enemies) do
    send("enemy " .. v)
    end
    end
    Add the bold text. The last for-statement is not closed, nor is the overarching if-statement about your class.
  • I did a forced update on the mapper, and ended up losing all my maps. Is there any way to retrieve those, and avoid it in the future?
    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • How do I enable a gmcp module? I can't seem to get the syntax right. I know there are 2 ways, but I can't remember either of them. D:
  • Zeris said:
    How do I enable a gmcp module? I can't seem to get the syntax right. I know there are 2 ways, but I can't remember either of them. D:
    sendGMCP('Core.Supports.Add ["Comm.Channel 1"]')
    sendGMCP('Core.Supports.Add ["IRE.Target 1"]')

    Like that?


  • edited July 2018
    I meant to post my question in the other thread. Not sure what happened. Yes that is exactly what I was looking for. Thank you.
  • So, I want to do different things when in different game environments. For instance, something kinda like this, though I know it's wrong:

    <code></code><code> if local env = grasslands then<br> dothing<br> if local env = mountains then<br> dothing<br> if local env = jungle then<br> dothing<br> if local env = hills then<br> dothing<br> if local env = swamp then<br> dothing<br> if local env = valley then<br> dothing<br> if local env = freshwater then<br> dothing<br> if local env = river then<br> dothing<br> if local env = water then<br> dothing<br> if local env = ocean then<br> dothing<br> end<br> end<br> endfunction Thing()<br> roomInfo = gmcp.Room.Info<br> local env = gmcp.Room.Info.environment<br> <br> if local env = natural underground then<br> dothing<br> if local env = forest then<br> dothing<br> if local env = garden then<br> dothing<br> if local env = desert then<br> dothing<br>

    This is probably really bad code, sorry to all you code gods. Can anyone help me out with this, please?



    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • KlendathuKlendathu Eye of the Storm
    if env == "Natural Underground" then

    elseif env == "Forest" then

    etc.

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • edited November 2018
    You can also get rid of the whole if ... else if by using a table:

    local actions = {
      ["natural underground"] = function()
          -- do something
        end,
      forest = function()
          -- do something
        end,
      -- ...
    }
    
    function Thing()
      local roomInfo = gmcp.Room.Info
      local env = roomInfo.environment
      local action = actions[env]
      if action then
        action()
      end
    end
    Edit: added provisions for environment without action
  • Keneanung said:
    You can also get rid of the whole if ... else if by using a table:

    local actions = {
      ["natural underground"] = function()
          -- do something
        end,
      forest = function()
          -- do something
        end,
      -- ...
    }
    
    function Thing()
      local roomInfo = gmcp.Room.Info
      local env = roomInfo.environment
      local action = actions[env]
      if action then
        action()
      end
    end
    Edit: added provisions for environment without action
    Hmm, I'm getting an error with this. Though, I probably don't understand it well enough to get it right.
    local actions = {
          ["natural underground"] = function()
              harvestingtimer = tempTimer(4, [[mmp.gotoRoom(HarvestList[1])]])
            end,
          ["forest"] = function()
              harvestingtimer = tempTimer(7, [[mmp.gotoRoom(HarvestList[1])]])
            end,
                ["garden"] = function()
                      harvestingtimer = tempTimer(7, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["desert"] = function()
                        harvestingtimer = tempTimer(4, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["grasslands"] = function()
                        harvestingtimer = tempTimer(4, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["mountains"] = function()
                        harvestingtimer = tempTimer(2, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["jungle"] = function()
                        harvestingtimer = tempTimer(5, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["hills"] = function()
                        harvestingtimer = tempTimer(4, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["swamp"] = function()
                        harvestingtimer = tempTimer(5, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["valley"] = function()
                        harvestingtimer = tempTimer(2, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["freshwater"] = function()
                        harvestingtimer = tempTimer(2, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["river"] = function()
                        harvestingtimer = tempTimer(2, [[mmp.gotoRoom(HarvestList[1])]])
                    end
                ["water"] = function()
                        harvestingtimer = tempTimer(2, [[mmp.gotoRoom(HarvestList[1])]])
            end
                ["ocean"] = function()
                        harvestingtimer = tempTimer(2, [[mmp.gotoRoom(HarvestList[1])]])
                    end
        }
        function Harvesting()
          local roomInfo = gmcp.Room.Info
          local env = roomInfo.environment
          local action = actions[env]
          if action then
            action()
          end
        end


    I put this in Scripts. Does anything need to be added?
    Give us -real- shop logs! Not another misinterpretation of features we ask for, turned into something that either doesn't help at all, or doesn't remotely resemble what we wanted to begin with.

    Thanks!

    Current position of some of the playerbase, instead of expressing a desire to fix problems:

    Vhaynna: "Honest question - if you don't like Achaea or the current admin, why do you even bother playing?"


  • KlendathuKlendathu Eye of the Storm
    You need a comma after each end

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • Also bear in mind that Lua is case sensitive. Environments in GMCP are, as far as I know, capitalised (e.g. "Forest", not "forest"), so you'll want to make sure the keys in your actions table match exactly what's in GMCP, or that you're converting your env variable to lowercase using string.lower before using it as a key.
  • Is that for harvesting? 

    @Ismay I can show you what I have when I get home. Less functions. Might not be best code ever but it works. And Im fairly certain it uses way less functions (100% certain)

Sign In or Register to comment.