Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Adapting health bar plugin to Geas MUD

Adapting health bar plugin to Geas MUD

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


Posted by Chaotzin   (19 posts)  Bio
Date Mon 30 Oct 2017 08:25 PM (UTC)
Message
Hi all

I'm very new to scripting but have started playing Geas MUD and would like to adapt a few simple plugins to working over there.

As a start, I'm trying to modify Nick's 'improved health bar plugin' (as seen here: https://www.gammon.com.au/forum/bbshowpost.php?id=9270&page=1).

Geas MUD uses a text/description based prompt as opposed to a numerical one. The prompt always reports on physical, mental and fatigue status, but also reports on stamina when that value is not 100%.

The physical/mental/fatigue output looks like this:


You are slightly hurt, in full vigour and extremely alert.


And with stamina:


You are somewhat hurt, slightly degraded, extremely alert and breathing slightly faster.


I've modified the trigger in Nick's plugin to identify this prompt and to name the variables physical, mental, fatigue and stamina. When a stamina message doesn't show, the trigger picks up the punctuation instead for that variable - I plan to use this to give stamina a 100% value. The full trigger looks like this:


<triggers>
  <trigger
   enabled="y"
   match="^You are (?<physical>(at deaths door|barely alive|terribly hurt|in a very bad shape|in a bad shape|not in a good shape|not feeling very well|hurt|somewhat hurt|slightly hurt|feeling very well))\, (?<mental>(in a vegetable state|exhausted|worn down|indisposed|in a bad shape|not in a good shape|not feeling very well|degraded|somewhat degraded|slightly degraded|in full vigour))(\,| and) (?<fatigue>(extremely exhausted|very exhausted|exhausted|somewhat exhausted|slightly exhausted|extremely tired|very tired|tired|somewhat tired|slightly tired|extremely weary|very weary|weary|somewhat weary|slightly weary|slightly alert|somewhat alert|alert|very alert|extremely alert))( and )?(?<stamina>(completely out of breath|having trouble breathing|panting heavily|panting|breathing heavily|short of breath|slightly short of breath|breathing slightly faster|\.))\.?$"
   regexp="y"
   script="do_prompt"
   sequence="100"
   name="prompt"
  >
  </trigger>
</triggers>


I've tested this just by printing the wildcards and it all seems to work OK up to here. But I've run into a problem trying to assign numerical values to these descriptions.

This is my attempt at a table with numerical values that I've assigned to the various physical messages:


physical = { 
	"at deaths door" = 10,
	"barely alive" = 19, 
	"terribly hurt" = 28, 
	"in a very bad shape" = 37, 
	"in a bad shape" = 46, 
	"not in a good shape" = 55, 
	"not feeling very well" = 64, 
	"hurt" = 73, 
	"somewhat hurt" = 82, 
	"slightly hurt" = 91, 
	"feeling very well" = 100 
	}


And the subsequent action to use these values in the do_prompt function:


function do_prompt (name, line, wildcards)

  local physical = physical [wildcards.physical]


I haven't used tables before so I expect I've got that part wrong. Appreciate any advice.

Thanks!
Top

Posted by Fiendish   USA  (2,541 posts)  Bio   Global Moderator
Date Reply #1 on Mon 30 Oct 2017 10:45 PM (UTC)

Amended on Mon 30 Oct 2017 10:46 PM (UTC) by Fiendish

Message
Try

physical = { 
	["at deaths door"] = 10,
	["barely alive"] = 19, 
	["terribly hurt"] = 28, 
	["in a very bad shape"] = 37, 
	["in a bad shape"] = 46, 
	["not in a good shape"] = 55, 
	["not feeling very well"] = 64, 
	["hurt"] = 73, 
	["somewhat hurt"] = 82, 
	["slightly hurt"] = 91, 
	["feeling very well"] = 100 
	}


https://stackoverflow.com/questions/4514636/lua-implicit-table-creation-with-string-keys-why-the-extra-brackets

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Chaotzin   (19 posts)  Bio
Date Reply #2 on Tue 31 Oct 2017 09:09 AM (UTC)
Message
Thanks Fiendish. All works perfectly now :)
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.


15,020 views.

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

Go to topic:           Search the forum


[Go to top] top

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