It's possible for tables - as mentioned by Keneanung - but you'll quickly run into the issue that a lot of script authors for Achaea don't understand tables, and therefore don't use namespacing (the original version of Wundersys had this problem). If the check failed, the pattern failed and the trigger didn't execute its Monitoring Lua variables directly isn't possible. Just in that case the check being run on every line of output was "Is this line a prompt?" If the check succeeded, the pattern passed and the trigger executed its code.
Huh, does this trigger setup fire without the need to fire off prompt? I’ve never seen code done like that.Technically you have, since every prompt trigger prior to Mudlet 3.6 (and the addition of the separate "prompt" trigger type) used the Lua function type. I've tried various connotations of 'return testvar', such asĪlso, my testing has been with a single pattern, forgetting the OR part - figured I should get a single one working first. If I can get the above to work, then I can use more complex expressions as well, and easily monitor how/what these other scripts are doing. The actual script will set the CSS of a label, giving me a toggle style button that displays some information, without requiring me to delve into someone else's code (say I am using wsys, svof or trex - at the moment I am leaning more toward wsys for its simplicity). this is an OR type trigger)Script:echo(tostring(testvar))
Pattern 1, lua func type: return testvarPattern 2, lua func type: return not testvarTrig options: default (i.e. True/False, running the triggers script when there is a change in the value.
The mudlet manual is pretty vague when it discusses them. I'm not sure what you mean by "masive crashes", so you may try to adjust the timeout=X value (up or down) in the code above to try to get rid of those crashes.It's been too long since I used these, and I can't get them to work beyond just the basics, and I can't find any of my old scripts that did it. Loop:iteration() - NOTE: instead of your "client:_ioloop_iteration()" call Here is a better code example: local loop = require("mqtt.ioloop").get(true, ) - NOTE: you can try to adjust this timeout value In this case, the best option will be to implement a "connector" based on that sockets: įinally, if you have only timers - your way is also can work. It's possible that it has its own sockets implementation. The other way is to use the networking capabilities of your Mudlet Lua environment. So the entire CPU time of the separate thread will be used for network communication. I'm not familiar with the Mudlet Lua environment, but if you can run a separate OS thread with the "n_ioloop(client)" call in this - this can be the best option. The ioloop and its ":run_until_clients()" method (or "n_ioloop(client)" wrapper) is the right thing to do that.
To make the MQTT connection work, something in your code should periodically pull packets from the server and monitor a connection state. I guess my question is: Am i doing it wrong? Can i run the ioloop wihtout it crashing the main thread? Or if i need to run the ioloop manually, is this the correct way to do it, by manually calling _ioloop_iteration() at a fixed interval? Or is there a better way, calling some method that will check the inbound queue, fire the callbacks then exit without looping? I did try to run the client:_ioloop_iteration() at 100ms instead, but then i had masive crashes again. I would have preferred to run it faster though, as the client is "sluggish" when receiving external messages (understandably) with a 1 second period. Now i can publish, and subscribe to messages in Mudlet. This works ok'ish when i run it at 1 second period. I managed to get past this issue, by not running ioloop, but rather setting up a timer that run the client:_ioloop_iteration() at a fixed interval. If i run the ioloop the way the examples describe, I will basically crash the mudclient as the ioloop is blocking the "main thread" from executing. And i have almost gotten it to work the way i want it to using luamqtt. I am trying to implement mqtt support into a mudclient (Mudlet) that has lua as its backend script language.