Page 2 of 2

Re: Resetting a table back to it's original values

Posted: Sun Oct 05, 2014 7:07 am
by AlexCalv
Robin wrote:Note that ivan's copy functions crash if you pass a table with cycles.

Now, what you probably want is none of this, but just a reset function:

Code: Select all

player = {}

function player.Reset()
   player.x = 10
   player.y = 636
   player.width = 80
   player.height = 80
   player.speed = 300
   player.xVel = 0
   player.yVel = 0
   player.jumpVel = -800
   player.score = 0
   player.lives = 3
   player.state = "stand"
end

player.Reset()
Then you can simply call player.Reset().
This was literally the simplest thing. Everyone else was listing the most complicated ways lol. Thanks everyone for responding!