Please help me script (Mudlet edition)

DaraiusDaraius ShevatThe juror's taco spot
edited September 2015 in Mechanic's Corner
At the request of @Tarkenton and @Salome, here is how I approached the task of making a bashing timer and gold-per-minute calculator. My first instinct is to work with information that's visible to me, so this first draft only triggers on actual gold drops and pick-ups. It's limited and inefficient, but it gets the job done as long as the proper information appears on my screen. It begins by starting the hunt:

image

This starts the stopwatch, sets my picked-up gold this session at zero, and my starting gold at whatever total gold I have at the moment (for use by my failed script at the end of this post).

Then I look for gold to drop, and pick it up when I get balance (again, triggered by what I see, since I don't know how to work with gmcp directly yet - more on that in a minute).
image

image

Then finally, some math and displaying of info. It displays the stopwatch time (divided by 60 so it's in minutes, rather than seconds), and it divides the gold picked up in the session by the stopwatch time (multiplied by 60 so it's gold per minute, rather than gold per second). This is the part I'm mostly happy with, since it does what I expect and I understand it.

image

This seems to work for me, but only if all the information I need appears on my screen.

image

I know there's a better way with GMCP data. I feel like I should be able to track any change in my gold, even if it's received through influencing, or from bards and scholars, or from another player, or even an origami. Here's what I've got and how I expect it to work.

image
My expectation is that any time there's a change in gmcp.Char.Status gold, if it's higher than what I started the session with, it'll display the same information as my trigger above. Trouble is, I think I have a fundamental misunderstanding of how the Scripts section of Mudlet is supposed to work. Or else I really don't get functions. Am I anywhere close to the right track? What I'd love to hear is that I've got everything I need here in the deltaGold script, and I just need something... else, somewhere, to activate it and make sure it fires every time there's a change in my gold status. Also, I'm open to complete revisions of all this mess to make it into something more efficient.
I used to make cakes.

Estarra the Eternal says, "Give Shevat the floor please."

Comments

  • edited September 2015
    @Daraius For now, I've exactly done what you've done and so far all I can get it to do is take the gold. The data table itself isn't firing, so it's a puzzle! I'll get back to you, until then, I tinker away.

    Edit: Thanks to some small mistakes I fixed, it works. Other people @Aurik @Ssaliss are tinkering with it too. :)
    The apple is cold, crisp, and sour as the juices fill your mouth. As you consume the fruit, you glimpse, for a moment, a massive, shadowy figure, Her snow-white hair framing a perfect, icy-eyed visage. Beneath you, a vast, perfect web of silken strands lies - and, for a moment, you realize that you too are part of it, weaver and strand both - and home.
  • AeldraAeldra , using cake powered flight
    Hey,

    A two minor ideas for you:

    - Consider using avarice enchant to save yourself the trouble with the gold pickup triggers.
    - You can make triggers to fire on prompt by switching trigger type to 'lua function' and using 'return isPrompt()' as trigger. Thus, you
    can have it fire on every prompt and simply print something if the amount of gold has changed, meaning you save your amount of gold on 'hunton' and then just compare / update the gold variable everytime it changes on every prompt If that's confusing, let me know and I'll craft you an example tonight.

    Avatar / Picture done by the lovely Gurashi.
  • Aeldra said:
    Hey,

    A two minor ideas for you:

    - Consider using avarice enchant to save yourself the trouble with the gold pickup triggers.
    - You can make triggers to fire on prompt by switching trigger type to 'lua function' and using 'return isPrompt()' as trigger. Thus, you
    can have it fire on every prompt and simply print something if the amount of gold has changed, meaning you save your amount of gold on 'hunton' and then just compare / update the gold variable everytime it changes on every prompt If that's confusing, let me know and I'll craft you an example tonight.

    That's possible, but a fair bit more system intensive - only calling it when it actually needs calling would be better. Good to know though, thanks for chiming it in - I'm tinkering around with this myself, I might end up using that method if I can't get GMCP stuff working like I want.
    image
  • AeldraAeldra , using cake powered flight
    Yep, it's more system intensive, but having one prompt trigger will not kill you, especially if you are only doing a compare between a few numbers. There may be a gcmp event you can use that would be cheaper, but I can not check that from work.
    Avatar / Picture done by the lovely Gurashi.
  • edited September 2015
    If it works as you intended it to, then it's fine. You might not want to use 'stopStopWatch' until you finish, though. Otherwise your counter will stop the minute your gold changes. You should instead pause it, then unpause it after the cechos.

    Also, try not to use  if 'var == "true"' or 'var == "yes"' etc. Just do var = true, that way when checking you can just do;
       if goldhere then
          send("get gold",false)
       end

     ^better way than this to be honest, is to not use that trigger at all, and just use avarice to immediately pick the gold up. Then you can just track it all via scripts, and not have to use any triggers at all.


    edit, since posts happened while I was writing this: the event you use, is the exact one Dariaus has in his script. gmcp.Char.Status.gold - the script will fire whenever the number changes. If it increases, the echos happen, if it doesn't, then they don't.
    image
  • Aeldra said:
    Yep, it's more system intensive, but having one prompt trigger will not kill you, especially if you are only doing a compare between a few numbers. There may be a gcmp event you can use that would be cheaper, but I can not check that from work.
    Oh yeah - it's less 'this will not run well on most machines', more 'this is not best practice'.
    image
  • AeldraAeldra , using cake powered flight

    Syrennia said:


    edit, since posts happened while I was writing this: the event you use, is the exact one Dariaus has in his script. gmcp.Char.Status.gold - the script will fire whenever the number changes. If it increases, the echos happen, if it doesn't, then they don't.

    Oh, then I learned something to improve my own stuff as well. I didn't realize things like Status.Gold were real events.
    Avatar / Picture done by the lovely Gurashi.
  • edited September 2015
    Syrennia said:


    edit, since posts happened while I was writing this: the event you use, is the exact one Dariaus has in his script. gmcp.Char.Status.gold - the script will fire whenever the number changes. If it increases, the echos happen, if it doesn't, then they don't.
    I'm trying to make that work, and gmcp.Char.Status.gold doesn't fire - nor does gmcp.Char.Status. gmcp.Char.Items.Remove fires just fine though - but that fires on any item pickup, so I'd rather try to narrow it down if I can.

    Edit: And of course, right after posting that, gmcp.Char.Status.gold starts working. I guess I must've been capitalizing a G or something...

    Edit edit: Okay so, I hallucinated the first edit. gmcp.Char.Status.gold doesn't seem to fire - but I got gmcp.Char.Status to fire, so. Set that as the event handler, and it should work okay.

    Also, try using getStopWatchTime(huntWatch) instead of stopStopWatch(huntWatch) - don't know if it works any better but
    image
  • edited September 2015
    Okay, so I think I have it mostly working. Here it is, in case people want to play around with it/want it for themselves.


    image
  • AeldraAeldra , using cake powered flight
    Aurik said:
    Okay, so I think I have it mostly working. Here it is, in case people want to play around with it/want it for themselves.


    Thank you for sharing! :-)
    Avatar / Picture done by the lovely Gurashi.
  • http://puu.sh/jYpoI/d5d4f86e1a.png

    And just a little shot of how I've modified it for my own setup - I like having things listed neatly off to one side. :3

    (I can share this as well if people want it - but I know some people are fussy about GUIs)
    image
  • DaraiusDaraius Shevat The juror's taco spot
    edited September 2015
    Thanks for all the input. I didn't know avarice enchantment was even a thing, so I learned something new about the game and scripting today! Using gmcp.Char.Status instead of gmcp.Char.Status.gold seems to have done the trick. It fires when I read news, but whatever, it still does exactly what I want it to do. Next step will be to fold in essence tracking, and maybe even try to make a mini-console!

    And if that results in catastrophic failure, well... then I just steal @Aurik's.  ;))
    I used to make cakes.

    Estarra the Eternal says, "Give Shevat the floor please."
  • DaraiusDaraius Shevat The juror's taco spot
    edited September 2015
    P.S. Any idea why setting gmcp.Char.Status.gold as the event handler doesn't function as expected?
    I used to make cakes.

    Estarra the Eternal says, "Give Shevat the floor please."
  • Wild guess since I don't use Mudlet: The event that comes from Lusternia is Char.Status (which gets translated to gmcp.Char.Status by Mudlet). "gold" is a field in that message.
    image
  • Basically what Ssaliss said. There's no 'gold' event, only a Status event that alters 'gold'.

    I have everything tucked behind if statements, so even if it fires on things I don't want it firing on, I don't see it and it doesn't really affect anything.

    Essence tracking is going to be tricky - gmcp.Char.Vitals fires on every prompt, so you'll need something to check whether you actually gained essence or not, unless you really like a four line prompt that is. I got around it by adding a 'essenceSinceLastCheck' variable - if I have more essence than that at a check, then it fires, and sets essenceSinceLastCheck to my new essence total. Did the same for esteem.

    For a miniconsole - I can shoot you what I have, if you have trouble with it. I have mine working mostly the way I want now - I'll probably end up tweaking it, but that's just because I'm an eternal tinkerer xP
    image
Sign In or Register to comment.