Crypt Cleanser
Posts: 714
Joined: Saturday, 5th December 2015, 06:56
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?
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?