This is a prototype of a time travelling debugger for Lua, inspired by Elm's.
Download Love2d from http://love2d.org. Version 0.9.x.
Change the velocity when jumping from 6.
It's likely performance will not scale since every function call is recorded, and every function call is now dozens of function calls instead. Will likely slow as the program runs and/or more logic is added.
Does not currently handle bugs in code well.
Saw it from http://debug.elm-lang.org/edit/Mario.elm
Elm's functional programming and pure functions are tools to assist building a time travelling debugger.
Lua's functions, on surface, are mutable and can have side effects, and would greatly impede the implementation of a time travelling debugger like Elm's.
However, if we switch our perspective, really, every Lua functions are pure functions. A Lua function takes the global state, the upvalues state, the input parameters, and returns some values, as well as a set of modifications to the global state, and the upvalues state. As long as we use the same global table, the same set of upvalues, and the same arguments, a Lua function will almost always return the same values, and do exactly the same thing. This prototype is implemented based on this fact.
There are functions that use information or perform actions that affect the
world outside of the global state or upvalues, for example, io.read and
io.write. All we have to do is tell the debugger that these are impure
functions whose returns must be recorded, so they can be played back without
being run, while the debugger is performing the "time-travel". This is done
love.keyboard.isDown = record(love.keyboard.isDown)
See usage in
This debugger can work with any Lua program, not just with Love2d.