Someone's LUA-Console


Run lua commands without losing achievements. Now remembers input-script. "game.player" works. By default opens with CONTROL + RIGHTBRACKET. Execute last input-script with CONTROL + ENTER.

Utilities
27 days ago
0.17 - 2.0
5.26K
Cheats

b game.player doesnt work with local variables.

1 year, 10 days ago

=== game.player ===

I find that the mod only substitude 'game.player.' to 'game.player[index].' . However, if somebody defined a local var for game.player, it would throw an error.

A simple way is to detect all end-of-line 'game.player':

cmd = cmd .. '\n'
cmd = cmd:gsub('game%.player%s*\n+', 'game.players['..player.index..']\n') -- either '\n' or '\n+' is ok

=== /c at the beginning ===

I am also wondering that if we can just ignore '/c' at the beginning of whole commands.

11 months ago

Any kind of newline-checks are just bad code and introducing bugs, as lua doesnt care about newlines.

I fixed it in the way that 'game.player.' is no longer replaced to 'game.player[index].' but 'game.player' is replaced to 'game.player[index]' - basically get dir of the last dot. That way

local a = game.player
game.print(a.name)

seems to work.

Also I am not fixing people copying non-lua code into a lua input field.

11 months ago

thanks! appreciate your work

New response