Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Mudlet Scripting

1235718

Comments

  • MereliiMerelii Member Posts: 8
    Okay, so I have Geyser for Mudlet, and I can't get the gauges on the gui to attach to my stats. I'm not sure what I'm supposed to be doing to make it grab the values for my health.

    This is what is in the Gauges script folder. I have GMCP enabled, but I don't know how to make it grab the values. When I take damage, the bar doesn't move, for example.


    GUI.Footer = Geyser.HBox:new({

    name = "GUI.Footer",

    x = 0, y = 0,

    width = "100%",

    height = "100%",

    },GUI.Bottom)


    GUI.LeftColumn = Geyser.VBox:new({

    name = "GUI.LeftColumn",

    },GUI.Footer)


    GUI.RightColumn = Geyser.VBox:new({

    name = "GUI.RightColumn",

    },GUI.Footer)


    GUI.GaugeBackCSS = CSSMan.new([[

    background-color: rgba(0,0,0,0);

    border-style: solid;

    border-color: white;

    border-width: 1px;

    border-radius: 5px;

    margin: 5px;

    ]])


    GUI.GaugeFrontCSS = CSSMan.new([[

    background-color: rgba(0,0,0,0);

    border-style: solid;

    border-color: white;

    border-width: 1px;

    border-radius: 5px;

    margin: 5px;

    ]])


    GUI.Health = Geyser.Gauge:new({

    name = "Health",

    },GUI.LeftColumn)

    GUI.Health.back:setStyleSheet(GUI.GaugeBackCSS:getCSS())

    GUI.GaugeFrontCSS:set("background-color","red")

    GUI.Health.front:setStyleSheet(GUI.GaugeFrontCSS:getCSS())

    GUI.Health:setValue(math.random(100),100)

    GUI.Health.front:echo("Health")


    GUI.Mana = Geyser.Gauge:new({

    name = "Mana",

    },GUI.LeftColumn)

    GUI.Mana.back:setStyleSheet(GUI.GaugeBackCSS:getCSS())

    GUI.GaugeFrontCSS:set("background-color","blue")

    GUI.Mana.front:setStyleSheet(GUI.GaugeFrontCSS:getCSS())

    GUI.Mana:setValue(math.random(100),100)

    GUI.Mana.front:echo("Mana")


    GUI.Endurance = Geyser.Gauge:new({

    name = "Endurance",

    },GUI.RightColumn)

    GUI.Endurance.back:setStyleSheet(GUI.GaugeBackCSS:getCSS())

    GUI.GaugeFrontCSS:set("background-color","yellow")

    GUI.Endurance.front:setStyleSheet(GUI.GaugeFrontCSS:getCSS())

    GUI.Endurance:setValue(math.random(100),100)

    --GUI.Endurance.front:echo("Endurance")

    GUI.Endurance.front:echo([[<span style = "color: black">Endurance</span>]])


    GUI.Willpower = Geyser.Gauge:new({

    name = "Willpower",

    },GUI.RightColumn)

    GUI.Willpower.back:setStyleSheet(GUI.GaugeBackCSS:getCSS())

    GUI.GaugeFrontCSS:set("background-color","purple")

    GUI.Willpower.front:setStyleSheet(GUI.GaugeFrontCSS:getCSS())

    GUI.Willpower:setValue(math.random(100),100)

    GUI.Willpower.front:echo("Willpower")


    Anyone have any Ideas?
  • LionasLionas Member, Historian Posts: 765 ✭✭✭✭✭
    edited November 2013
    Knowing nothing about Geyser, I'm going to assume it relates to these lines:

    GUI.Mana:setValue(math.random(100),100)


    You may need to change that to

    GUI.Mana:setValue(gmcp.Char.Vitals.mp)



    It may be that you need to set the value inside a gmcp handler (that makes the most sense to me). Take a look at http://wiki.mudlet.org/w/Manual:Supported_Protocols#GMCP for help with that.
    I am the righteous one... 
    the claims are stated - it's the world I've created 
  • MereliiMerelii Member Posts: 8
    would that be .mp for mana, and then .hp for health?
  • LionasLionas Member, Historian Posts: 765 ✭✭✭✭✭
    edited November 2013
    http://www.ironrealms.com/gmcp-doc

    Char
      Sent by server:
        - Char.Vitals
          * Basic character attributes such as health, mana, etc.
          * Message body is an object containing several variables
          * Additionally, each variable is included in a string, in the format name:cur/max
          * Interpretation of the variables is game specific
          * It is generally safe to assume that the values are numbers (even though encoded as strings)
          * Example: Char.Vitals { "hp": "4500", "maxhp": "4800", "mp": "1200", "maxmp": "2500", "ep": "15000", "maxep": "16000", "wp": "14000", "maxwp": "15000", "nl": "10", "string": "H:4500/4800 M:1200/2500 E:15000/16000 W:14000/15000 NL:10/100" }

    tl;dr: hp is current hp, mp is current mp.

    EDIT: My last gmcp.char.vitals looks like this:
    {"bal":"1","maxmp":"6710","maxhp":"5720","string":"H:5720\/5720 M:6710\/6710 NL:44\/100 ","nl":"44","mp":"6710","hp":"5720","eq":"1","deaf":"1","salve":"0","blind":"1"}
    
    I am the righteous one... 
    the claims are stated - it's the world I've created 
  • CassiusCassius Member, Beta Testers Posts: 607 ✭✭✭
    edited November 2013
    Likely you will need mp, maxmp, hp, and maxhp for the gauge with:
    GUI.Mana:setValue(tonumber(gmcp.Char.Vitals.mp),tonumber(gmcp.Char.Vitals.maxmp))
    GUI.Health:setValue(tonumber(gmcp.Char.Vitals.hp,gmcp).tonumber(Char.Vitals.maxhp))

    Bear in mind I don't use geyser but this would appear to be the correct solution based on your previous code which I'm assuming was copied from some template.  For the gauge you'd need both the value and it's maximum range.
  • MereliiMerelii Member Posts: 8
    Okay i will try that this weekend when i get on the laptop. That makes a lot of sense, looking at it. I tried reading the manual, and got more confused.DX
    I'll let you know if it works. :D
  • AmbroseAmbrose Member Posts: 197 ✭✭✭
    This is kind of a minor thing because it's a niche thing that really only matters in content heavy RP or PK discussions where I need to say a lot at one time, but I use the Vyzor map window and whenever the resolution of the window things it needs to change - it really lags pretty bad, it usually recovers after about 30 seconds, but I was wondering if anyone had a quick fix for that?
  • RynnRynn Member Posts: 17
    I'd like to figure out how to build an affliction tracker.

    I have the knowledge of how to fight and score a kill, I know how to stack affs and everything, but the biggest problem for me is tracking it. I don't have the mental reflexes to actually manually track it, even with big flashy echoes, so I need to code a tracker that can tell me what affs someone has, and then a queue to apply affs based on that tracking.

    I know how to create aff variables and use aff/cure messages to set those variables, but I don't know how to add those afflictions to a table and then display that table on-screen so I know what to afflict with next. That's what I'm stuck at.

    It'd also be nice if I could figure out how to set up a window or a GUI or something that could tell me what a person's herb/salve/smoke/tree/purge balances are on and have timers for them, or at the very least an 'on' or 'off'.
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Problem 1:
    'add those afflictions to a table'
    Solution 1:
    i) set up a namespace; treat a main table like a website, and each affliction like its separate pages, eg.
    afflictions = {}
    ii) set up each affliction as a key in the main table, eg.
    afflictions.paralysis = "value"
    afflictions.metrazol = "value"
    afflictions.hemotoxin = "value"
    iii) set up an iterator to show you what afflictions are present and which are not.
    for aff, value in pairs(afflictions) do
    if value == "yourtruevalue" then display(aff) end
    end

    Solution 2:
    i) set up a comparator list, eg.
    tlist = { "paralysis", "metrazol", "hemotoxin", ……… }
    ii) set up a current list, eg.
    current_affs = {}
    iii) push an aff into your current list when delivered, eg.
    table.insert( "current_affs", currenttoxin )
    iv) write a function to remove an aff when cured, eg.
    aff_cure( "hemotoxin" ), where
    function aff_cure( toxin ) 
    if current_affs:contains( "hemotoxin" ) then
    current_affs:remove( current_affs:index_of( "hemotoxin" ) )
    end
    end
    v) write an iterator to display current_affs
    for i=1, #current_affs do
    display( current_affs[i] )
    end

    display() of course is the ugliest function imaginable.
    I use:

    eden.thing = Geyser.MiniConsole:new({

    name="affbox",

    x= -0.1*width,

    y= 440,

    width= 0.1*width, height="40c",

    })

    eden.thing:setFontSize(10)

    eden.thing:setColor(20,20,20,10)

    end


    To push something into it, do:

    // Clear it first

     clearWindow("affbox")

    // Then push

    cecho("affbox", "\nhemotoxin")


    So, use your iterator:

    for aff, value in pairs(afflictions) do
    if value == "yourtruevalue" then 
    cecho("affbox", "\n"..aff)
    end
    end

    There are many caveats and checks you need to do, but that is the basic idea. Of course, like in real life, there is more than one correct solution.
    wit beyond measure is a Sidhe's greatest treasure
  • AzefelAzefel Member Posts: 730 ✭✭✭✭
    @Iniar is terrible. Don't listen to him.

    Plus he uses a Mac (thus confirming his terribleness).
  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭
    Tracking what you give is easy (see Iniar's stuff above). Probably your most complex function will be the one that determines what they just cured. There are a ton of ways to go about that (ranging from just guess at an aff of the herb type and remove it to Kyrock math). That's typically what makes the difference between people who track well and badly though, if you're doubling up affs you're killing your progress.
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Ambrose said:
    This is kind of a minor thing because it's a niche thing that really only matters in content heavy RP or PK discussions where I need to say a lot at one time, but I use the Vyzor map window and whenever the resolution of the window things it needs to change - it really lags pretty bad, it usually recovers after about 30 seconds, but I was wondering if anyone had a quick fix for that?
    Just loaded up Vyzor, having no dramas with it - what are you doing specifically when it happens? Resizing the main Mudlet application, resizing the frame, receiving new data from the server?
    wit beyond measure is a Sidhe's greatest treasure
  • AmbroseAmbrose Member Posts: 197 ✭✭✭
    edited December 2013
    Does it pretty much when any resize happens - if I try to change the main Mudlet application window, if I get to typing a conversation, when the input line wraps the text over to a second line, etc.
  • TreydenTreyden Member Posts: 54
    Quick question, I didn't see any mention of balances and how to use GMCP to keep track of them, anyone mind giving me an example of how to do it or explain it a bit to me?
  • AzefelAzefel Member Posts: 730 ✭✭✭✭
    char.vitals has bal and eq keys that swap between 1 and 0 (also blind, deaf, prone, stun, bleed, etc)

    If you have existing things that work off GMCP, these work the same way. The best way of using GMCP that I can teach you is to uninstall mudlet (lua ftl) and use cmud (cmud admittedly is pretty terrible too, especially when it comes to GMCP).
  • AslakAslak Member Posts: 4
    You find all the GMCP data in Mudlet in the table named "gmcp". So for example gmcp.Char.Vitals is where you find balances, health, mana and so on. So checking if you're on balance is as easy as "if gmcp.Char.Vitals.bal == "1" then echo("I have balance") end". If you want to show the whole table you can type "lua display(gmcp)" in your command prompt - assuming you have the lua alias that should be standard today. If not, you find it on the Mudlet forum.

    If you want to bind a script to a gmcp event, you'll be able to find out when GMCP events are ran if you turn on Debug mode. This is commonly done to update all your balances, health etc each time it's updated, instead of binding a script to every prompt, which I believe is a slower process. This is of course a bit more advanced, but it's a tip.
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Trigger to make http links clickable:

    trigger pattern: (regex) 
    ([h|H]ttps?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]

    code:

    selectString(matches[1], 1)

    setUnderline(true)

    setLink([[openUrl("]]..matches[1]..[[")]], "Click to open in browser")

    resetFormat()

    wit beyond measure is a Sidhe's greatest treasure
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Ambrose said:
    Does it pretty much when any resize happens - if I try to change the main Mudlet application window, if I get to typing a conversation, when the input line wraps the text over to a second line, etc.
    http://forums.mudlet.org/viewtopic.php?f=5&t=1376&start=60

    "Unfortunately, any time Vyzor.HUD:Draw()is called, whatever it is that causes the slow-down occurs. I experimented with using the Draw() function directly on the frames I want to resize (in the instances when I am only adjusting specific portions of my gui rather than the entire thing) but with mixed success."
    wit beyond measure is a Sidhe's greatest treasure
  • AmbroseAmbrose Member Posts: 197 ✭✭✭
    Thanks for digging that up... you think there'd be any way to at least keep that function from being called when my input line gets longer than 1 line... I get that it will probably have to happen when I resize the window, but it gets to be a pain in the **** when I am typing a sentence and am limited to 140 characters, Twitter-style without having to have the slow-down hit me like a truck.
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Probably not. Vyzor is overly complicated, especially for what we (or I) use it for. See http://forums.mudlet.org/viewtopic.php?f=7&t=3481&p=17155&hilit=command+line#p17155 seems they are aware of it and want to squish it at some point. Haven't actually tested the script in that thread but might be worth looking into (instead of Vyzor).
    wit beyond measure is a Sidhe's greatest treasure
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Oh man, Ambrose, just did (no Vyzor/Geyser)

    sysWindowResizeEvent

    setBorderLeft( x )

    and my machine spazzed out. Bad codes imo. I'll write a lock-out later. Gotta catch some sleep.
    wit beyond measure is a Sidhe's greatest treasure
  • AmbroseAmbrose Member Posts: 197 ✭✭✭
    No worries, you're awesome man, thanks for looking into it for me. (Non-coding type and what not)
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    edited December 2013
    on sysWindowResizeEvent

    function eden.ui.resize()

    width, height = getMainWindowSize()

    eden.overmind.update() -- this draws a simple box, use this as a real-time guide


    if not eden.resizing then -- this is a lockout flag, start drawing if it's false

    eden.resizing = true -- enable your lockout

    if eden.resizeTimer then killTimer(eden.resizeTimer) end -- reset the timer

    eden.resizeTimer = tempTimer( 2, function() eden.ui.draw() end ) -- make a  timer to execute all your main drawing stuff only at t=2

    tempTimer( 3, function() if eden.resizeTimer and eden.resizing then killTimer( eden.resizeTimer) eden.resizing = false end end ) -- reset your lockout and kill your timer at t=3

    end

    end

    I imagine you would end up placing something like Vyzor's main Draw() function where I have eden.ui.draw()
    wit beyond measure is a Sidhe's greatest treasure
  • IluvIluv Member Posts: 703 ✭✭✭✭
    Is there a way to change Echolink's button color from blue?
  • AslakAslak Member Posts: 4
    setFgColor() will do the job for you
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    If you use MudletMapper, this short script will make your team-mates roomcall blink on your map.

    function doblink( room, color, duration )

    local colorn, durationn

    local r,g,b,br,bg,bb

    room = tonumber(room)

    if type(color) == "table" then

    r,g,b,br,bg,bb = unpack(color)

    end

    if not color then

    r,g,b,br,bg,bb = 220,0,0,255,186,23

    end

    if not duration then durationn = 5 else durationn = duration end


    highlightRoom(room,r,g,b,br,bg,bb,1,255,255)

    for i=0.5, durationn do

    tempTimer( i, function() highlightRoom( room, r,g,b,br,bg,bb, 1, 255, 255 ) end )

    tempTimer( i+0.5, function() unHighlightRoom( room ) end )

    end

    tempTimer( durationn + 1, function() unHighlightRoom( room ) end )

    end

    You invoke it by doing doblink(roomnumber), with optional parameters of doblink(roomnum, {colours in rgb format}, duration of blink)
    wit beyond measure is a Sidhe's greatest treasure
  • OrillOrill Member Posts: 1
    I've hit a problem with the mud let mapper. I updated the mapper, but now none of the aliases for using it are working (mc, rl, goto, etc.,). Nor does the mapper even seem to know where I am. it's stuck on one room and when I pass through that room it doesn't start tracking me either. Any ideas how to fix this?
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Might be worth checking out if you've overwritten mmp table with something of your own. Uninstall mud let mapper and reinstall it.
    wit beyond measure is a Sidhe's greatest treasure
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    The difference in gmcp for <blackout>

        Vitals = {
          deaf = "1",
          eq = "1",
          maxhp = "5635",
          hp = "5452",
          nl = "79",
          maxmp = "7015",
          bleed = "31",
          bal = "0",
          string = "H:5452/5635 M:6675/7015 NL:79/100 ",
          blind = "1",
          mp = "6675"
        },

        Vitals = {
          maxmp = "7015",
          mp = "6755",
          string = "H:5441/5635 M:6755/7015 NL:79/100 ",
          maxhp = "5635",
          hp = "5441",
          nl = "79"
        },
    wit beyond measure is a Sidhe's greatest treasure
Sign In or Register to comment.