Battle Log with delay (Print Out List With A Delay Between Items)

Hi, here's my code for displaying the battle log (RPG style game).
I had to do some tricks because It's impossible to use the SetTimeout function inside a foreach loop.

  1. create a stringlist variable in your game object (or wherever you like) ,for example game.battleLog, to store all the messages.

  2. If you use the attacktheplayer turnscript (from RPG combat lib) , paste this code at the end:
    foreach(entry, game.battleLog) {
    request(Hide, "Command")
    EnableTimer (displayBattleLog)

  3. create a Timer (I call it "displayBattleLog"), paste this code:

See the code below:

<timer name="displayBattleLog">
			n = StringListItem (game.battleLog, 0)
			msg ("<br>" + n)
			JS.scrollToEnd ()
			list remove (game.battleLog, n)
			if(ListCount(game.battleLog) = 0){
				DisableTimer (displayBattleLog)	
				request(Show, "Command")					

This topic is now closed. Topics are closed after 60 days of inactivity.