[bugfix] LuaScript now works

Fixed wrong casts, typos and global variable naming