Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Mudlet questions & answers!

189101113

Comments

  • AntoniusAntonius Posts: 4,498Member @@ - Legendary Achaean
    Austere said:

    venom = "curare"
    _G[venom .. "timer"] = tempTimer(4, [[ Venomdo() _G[venom.."timer"] = nil ]])

    If I do that,  I am looking at having to do something like this?

    Next question would be,  is the venom variable pulled at the point the trigger is made, or when it fires? Assuming it is the point in fires,  I think I finally hit a wall in using timers of off a table. 
    With the way you have it set up, it would have the value at the point the timer fires used. To get it to be pulled when you create it, do something like this:

    _G[venom .. "timer"] = tempTimer(4, [[Venomdo();_G["]] .. venom .. [[timer"] = nil]])


    Austere
  • AustereAustere TennesseePosts: 2,185Member @@ - Legendary Achaean
    Antonius said:
    Austere said:

    venom = "curare"
    _G[venom .. "timer"] = tempTimer(4, [[ Venomdo() _G[venom.."timer"] = nil ]])

    If I do that,  I am looking at having to do something like this?

    Next question would be,  is the venom variable pulled at the point the trigger is made, or when it fires? Assuming it is the point in fires,  I think I finally hit a wall in using timers of off a table. 
    With the way you have it set up, it would have the value at the point the timer fires used. To get it to be pulled when you create it, do something like this:

    _G[venom .. "timer"] = tempTimer(4, [[Venomdo();_G["]] .. venom .. [[timer"] = nil]])


    This still looks like it is pulling the variable at the end of the timer instead of when it is created.  I couldn't find anything in the mudlet documentation involving any of this,  so it is a bit difficult for me to debug.  Any chance you can link me where it is spelled out at,  or possibly have another idea? 
  • AustereAustere TennesseePosts: 2,185Member @@ - Legendary Achaean
    As a heads up,  I got this working.  I don't know how,  I don't know why,  but it works.  The best conclusion I can come to is that @Antonius‌ is a coding god,  sent from on high to answer my questions.  Thank you! 
  • AerekAerek East Tennessee, USAPosts: 1,818Member @@ - Legendary Achaean
    Riddle me this:

    I have a script written in Mudlet. The script works perfectly, except that when I close Mudlet and re-open it, the script will not function until I've opened the Scripts menu, manually selected it, and "saved" it. I don't have to make any changes, just the act of clicking "Save Item" makes it spring to life.

    What could cause this, and how do I fix it?
    -- Grounded in but one perspective, what we perceive is an exaggeration of the truth.
  • JacenJacen Posts: 2,302Member @@ - Legendary Achaean
    edited March 2015
    Using variables in the script that aren't defined at Mudlet's startup, like the gmcp table. For instance, running something like 
    if gmcp.Char.Vitals then
    will break the script, since the gmcp table is empty, and you are attempting to dig into the table using a nil key.
    image
  • AerekAerek East Tennessee, USAPosts: 1,818Member @@ - Legendary Achaean
    That sounds like it might be the case. What's a workaround for that. Is there a way to make the script load up after those variables or tables have been filled?
    -- Grounded in but one perspective, what we perceive is an exaggeration of the truth.
  • LekiLeki Posts: 12Member
    Aerek said:
    That sounds like it might be the case. What's a workaround for that. Is there a way to make the script load up after those variables or tables have been filled?
    I believe mudlet has an onconnect flag you can use. That way the script won't try to load before you are actually connected to the game. Think that will fix it. Either that or you can raise an event for when gmcp updates and connect it to that.
    image
  • JacenJacen Posts: 2,302Member @@ - Legendary Achaean
    edited March 2015
    To be honest I can't remember how I worked around it. You could do something like this in a gmcp event script...

    name: vitalsEvent
    event: gmcp.Char.Vitals
    script:
    function vitalsEvent() if myScript.isInit == false then
    myScript.init()
    else
    myScript.eventFired()
    end
    end
    image
  • AntoniusAntonius Posts: 4,498Member @@ - Legendary Achaean
    Leki said:
    Aerek said:
    That sounds like it might be the case. What's a workaround for that. Is there a way to make the script load up after those variables or tables have been filled?
    I believe mudlet has an onconnect flag you can use. That way the script won't try to load before you are actually connected to the game. Think that will fix it. Either that or you can raise an event for when gmcp updates and connect it to that.
    Mudlet has an event for when scripts have finished loading (sysLoadEvent off the top of my head), but not for when you connect to the game.

    Exactly how you'd go about fixing the problem depends on the script and which variables you're trying to use that don't exist yet. Events are generally how you'd delay it until you have what you need available, but the exact event you want will vary.
  • LekiLeki Posts: 12Member
    Antonius said:
    Leki said:
    Aerek said:
    That sounds like it might be the case. What's a workaround for that. Is there a way to make the script load up after those variables or tables have been filled?
    I believe mudlet has an onconnect flag you can use. That way the script won't try to load before you are actually connected to the game. Think that will fix it. Either that or you can raise an event for when gmcp updates and connect it to that.
    Mudlet has an event for when scripts have finished loading (sysLoadEvent off the top of my head), but not for when you connect to the game.

    Exactly how you'd go about fixing the problem depends on the script and which variables you're trying to use that don't exist yet. Events are generally how you'd delay it until you have what you need available, but the exact event you want will vary.
    Not that it matters to me but I am pretty sure I read it before. This may or not be the case but they talk about the onConnect() function here. This may be a custom function, but I don't think so. Might not fix his problem though.

    http://forums.mudlet.org/viewtopic.php?f=9&t=2160

    image
  • VadimusesVadimuses Posts: 1,077Member @ - Epic Achaean
    Antonius said:
    Exactly how you'd go about fixing the problem depends on the script and which variables you're trying to use that don't exist yet. Events are generally how you'd delay it until you have what you need available, but the exact event you want will vary.
    http://wiki.mudlet.org/w/Manual:Event_Engine#sysConnectionEvent

    GMCP is negotiated (activated) after you connect though.
  • AerekAerek East Tennessee, USAPosts: 1,818Member @@ - Legendary Achaean
    edited March 2015
    I'll tip my hand if it helps isolate a fix.
    function AutoEngage(event, balance)
       if event == "svo lost balance" then
          if balance == "balance" then
             if Combat and AutoEngage then
                if Engaged ~= true then
                   if svo.bals.equilibrium then send("engage "..Target, false) end
                end
             end
          end
       end
    end

    I'm assuming the culprit is either the svo.bals.equilibrium, or perhaps that the script is loaded when I open up my profile, but the mentioned variables aren't set until I actually log in.

    Also, this puppy is ugly as sin. If there's a more streamlined way to do this, I wouldn't mind the critique.

    -- Grounded in but one perspective, what we perceive is an exaggeration of the truth.
  • AustereAustere TennesseePosts: 2,185Member @@ - Legendary Achaean
    edited March 2015
    Just move the script containing that to below all your svo scripts.  Honestly, this works better than anything else I have ever tried
  • AustereAustere TennesseePosts: 2,185Member @@ - Legendary Achaean
    Also, for scripts that use gmcp, I have had decent luck out of defining the variables myself lately,  though it wrecks my illusion script still.  Here is a few examples, not sure how bad this is,  but it works for me.  Also note, I realize the last table is wrong, i was lazy. 

    gmcp = gmcp or {}
    gmcp.Char = gmcp.Char or {}
    
    gmcp.Char.Name = gmcp.Char.Name or "Austere"
  • CynlaelCynlael Posts: 3,257Member @@ - Legendary Achaean
    You could always just make it so GMCP stuff doesn't fire off until you're logged in. (by using the Login line)

  • AustereAustere TennesseePosts: 2,185Member @@ - Legendary Achaean
     Is there any way to check to see if a variable is a string or a table?  I couldn't find anything last night,  but I admit, it was 3 am...maybe I was just looking at it wrong. 
  • JacenJacen Posts: 2,302Member @@ - Legendary Achaean
    type(variable)

    returns the type as a string ("number","string","table","function","nil")
    image
    Austere
  • KlendathuKlendathu Eye of the StormPosts: 2,911Member @@ - Legendary Achaean
    if type(v) == "table" then

    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."
    Austere
  • PathrisPathris BFEPosts: 19Member
    Has anyone made a script for the new GMCP defences/afflictions yet?
  • KeneanungKeneanung Posts: 584Member ✭✭✭✭ - Eminent
    Yes. It's pretty similar to a room item tracker. If nobody else can provide an example, I can do later today.
  • KlendathuKlendathu Eye of the StormPosts: 2,911Member @@ - Legendary Achaean
    Here's one I threw together for affs.

    http://pastebin.com/AuMRaEPB

    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."
    Keneanung
  • RekhyrRekhyr Posts: 56Member ✭✭✭ - Distinguished
    this is how I track afflictions since gmcp.Char.Afflictions.
    http://pastebin.com/CLrG0i0k

    and here is defences.
    http://pastebin.com/JmMRP9Tg
    Keneanung
  • PathrisPathris BFEPosts: 19Member
    That's awesome @Klendathu! Thanks a lot.
  • MagetaMageta Posts: 10Member
    I have a very simple script that tracks my XP gain, and I just recently trans'd vision and now it's all F'd up.

    You have slain a hideous, writhing squid, retrieving the corpse. [+0.59999999999999% 59.3%]

    How do I round that??


  • MagetaMageta Posts: 10Member
    Thank you @Keneanung math.ceil() did the trick!
  • SeifurSeifur Posts: 64Member ✭✭✭ - Distinguished
    local n = 59.3
    local p = 58.7
    
    local x = math.floor(((n - p) * 10^2) + 0.5) * 10^-2    --> 0.6
    retired
    AustereSena
  • SeifurSeifur Posts: 64Member ✭✭✭ - Distinguished
    I don't know why I thought using exponents was an easier solution. I could have just done this:
    math.floor(((n - p) * 10) + 0.5) / 10
    retired
  • AustereAustere TennesseePosts: 2,185Member @@ - Legendary Achaean
    I recently updated my mudlet to 3.0.0-delta and was having some issues with my mapper.  It will not longer allow me to zoom using the mouse(or even click anywhere or anything on the map)  I can't even click the bar that has the little arrow on it to expand the options.  I am assuming that my mapper code has simply fallen out of favor for something better.  I honestly, dunno.  Any help would be great. 

    GUI.Map_Container = Geyser.Container:new({
    name = "GUI.Map_Container",
    x = 0, y = 0,
    width = "100%",
    height = "100%",
    },GUI.Box1)
    
    GUI.Mapper = Geyser.Mapper:new({ name = "GUI.Mapper", x = 20, y = 20, width = GUI.Map_Container:get_width()-40, height = GUI.Map_Container:get_height()-40, },GUI.Map_Container)
    GUI.Box1CSS = CSSMan.new(GUI.BoxCSS:getCSS()) GUI.Box1CSS:set("background-color", "black") GUI.Box1:setStyleSheet(GUI.Box1CSS:getCSS())
Sign In to Comment.