Mudlet Help Desk

OsmondOsmond Member Posts: 141 ✭✭✭
Not a lot of people used it in the last forums, but I am bringing this back.  So I am trying to create some buttons to toggle fucntions, so I am using geyser labels.  I can make the button and all that just fine, but I am having trouble with the setClickCallback function.  Here is what I am using


testlabel = Geyser.Label:new({

name = "testlabel",

x = "1", y = 691,

width = "85", height = "25",

fgColor = "DodgerBlue",

color = "navy",

message = [[<center>Precache</center>]]

})

setClickCallback("precache_off")


function precache_off()

if osmosis.precache then

send("i_off precache")

else

send("i_on precache")

end


This isn't working, anyone have any ideas?



image
«13456789

Comments

  • DhraenDhraen UKMember Posts: 59 ✭✭
    Pass it as a method rather than how you are attempting to use it. i.e.

    [code]testlabel:setClickCallbac("precache_off")[/code]
    Systems and scripting support: support@pharanyx.com
    Advanced HTML logging: http://www.logsty.net
    Anything else? http://www.google.com
  • DhraenDhraen UKMember Posts: 59 ✭✭
    Silly forums, but you get the idea.
    Systems and scripting support: support@pharanyx.com
    Advanced HTML logging: http://www.logsty.net
    Anything else? http://www.google.com
  • OsmondOsmond Member Posts: 141 ✭✭✭
    So another (of many) question: How would I go about displaying the contents of a variable?
    image
  • DhraenDhraen UKMember Posts: 59 ✭✭
    echo(var)?


    Systems and scripting support: support@pharanyx.com
    Advanced HTML logging: http://www.logsty.net
    Anything else? http://www.google.com
    Sykar
  • SykarSykar A holeMember Posts: 7
    edited March 2013
    I'm a bit late, but there are a few ways to display a variable. The most common method is to use "echo()". Another way to do it, if you have a table that you're trying to display is "display()". You can also use "return var" and it'll return your value via function:

    testvar = "yep"

    function test()
      return testvar
    end

    echo(test())

    will show "yep"


    Just added for some variety.
  • OsmondOsmond Member Posts: 141 ✭✭✭
    edited March 2013
    Fixed the last issue, so editing for this next frustrating part.  I have everything together but of course it isn't working.  This pastebin has all the scripts and triggers involved in this little project, if anyone cares to give it a look for me.

    http://pastebin.com/9J4AQjJL
    Post edited by Osmond on
    image
  • TzaTza Member Posts: 126 ✭✭✭
    edited March 2013
    Osmond said:
    Fixed the last issue, so editing for this next frustrating part.  I have everything together but of course it isn't working.  This pastebin has all the scripts and triggers involved in this little project, if anyone cares to give it a look for me.

    http://pastebin.com/9J4AQjJL
    I really have no idea about your Gauges there, however there's one thing I noticed:

    You're calling your addDamage function with string input, a la: addDamage(matches[4], matches[2])

    However, in your script you have (for example):

    1.         if severity == light then
    2.                 if limb == head then
    3.                         osmosis.limbdamage.head = osmosis.limbdamage.head + 1
    4.                 elseif limb == torso then
    5.                         osmosis.limbdamage.torso = osmosis.limbdamage.torso + 1


    I'm assuming that the variable 'severity' can take the values of "light", "moderate" or "critical". But to compare it like this you would have to write severity == "light" and not severity == light. If you write 'light' without apostrophes the client is going to assume it's variable but since such a variable doesn't exist, it'll throw an error complaining about a nil value. If you want to compare a string you always need apostrophes around the string.

    I also find it weird that your create_left_arm_<colour>() functions -create- labels each time they're called. Wouldn't it be enough to initialize the gauges once (as in create them) and afterwards in any subsequent calls only change the colour, text etc to whatever you need? The way I'm reading this you actually just need -one- gauge, but one that changes colour. To do this you are currently always creating new gauges atop the old one... I think a change_colour_<limb>(<colour>) function would help there. (Unless I'm completely wrong about what you're trying to do.)

    (EDIT: If formatting wasn't utterly ridiculous in this editor, I'd remove the black highlight. As it is, setting it to black is the best I can do as I cannot remove it without reading through some seriously ridiculous source.)
    Dhraen
  • OsmondOsmond Member Posts: 141 ✭✭✭
    Its not returning a nil value, I have a separate script to initialize variables, it initializes osmosis and osmosis.limbdamage, I know that is kind of weird, but it helps me keep track of things when they are all in one script instead of initialiing a variable in the function it is used in.  I'm not getting any errors actually, just nothing is happening when I slam the left arm.  

    With the whole creating a new gauge each time, its the only way I could figure out how to change the color, I was originally trying to create the function to take a color arguement , but it didn't work and after hours if looking through documentation I gave up and just went the route I did.
    image
  • TzaTza Member Posts: 126 ✭✭✭
    @Osmond: I don't mean the osmosis.limbdamage but the head and torso stuff.

    So instead of:

    if limb == head then

    it should be:

    if limb == "head" then

    Same for torso. You already wrote "left arm" and "right arm" with apostrophes after all.

    No clue about your gauges though :( Debugging can be a biatch. Try using the error and debug tool in Mudlet. Try using echos to see if your if-then condition matches or not and to figure out on which line the error is. Check if your gauge creation stuff is correct at all by (for example) using an alias to just create a gauge once and see if it shows up correctly etc. Best I can think of, sorry. ;)
  • OsmondOsmond Member Posts: 141 ✭✭✭
    So, new issue, and yes, more GUI type stuff! :D

    I am having issues with my buttons randomly moving south a bit.  It looks like they are moving down my screen almost exactly the height of the buttons themselves.  Not sure exactly why this is, here is what I am using for each button:


    function call_herb()


    herbcontrol = Geyser.Label:new({

    name = "herbcontrol",

    x = 1117, y = 750,

    width = "60px", height = "30px",

    fgColor = "black",

    color = osmosis.citadel.controls.herb,

    message = [[<center>Herbs</center>]]

    })

    herbcontrol:setClickCallback("herb_toggle")


    end

    call_herb()


    I then have a function of course that actually checks for the circumstances in toggling said button.  I can't figure out why they keep moving on me though.


    image
  • DhraenDhraen UKMember Posts: 59 ✭✭
    You should really be using containers for this.
    Systems and scripting support: support@pharanyx.com
    Advanced HTML logging: http://www.logsty.net
    Anything else? http://www.google.com
  • MissariMissari Member Posts: 208 ✭✭✭
    Here's one that's been stumpifying me for about an hour now.

    In cMUD you can trigger variables e.g. 
    ^You drive .+ into @target[a-z]* with a quick thrust\.$

    In mudlet you...? Halp plox ;-;
  • MissariMissari Member Posts: 208 ✭✭✭
    http://pastebin.com/NpgTDjFk

    This is driving me nutsoid, too. ;-;
  • KaeusKaeus Member Posts: 209 ✭✭✭
    Missari said:
    http://pastebin.com/NpgTDjFk

    This is driving me nutsoid, too. ;-;
    Why not just do something like this:

    The envenoming message shows you the variables you are storing from your alias, why not just use the captures from the trigger instead.
  • MissariMissari Member Posts: 208 ✭✭✭
    edited May 2013
    That helps with envenoming, but empowering isn't as nice.

    e.g. 
    ^Focusing your mind, you utter a quiet prayer and imbue .+ with (\w+)\.$

    Notice the lack of which hand I empowered.

    Also it's
    table.insert(_G["wvenom_" .. matches[3]], 1, matches[2]) >_>
  • KaeusKaeus Member Posts: 209 ✭✭✭
    Missari said:
    That helps with envenoming, but empowering isn't as nice.

    e.g. 
    ^Focusing your mind, you utter a quiet prayer and imbue .+ with (\w+)\.$

    Notice the lack of which hand I empowered.

    Also it's
    table.insert(_G["wvenom_" .. matches[3]], 1, matches[2]) >_>
    I haven't had to bother putting empowerments the same way as venoms since it has a different message when it gets applied anyway. Beyond that, I wipe my weapons before I envenom, so I don't really need to worry about order.
  • MissariMissari Member Posts: 208 ✭✭✭
    I got it figured. If anyone is curious just let me know. :D

    Thanks for putting up with my cranky/newbish unicorns.
  • MissariMissari Member Posts: 208 ✭✭✭
    edited May 2013
    Alright, for reals. I've been trying since I started using mudlet to gag double prompts. Someone please enlighten me.

    for anyone who's not sure what I mean by "double prompt" see below

    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
    H:5720/5720 M:6050/6050 E:100% W:100% B:100%  eb lr 
  • TozToz Member Posts: 2,143 ✭✭✭✭✭
    Usually that means you have something gagged, and the prompt that comes after it is still showing. I work around this by adding a simple gagPrompt variable to everything I gag - if I gag lighting my pipes, for instance, gagPrompt = 1. Then I have a trigger that checks to see on every prompt if it should gag it. If so, it gags the prompt with deleteLine and sets gagPrompt to 0.
    (Oasis): Azzello says, "I'll still never forget the first time I saw Toz throwing hammers."
    (Oasis): Azzello says, "I freaked out and thought they had somehow managed to pull me into them."
    (Oasis): Azzello says, "So I tumbled away from my team and into theirs."


    Missari
  • MissariMissari Member Posts: 208 ✭✭✭
    Dear sweet baby white Jesus THANK YOU.


    (If anyone has any other ideas I will eat them up with just as many praises.)
  • DhraenDhraen UKMember Posts: 59 ✭✭
    edited May 2013

    function keepalive()

      sendGMCP("Core.KeepAlive")

      if keepalive then

        killTimer(keepalive)

      end


      keepalive = tempTimer(60, [[keepalive()]])

    end


    keepalive()


    And your gagging function:


    function gaglp()

      deleteLine()

      tempLineTrigger(1, 1, [[

        if isPrompt() then deleteLine() end

      ]])

    end

    Systems and scripting support: support@pharanyx.com
    Advanced HTML logging: http://www.logsty.net
    Anything else? http://www.google.com
    Missari
  • LinLin SMASHER/DEVOURER MASCHINEKLASTMember Posts: 1,556 mod
    Issue with your function, Dhraen: you're creating a timer object with the same name as your function object, so it's going to be overwritten. Suggest just renaming the function something like "doKeepAlive()", etc.
  • TaurnilTaurnil Member Posts: 3
    I'm trying to make my own curing system and I'm using the and I am using CONFIG AFFLICTION_VIEW FULL to get the lines for what I've been afflicted with, my problem is that I can't figure out how to use the GMCP and was wondering if someone would mind helping me figure out how to use it so that I can use it to actually work with my system.
  • YusriYusri Member Posts: 73 ✭✭✭
    GMCP in Mudlet is easy peasy. You just need to go to Settings (the wrench icon), then General. There's a checkbox down under 'GMCP' which reads 'Enable GMCP'. Check it, close Mudlet, open Mudlet, and log in. GMCP data is stored in a table called 'gmcp' and updates every prompt (for the most part). If you make an alias to do 'display(gmcp)' you'll see the contents of the table. Some fun subtables are gmcp.Char.Vitals and gmcp.Room.Info.
    image
  • TaurnilTaurnil Member Posts: 3
    Hrm... and how would I go about making it so that using gmcp I can make an auto-sipper? I mean, I get the over all just of what you are saying, it does make sense when explained like that, problem is I have no idea how to actually use it so that I can incorporate it into a system to make the system viable. If you care to explain more can you send me a message so that I can act all newbie like and not feel like a complete idiot?
  • YusriYusri Member Posts: 73 ✭✭✭
    Not an idiot! Everyone starts somewhere, asking questions is the best way to learn stuff.

    The upshot of GMCP is that every prompt, without the need for triggers, you have a whole mess of character data sitting in a table ready for use. Example. It's all stored in a standard Lua table that can be accessed/manipulated like every other Lua variable - there's lots of good reading on how to do this on the Internet, if you're unfamiliar. Just Google 'lua table' or 'lua tutorial'.

    So, here's an autosipper that you could put in your prompt that uses GMCP. checkLimiter() and resetLimiter() are just functions that check if we've already tried to sip/eat in the past fraction of a second, so we don't send two sip/eat commands at once.

    It's a bit more complex than it strictly needs to be so you can see some of the features of GMCP. You would put this in a prompt trigger, or a GMCP event (I can explain those if you like - they're kind of like triggers that fire on GMCP updates rather than lines of text) and your sipper would be done. 
    image
    MastemaLinLianca
  • TaurnilTaurnil Member Posts: 3
    Yusri, you are doing a wonderful job explaining this to me, I really appreciate you taking time to explain it, and yes, if you don't mind I would like to know about GMCP event, this way I can try and get things running better in this system I'm making.
    YusriAlice
  • YusriYusri Member Posts: 73 ✭✭✭
    No worries, mate. I like talking about this because it makes me feel useful. <_<

    GMCP events are fairly straightforward - events in general are a bit trickier and I haven't messed around with any player-created ones, so I'll leave that for someone else.

    Basically, you make a script (click the Scripts button on your menu bar, then click Add Item). It needs to contain a function and an event handler, and the script file needs to be named the same as the function. So if your function is called onVitalUpdate, your script needs to be called onVitalUpdate. I don't know why this is, it's just a thing I discovered back when I was learning Mudlet. This function will be called whenever your event handler is called.

    In the box labelled 'Add User Defined Event Handler', you need to write the exact table name of the GMCP data that you would like to cause the event to fire. So, if you're writing a function that you want to fire every time you get new character vital data, like HP, balances, all that, you would write 'gmcp.Char.Vitals' into the 'Add User Defined Event Handler' box, and click the plus button. It should pop up in the Registered Event Handler box. Here's a screenshot to show you how it should end up looking:

    image


    So, to recap:
    • Create a script.
    • Add an event handler using the Add User Defined Event Handler box. The handler is the name of the table that, when updated, will call this event.
    • Add a function to the script containing all the code you want to fire when this event occurs.
    • Make sure the script name is the same as the function name.
    Apologies if any of this is unclear, I'll be happy to clarify if it is.
    image
    LinLianca
  • YusriYusri Member Posts: 73 ✭✭✭
    edited May 2013
    Additional notes: You can just throw sendGMCP("Core.KeepAlive") into a global timer set to 60 seconds and you're done. No need for other functions.

    You can also get rid of double prompts and minimize spam by putting the following into your prompt trigger. Basically it will only show your prompt if it's not identical to the previous prompt.

    if lastprompt == line then deleteLine() end
    lastprompt = line

    image
    LinVolka
  • SetneSetne The Grand Tyrant Member Posts: 835 ✭✭✭✭✭
    Yusri said:
    I haven't messed around with any player-created ones
    Player created events are used basically like gmcp ones, but instead of the game raising/sending them, a script/system would with the raiseEvent() function, e,g: raiseEvent("murder enemies") or even raiseEvent("murder enemies", enemy1, enemy2, etc) 
    Also, when making prompt triggers, one awesome thing you can do is instead of having to make a regex pattern or multiple regex patterns for various prompt variations, you can simply use the function isPrompt() 
    example
    return isPrompt() with the pattern type as a lua function
    This will catch any and all prompt variations, though you'd still have to use regex(be it another pattern or code) to pull data from the line if you can't get it elsewhere, like from gmcp.
    Love gaming? Love gaming stuff? Sign up for Lootcrate and get awesome gaming items. Accompanying video.

    Ingram said:
    "Oh my arms are suddenly lubed"
    YusriLin
Sign In or Register to comment.