Building a toggle

Post Reply
panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Building a toggle

Post by panamaniac »

Hi all,

So in the mud I play there's a command to make you be in either offense or defense mode. It takes about 10 seconds to go from one to the other. The problem is that there's not a command to quickly see which mod you're in.

What I'm hoping for is something that triggers on certain text (e.g. "you are now in offense mode") to remember which mode i'm in. So for example having an alias that when entered returns either "offense" or "defense" so that I know what mode I'm in.

Does anyone have any suggestions of how I could code this? I'm assuming there's a way to capture and then recall information in a table...?

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Building a toggle

Post by Belgarath »

Here's a simple example:
Code: [show] | [select all] lua
-- Trigger: You are now in offence mode.
mode = "offence"

-- Trigger: You are now in defence mode.
mode = "defence"

-- Alias to display mode:
cecho("<cyan>++ <green>You are in <red>" .. mode:upper() .. "<green> mode!<cyan> ++\n")
If you want to add it to a table, just use pvp.mode instead. Good luck!

Post Reply