[SOLVED] Error: Attempt to call upvalue (a nil value)

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.
Post Reply
User avatar
fairenough
Prole
Posts: 12
Joined: Fri Aug 11, 2017 4:44 pm
Contact:

[SOLVED] Error: Attempt to call upvalue (a nil value)

Post by fairenough »

Hi all! I'm back with another question.

So I'm using hump's class system, and everything is going swimmingly so far. Or was, until I added another class. Which to me means I screwed something up in the code for the new class. I've made classes before and it went fine, which has me pulling my hair out trying to figure this one out.

When I launch the game, I get:
gamestates/gameLevel1.lua:19: attempt to call upvalue 'Explosion' (a nil value)

Here's the code for gameLevel1.lua:
(line 19 is: exp = Explosion(0,0) as you may have guessed)

Code: Select all

Gamestate = require 'libs.hump.gamestate'

local Entities = require 'entities.Entities'
local Entity = require 'entities.Entity'

local gameLevel1 = {}


local Player = require 'entities.player'
local Bg = require 'entities.background'
local Enemy = require 'entities.enemy'
local Explosion require 'entities.explosion'

function gameLevel1:enter()
  Entities:enter()
  background = Bg(0,0)
  enemy = Enemy(200,200)
  exp = Explosion(0,0)
  
  player = Player(100, 50, exp)
  Entities:addMany({background, exp, player, enemy})
end

function gameLevel1:update(dt)
  Entities:update(dt)
end

function gameLevel1:draw()
  Entities:draw()
end

return gameLevel1
And for kicks, here's explosion.lua (which to the best of my knowledge is a duplicate of the other classes I've made):

Code: Select all

local Class = require 'libs.hump.class'
local Entity = require 'entities.Entity'

local explosion = Class{
  __includes = Entity
}


function explosion:init(x, y)
  local img = love.graphics.newImage("assets/explosion04.png")
  self.explosion = love.graphics.newParticleSystem(img, 32)
  self.explosion:setParticleLifetime(1,2)
  self.explosion:setSpeed(50,75)
  self.explosion:setRotation(0,3)
  self.explosion:setSizes(0.01,0.05)
  self.explosion:setColors(255,255,255,255,255,255,255,0)
--  self.explosion:setDirection(3)
  self.explosion:setParticleLifetime( 0.25, 0.5 )
  
  -- Init Class
  Entity.init(self, x, y, 1,1)
end


function explosion:update(dt)
  self.explosion:update(dt)
end


function explosion:boom(x,y)
  self.explosion:moveTo(x,y)
  self.explosion:emit(10)
end

function explosion:draw()
  love.graphics.draw(self.explosion)
end


return explosion
I've also attached the .love file. Any insight would be very appreciated! Thank you!
Attachments
flight.love
(697.53 KiB) Downloaded 166 times
Last edited by fairenough on Fri Aug 18, 2017 12:38 pm, edited 1 time in total.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Error: Attempt to call upvalue (a nil value)

Post by Ref »

Code: Select all

local Explosion require 'entities.explosion'
No '=' so no Explosion
User avatar
fairenough
Prole
Posts: 12
Joined: Fri Aug 11, 2017 4:44 pm
Contact:

Re: Error: Attempt to call upvalue (a nil value)

Post by fairenough »

OMFG.

Jesus. So simple. I *knew* it was going to be something simple.

Thank you. *puts head down in shame and shuffles away* :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests