Page 1 of 1

.rc LUA help

PostPosted: Wednesday, 4th May 2016, 08:11
by ololoev
A friend of mine wants his character tile to be changed while he levels up.
I just don't know what function is called when you level up. And whether tile_player_tile works without save&restarting or not.

Where can I see all crawl functions that I can use?

Re: .rc LUA help

PostPosted: Wednesday, 4th May 2016, 21:32
by Moose
"a friend of mine" ...

Re: .rc LUA help

PostPosted: Thursday, 5th May 2016, 02:02
by genericpseudonym
ololoev wrote:A friend of mine wants his character tile to be changed while he levels up.
I just don't know what function is called when you level up. And whether tile_player_tile works without save&restarting or not.

Where can I see all crawl functions that I can use?


It's not a default function in crawl, it's a lua script by Gammafunk:
https://github.com/gammafunk/dcss-rc
(crawl does have the option to change the player tile, but it's the script which can automatically change it over time)

To use it with the default settings (which changes tiles every 100 turns as well as on levelup), you can just add
include += RandomTiles.rc
to your rc file. Note that this should only work on the CAO and CBRO servers.

Otherwise you can just copy the contents of the randomtiles.rc on that github.

Re: .rc LUA help

PostPosted: Thursday, 5th May 2016, 07:07
by ololoev
genericpseudonym wrote:It's not a default function in crawl, it's a lua script by Gammafunk:
https://github.com/gammafunk/dcss-rc

TY for the link, but can anybody tell me how it is invoked every UI action? Where is the starting point?

Re: .rc LUA help

PostPosted: Thursday, 5th May 2016, 07:34
by andreas
Try this: look at the readme at that link. In the section on installation he shows you how to make a ''ready function'' which will run each turn. There you should invoke a previously defined function where you check the character's xl (I think you can use you.xl() to do this) and, if it has changed since the last turn, then invoke the gammafunk's function for changing the tile. (I don't know if there is a better way to do this than checking the output of you.xl() each turn.)

EDIT: Adding this in the rcfile underneath where I pasted in the contents of gammafunk's file RandomTiles.rc seemed to do the trick for me.

  Code:
<

  function tileUp()
    oldExpLevel = you.xl()
    new_random_tile()
  end

oldExpLevel = ""


  function ready()
    if (you.xl() ~= oldExpLevel) then
      tileUp()
    end
  end
>


I used 'new_random_tile()' to just get a new random tile on levelup; you might want to use 'set_tile_by_name()' instead, to get a particular tile from gammafunk's list.