LUA help


Problems running or configuring the software, commands & options, compiling, different platforms, using the interface, documentation, etc.

Crypt Cleanser

Posts: 714

Joined: Saturday, 5th December 2015, 06:56

Post Friday, 25th March 2016, 22:52

LUA help

Hi guys, I'm trying to incorporate some very basic LUA into my RC. All I want to do right now is make some custom messages for low hp, mp.

Here is the code in my current RC (this is an exact copy paste):

force_more_message += YOU ARE CLOSE TO DEATH

:local mhp = 1000
:local chp = 1000
:local lhp = 1000

:chp, mhp = you.hp()
:lhp = 10
:if chp < lhp then
: crawl.mpr("YOU ARE CLOSE TO DEATH ")
: crawl.mpr("YOU ARE CLOSE TO DEATH ")
: crawl.mpr("YOU ARE CLOSE TO DEATH ")
: crawl.mpr("YOU ARE CLOSE TO DEATH ")
: crawl.mpr("YOU ARE CLOSE TO DEATH ")
:end

----

This code will cause me to have to press space 5 times if I am below 10 hp. I have tested it, and it works IF my character is below 10 hp when i start the game.

This tells me that the rc code is only being executed once. However, I cannot figure out a way to make it execute once per turn. I know it is possible though, because bots.

https://github.com/elliptic/qw/blob/master/qw.rc

^This bot is an rc file (not external file, all in your .rc config). It has two relevant functions, start() and ready(). It looks like ready() in particular is designed to run once per turn. However, I cant figure out how the author forced this to happen.

Anyone know more? How do I check my char's HP per turn instead of only on load?

Crypt Cleanser

Posts: 714

Joined: Saturday, 5th December 2015, 06:56

Post Friday, 25th March 2016, 23:10

Re: LUA help

Nvm figured it out guys. Looks like ready() function runs automatically each turn. This could have been better documented in the lua entries in the options help file...

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 29 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.