[solved] Resetting a table back to it's original values

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
AlexCalv
Prole
Posts: 49
Joined: Fri Aug 08, 2014 7:12 pm
Contact:

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

Post 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!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 1 guest