Small Coding Questions

12346»

Comments

  • AldricAldric Member Posts: 790 ✭✭✭✭✭
    edited January 2015
    I'm not sure how many people use mudbot any more, but we've got some great coders, so it's worth a shot!

    I want mudbot to echo a line 'You have reached your destination" when I hit the room I pathed to, just like the IG path finding system does for trigger purposes. I can't imagine it'd be too terribly difficult since mudbot already has the `echo functionality, but I haven't the slightest idea which file to be playing with, or where I'd be tweaking what.

    Any advice?

    EDIT: Looking at the files in Notepadd++ is just... wow. I don't want to touch anything I'm not 100% sure of.


    Post edited by Aldric on
    image
    Feelings, sensations that you thought were dead. No squealin' remember, that it's all in your head.
  • MaelMael Member Posts: 47 ✭✭
    @Aldric I haven't really gone into mudbot too much, but what you're looking at is a DLL file, it's encoded, and any modifications that are made to it will likely break it. I think you'll likely want to work in main.c.
  • NalorNalor UKMember Posts: 774 ✭✭✭
    You have to go into Xons C files which he has in the same thread I believe and edit them and encode them etc.

    You cant really edit the mudbot files only 1 or two, Imap and config..

    Also. WHy not just make a trigger in ya system? Much easier no?

    (Done.) == is normally the line you can trigger off..
    Mudlet Bashing System for sale. Message if interested
  • AldricAldric Member Posts: 790 ✭✭✭✭✭
    I... somehow missed the (Done.) line. Thanks for that! Problem solved!
    image
    Feelings, sensations that you thought were dead. No squealin' remember, that it's all in your head.
  • NalorNalor UKMember Posts: 774 ✭✭✭
    Aldric said:

    I... somehow missed the (Done.) line. Thanks for that! Problem solved!

    @Aldric its your best friend :P I use it for many things.. including looking for foci
    Mudlet Bashing System for sale. Message if interested
  • ReuxReux Member Posts: 251 ✭✭✭
    edited August 2015
    From an earlier question, I have a better one now.

    How can I tell any particular way of handling a task is faster than another way? For example, from a MUSHclient script I'd use for picking apart Char.Vitals from GMCP:

    REXParseV = rex.new ("Char\.Vitals \{ \"hp\"\: \"([0-9]+)\"\, \"maxhp\"\: \"([0-9]+)\"\, \"mp\"\: \"([0-9]+)\"\, \"maxmp\"\: \"([0-9]+)\"\, \"ep\"\: \"([0-9]+)\"\, \"maxep\"\: \"([0-9]+)\"\, \"wp\"\: \"([0-9]+)\"\, \"maxwp\"\: \"([0-9]+)\"\, \"nl\"\: \"[0-9]+\"\, \"xp\"\: \"([0-9]+)\"\, \"maxxp\"\: \"([0-9]+)\"\, \"blood\"\: \"([0-9]+)\"\, \"bleeding\"\: \"([0-9]+)\"\, \"blind\"\: \"(0|1)\"\, \"deaf\"\: \"(0|1)\"\, \"prone\"\: \"(0|1)\"\, \"cloak\"\: \"(0|1)\"\, \"fangbarrier\"\: \"(0|1)\"\, \"flying\"\: \"(?:0|1)\"\, \"herb\"\: \"(0|1)\"\, \"salve\"\: \"(0|1)\"\, \"pipe\"\: \"(0|1)\"\, \"elixir\"\: \"(0|1)\"\, \"moss\"\: \"(0|1)\"\, \"tree\"\: \"(0|1)\"\, \"renew\"\: \"(0|1)\"\, \"affelixir\"\: \"(0|1)\"\, \"focus\"\: \"(0|1)\"\, (\"writhing\"\: \"1\"\, )?(\"fallen\"\: \"1\"\, )?(\"lying\"\: \"1\"\, )?(\"sitting\"\: \"1\"\, )?\"soul\"\: \"([0-9]+)\"\, \"residual\"\: \"[0-9]+\", \"madness\"\: \"([0-9]+)\"\, \"mutated\"\: \"[A-Za-z]+\"\, \"status\"\: \"[A-Za-z]+\"\, \"balance\"\: \"(0|1)\"\, \"equilibrium\"\: \"(0|1)\"\, \"ability\_bal\"\: \"(0|1)\"\, \"left_arm\"\: \"(0|1)\"\, \"right_arm\"\: \"(0|1)\"\, \"wield_left\"\: \"([A-Za-z0-9 ]*)\"\, \"wield_right\"\: \"([A-Za-z0-9 ]*)\"\, \"class\"\: \"([A-Za-z]+)\"\, \"mounted\"\: \"([0-9]+)\"\, \"voted\"\: \"(0|1)\", \"burrowed\"\: \"[a-z]+\"\, \"string\"\: \"H\:[0-9]+\/[0-9]+ M\:[0-9]+\/[0-9]+ E\:[0-9]+\/[0-9]+ W\:[0-9]+\/[0-9]+ NL\:[0-9]+\/100 \"\, \"charstats\"\: . \"Level\: ([0-9]+)\"", rex.flags().ANCHORED) PI = 'Char.Vitals { "hp": "7312", "maxhp": "6072", "mp": "7238", "maxmp": "4756", "ep": "28319", "maxep": "27900", "wp": "22066", "maxwp": "21900", "nl": "12", "xp": "2557065", "maxxp": "21072033", "blood": "100", "bleeding": "0", "blind": "0", "deaf": "0", "prone": "0", "cloak": "0", "fangbarrier": "0", "flying": "0", "herb": "1", "salve": "1", "pipe": "1", "elixir": "1", "moss": "1", "tree": "1", "renew": "1", "affelixir": "1", "focus": "1", "soul": "100", "residual": "100", "madness": "32", "mutated": "Werecroc", "status": "vampire", "balance": "1", "equilibrium": "1", "ability_bal": "1", "left_arm": "1", "right_arm": "1", "wield_left": "", "wield_right": "", "class": "shapeshifter", "mounted": "0", "voted": "0", "burrowed": "no", "string": "H:7312/6072 M:7238/4756 E:28319/27900 W:22066/21900 NL:12/100 ", "charstats": [ "Level: 137" ] }' s, e, t = REXParseV:match (PI)

    How do I know this is faster than running a string.gmatch ".-": ".-" on that same PI? Or a gmatch a similar, short rex.new?
    I mean, you know, an amount.


  • TrigruTrigru the Bumberton's DelightMember Posts: 255 ✭✭✭✭
    I don't know how MUSH does things, but the way I would test script efficiency was with this method:
    local t = os.clock()
    doRelevantCodeHere()
    echo("Time elapsed: " .. os.clock() - t)
    From there, it's a simple procedure of seeing which method takes the least time.
    image
  • OleisOleis Producer Emeritus Member, Administrator, Immortal Posts: 1,393 admin
    edited August 2015
    This is a shame for one main reason -- JSON is a format designed specifically to deliver information in an accessible and human-readable way. Matching it as regex sets you up for your GMCP parsing to break any time we add, remove, or even change the order of GMCP entities.

    If I could recommend an alternative, look at a library for converting JSON into native Lua tables, similar to what Mudlet does with its gmcp. table. Snipped to defer to Keroc's awesome reply below.
    Post edited by Oleis on
    You say to Slyphe, "You're so freaking smart."
    [---]
    "^," Slyphe agrees with you.
  • ReuxReux Member Posts: 251 ✭✭✭
    edited August 2015
    Thank you Trigru; already set up something. Replace os.clock() with GetInfo(232)
    Oleis said:

    This is a shame for one main reason -- JSON is a format designed specifically to deliver information in an accessible and human-readable way. Matching it as regex sets you up for your GMCP parsing to break any time we add, remove, or even change the order of GMCP entities.

    If I could recommend an alternative, look at a library for converting JSON into native Lua tables, similar to what Mudlet does with its gmcp. table. I have a link for a library I haven't used personally, to start your journey: http://regex.info/blog/lua/json

    I'll look into it and test it for efficiency against a gmatch.
    I mean, you know, an amount.


  • KerocKeroc A small cupboardMember, Administrator, Immortal Posts: 364 admin
    Just to touch on Oleis' reply, MUSHclient comes with a distrubuted JSON package that you can easily load into your code without much of a hassle. You can find it in the lua/ subdirectory of your install path called json.lua. Then all you need to do is load the package using 'require' and use accordingly.

    If you want to trim the fat you can even just load the decoder module and skip the rest as the encoder/whatever else probably isn't very useful for you.

    Trigru
  • ReuxReux Member Posts: 251 ✭✭✭
    Keroc said:

    Just to touch on Oleis' reply, MUSHclient comes with a distrubuted JSON package that you can easily load into your code without much of a hassle. You can find it in the lua/ subdirectory of your install path called json.lua. Then all you need to do is load the package using 'require' and use accordingly.

    If you want to trim the fat you can even just load the decoder module and skip the rest as the encoder/whatever else probably isn't very useful for you.

    I gotta figure out JSON first, because the linked page and file makes no sense to me. I don't know Java or JScript. Having one less thing to download would be nice, and I'll learn around what MUSH distributes. Thank you Keroc.

    The original addon that was distributed somewhere around here for GMCP use in MUSH used JSON, and I made a whole new addon just to avoid learning all the language the original author utilized; I can't edit what I don't understand, and it wasn't doing things I needed it to do.
    I mean, you know, an amount.


  • RiluoRiluo The DoctorMember Posts: 821 ✭✭✭✭
    setBackgroundColor("WhoHere",0,0,0,0)

    anyone know how to convert this from a black box on a screen into a transparent one or something as it is blocking a section of my screen and UI stuff is new to me.

    Abhorash says, "Ve'kahi has proved that even bastards can earn their place."

  • OlliOlli Member Posts: 3
    The parameters are r, g, b, transparency - 0 being fully transparent and 0,0,0 being the color black. You'd probably be better off moving using moveWindow("WhoHere",xCoordinate,yCoordinate). There may be a function to set your foreground's transparency - I couldn't find it, but I imagine it's available through setStyleSheet.
  • AngweAngwe I'm the dog that ate yr birthday cake Bedford, VAMember Posts: 978 ✭✭✭✭✭
    Hey, so. I'm about to undergo the dubious task of updating Tripwire. Which will mostly involve gutting Tripwire, I imagine. I like Tripwire's GUI, and I think I can update the tracking to work with the new information the discernment line gives you. Maybe? I don't know, I haven't the first idea of how to code anything at all.

    But I digress.

    Could anyone give me a clue on what I should maybe not delete before I just go on a spree? All the coding clans in-game seem to be dead.
    image
  • NalorNalor UKMember Posts: 774 ✭✭✭
    edited August 2015
    No the coding clans aint dead, was ignoring the question about Tripwire personally as someone already gutted it out and reposted it as .. Hmm don't remember the name PS or something.

    I would say go through the scripts and some scripts you shouldn't delete as its how it cures.. but best idea is to make sure to keep backups and not just save profile REAL backups. SAVE PROFILE AS - name it like backup(date)(time) as sometimes the rollback doesn't work right.


    found system which was tripwire til someone thought he wanted to sell it then realised people give it out for free -

    http://forums.aetolia.com/discussion/1915/project-source-support-version-1-1-update-6-june#latest
    Mudlet Bashing System for sale. Message if interested
  • AngweAngwe I'm the dog that ate yr birthday cake Bedford, VAMember Posts: 978 ✭✭✭✭✭
    I figured I could just do away with most of the curing, right? Firstaid is pretty robust these days, right? These are real questions, I honestly don't know anymore.

    It has pre-resto now, I've heard. Is there anything that Firstaid doesn't cover?
    image
  • NalorNalor UKMember Posts: 774 ✭✭✭
    then why not just rip out the UI?? it'll be much easier
    Mudlet Bashing System for sale. Message if interested
  • AngweAngwe I'm the dog that ate yr birthday cake Bedford, VAMember Posts: 978 ✭✭✭✭✭
    edited August 2015
    I don't know how.

    Edit: Trial and error, I guess, like everyone else. Alright! Thanks, I'll just try that.
    image
  • ReuxReux Member Posts: 251 ✭✭✭
    edited August 2015
    Focus isn't handled.

    I'd also say that how first aid handles curing bleed is inefficient,  UT that isn't hard to turn off and code curing yourself.
    I mean, you know, an amount.


  • EldreshEldresh Member Posts: 5
    So, using the web client (the one at http://client.aetolia.com/ ), there is a built in targeting system that lets you choose a target using the tab key. You can call the variable it sets with @tar in various aliases and the like. I would like to also be able to set this variable manually, rather than using the tab key. Am I just out of luck?

    Using @set tar does nothing other than create a new variable named tar with that value that using @tar doesn't work with.
  • DristinDristin Member Posts: 585 Immortal
    edited September 2015
    Eldresh said:

    So, using the web client (the one at http://client.aetolia.com/ ), there is a built in targeting system that lets you choose a target using the tab key. You can call the variable it sets with @tar in various aliases and the like. I would like to also be able to set this variable manually, rather than using the tab key. Am I just out of luck?

    Using @set tar does nothing other than create a new variable named tar with that value that using @tar doesn't work with.

    Have you tried --> settarget tar -target-?
    image
  • EldreshEldresh Member Posts: 5
    Dristin said:

    Eldresh said:

    So, using the web client (the one at http://client.aetolia.com/ ), there is a built in targeting system that lets you choose a target using the tab key. You can call the variable it sets with @tar in various aliases and the like. I would like to also be able to set this variable manually, rather than using the tab key. Am I just out of luck?

    Using @set tar does nothing other than create a new variable named tar with that value that using @tar doesn't work with.

    Have you tried --> settarget tar -target-?
    That sets a target in Aetolia itself, the web client's targetting system is completely separate from that.
  • DristinDristin Member Posts: 585 Immortal
    Eldresh said:

    Dristin said:

    Eldresh said:

    So, using the web client (the one at http://client.aetolia.com/ ), there is a built in targeting system that lets you choose a target using the tab key. You can call the variable it sets with @tar in various aliases and the like. I would like to also be able to set this variable manually, rather than using the tab key. Am I just out of luck?

    Using @set tar does nothing other than create a new variable named tar with that value that using @tar doesn't work with.

    Have you tried --> settarget tar -target-?
    That sets a target in Aetolia itself, the web client's targetting system is completely separate from that.
    I wasn't sure. Sorry!
    image
  • EldreshEldresh Member Posts: 5
    Eldresh said:

    So, using the web client (the one at http://client.aetolia.com/ ), there is a built in targeting system that lets you choose a target using the tab key. You can call the variable it sets with @tar in various aliases and the like. I would like to also be able to set this variable manually, rather than using the tab key. Am I just out of luck?

    Using @set tar does nothing other than create a new variable named tar with that value that using @tar doesn't work with.

    - @tar is now a real variable and can be changed

    I'm trying to figure out how to do this in the client and can't get it to work. Using @set tar still doesn't seem to work, it is creating a new variable named tar and giving it the value rather than setting the target variable.
  • SivekuiSivekui Member Posts: 77 ✭✭
    edited January 2016
    So, With the new WHO it seems to be messing up with my system code..

    I have

    ^\s+(\w+) \- (.+)(\s+)? \- ((\w+)?|?)$

    and

    ^\s+(\w+) \- (.+)\s+ \- ((\w+)?|?)$

    which is giving me

    ["Seaward stretch of Temple Circle 'blank spaces' "] = {
    "Rasani"
    },
    ["The Portals of Bloodloch 'blank spaces' "] = {
    "Infin"
    },
    ["The Portals of Enorian 'blank spaces' "] = {
    "Qaixheor"
    },

    the 'blank spaces' are ALOT of blank spaces but somehow it doesn't show after I click post.

    Anyone know a better code so it doesn't also track the big blank spaces? It's driving me nuts
    MayhemHunting - Discord Chat - CLANHELP MAY (ingame)

  • KerocKeroc A small cupboardMember, Administrator, Immortal Posts: 364 admin
    edited January 2016
    I would probably run...

    ^\s+([\w]+) \- (.+) \- v?([0-9]*)$

    Then run the second wildcard through a white space trim command.

    Cursory google search points me at :match( "(.-)%s*$" ) for trimming trailing white space.
    Post edited by Keroc on

    Riluo
  • SivekuiSivekui Member Posts: 77 ✭✭
    Thanks @Keroc I just added the trimming to my matches[3] and it works a dream!

    MayhemHunting - Discord Chat - CLANHELP MAY (ingame)

  • TrikalTrikal Member Posts: 129 ✭✭✭
    I use non-greedy matching

    ^\s+(\w+) \- (.+?)\s+\-\s*(v\d+)?

    The ? after .+ makes it match as little as possible before the rest of the trigger can match. Basically it trims the trailing whitespace for you. You can change the end of the regex matching so that it will only have the ##### in the matches instead of v####
    Riluo
  • SivekuiSivekui Member Posts: 77 ✭✭
    I stayed with my own triggger and just used matches[3]:match( "(.-)%s*$" ) ..

    I should have looked in my Mudbot who settings to find it but it was driving me nuts and thinking was going out the window ..
    MayhemHunting - Discord Chat - CLANHELP MAY (ingame)

  • CordiaCordia Member Posts: 39 ✭✭✭
    Hello people! The main channel for this Discord was started as a combat voice coordination spot for the shadow side. However, it's become quite a bit more than just that now. Recently, we updated one of the channels to be specifically for coding discussion. So, I wanted to offer people a link to join it if they want to:

    https://discord.gg/BThuH
12346»
Sign In or Register to comment.