[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Problems with lua
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Problems with lua

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Dphyre   (1 post)  [Biography] bio
Date Fri 13 Oct 2017 02:06 AM (UTC)
Message
I've got a small problem, and I fixed some of it, but would like expand it a little if you guys could help me.
I've got a MUD game I play and I have a custom monitor that fires off every 3-6 seconds and it looks like this:

HP: * ( * ) GP: * ( * ) XP: ( * ) Align: ( * )
when I see that, I have a trigger that does this.

if %3 > 200 then
DoAfter(math.random(1)+1, "XXX")
end -- if

So, if that third *, my GP, is above 200 I send a MM command. That works perfect but would like to expand it.
In that * next to align, there can be several things appear there. "extremely good", "very good", "quite good", "good", "barely good", "neutral", "barely evil", "evil", "quite evil", "very evil", and last but not least, "extremely evil"

I play an evil god, and can only cast the MM command if my alignment is Barely evil - extremely evil. What I wanted to do is follows, but I dont know the syntax.

if %3 > 200 and %6 == "barely evil|evil|quite evil|very evil|extremely evil" then
DoAfter(math.random(1)+1, "XXX")
end -- if

Basically, I need both of those conditions to be true, before it fires "XXX"


I also thought about triggering HP: * ( * ) GP: * ( * ) XP: ( * ) Align: ( * ) and using that to consistently update two variables too. But im unsure how to call variables inside the send box.

if GP > 200 and (AS == "barely evil" or AS == "evil" or AS == "quite evil" or AS == "very evil" or AS == "extremely evil" then
DoAfter(math.random(1)+1, "XXX")
end -- if

but both of those solutions gives me error, I would appricaite the help, if anyone could help me. One other thing is when I see this "HP: * ( * ) GP: * ( * ) XP: ( * ) Align: ( * )" in my mud - can it update the variables and fire off XXX if both conditions inside those variables are met?
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Fri 13 Oct 2017 07:23 AM (UTC)

Amended on Fri 13 Oct 2017 07:27 AM (UTC) by Fiendish

Message
Quote:
%6 == "barely evil|evil|quite evil|very evil|extremely evil"


I would do something like...

my_alignments = { 
   ["barely evil"] = true,
   ["evil"] = true,
   ["quite evil"] = true,
   ["very evil"] = true,
   ["extremely evil"] = true
}
if (%3 > 200) and my_alignments["%6"] then

The reason it would work is because when you look for a key that exists in the my_alignments table you will get back true, but if the key doesn't exist you will get back nil which is a false-ish value.

Quote:
But im unsure how to call variables inside the send box.

See the GetVariable and SetVariable functions.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


604 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]