Fatal: Non-empty stack after LuaContext::update()

Started by wizard_wizzle (aka ZeldaHistorian), February 16, 2014, 07:45:22 PM

Previous topic - Next topic
Not sure if this is a bug in the engine or the fault of my script, but I get the error "Fatal: Non-empty stack after LuaContext::update()" when one of my enemies is on the screen after a few seconds. The enemy script is below:

local enemy = ...

-- Octorok: simple enemy who wanders and shoots rocks

local going_hero = false
local awaken = false
local timer

function enemy:on_created()
  self:set_life(1)
  self:set_damage(2)
  self:create_sprite("enemies/octorok_red")
  self:set_hurt_style("monster")
  self:set_pushed_back_when_hurt(true)
  self:set_push_hero_on_sword(false)
  self:set_size(16, 16)
  self:set_origin(8, 13)
end

function enemy:on_movement_changed(movement)
  local direction4 = movement:get_direction4()
  local sprite = self:get_sprite()
  sprite:set_direction(direction4)
end

function enemy:on_obstacle_reached(movement)
  if awaken and not going_hero then
    self:check_hero()
  end
end

function enemy:on_restarted()
  if not awaken then
    self:go_random()
  else
    self:go_hero()
  end
  self:check_hero()
end

function enemy:on_hurt()
  if timer ~= nil then
    timer:stop()
    timer = nil
  end
end

function enemy:check_hero()
  local hero = self:get_map():get_entity("hero")
  local _, _, layer = self:get_position()
  local _, _, hero_layer = hero:get_position()
  local near_hero = layer == hero_layer
    and self:get_distance(hero) < 100

  if awaken then
    if near_hero and not going_hero then
      self:go_hero()
    elseif not near_hero and going_hero then
      self:go_random()
    end
  elseif not awaken and near_hero then
    self:wake_up()
  end
  timer = sol.timer.start(self, 1000, function() self:check_hero() end)
end

function enemy:wake_up()
  self:stop_movement()
  local sprite = self:get_sprite()
  sprite:set_animation("shooting")
  local x, y, l = self:get_position()
  local sx, sy = 0
  if d == 0 then
    sx = x + 8
    sy = y
  end
  if d == 1 then
    sy = y - 8
    sx = x
  end
  if d == 2 then
    sx = x - 8
    sy = y
  end
  if d ==3 then
    sy = y +8
    sx = x
  end
  sol.timer.start(self, 1000, function()
    local rock = self:create_enemy{
      breed = "rock_small",
      x = sx,
      y = sy
    }
    rock:go(d)
    sol.timer.start(self, 2000, function()
      self:check_hero()
    end)
  end)
end

function enemy:go_random()
  local m = sol.movement.create("random")
  m:set_speed(32)
  m:start(self)
  d = m:get_direction4()
  going_hero = false
end

function enemy:go_hero()
  local m = sol.movement.create("target")
  m:set_speed(48)
  m:start(self)
  d = m:get_direction4()
  going_hero = true
end

This is an internal bug of the engine. It should now be fixed by commit e23651e. Thanks for the report!

I went to compile the newest code, and all the sudden I'm getting a cmake error about not being able to find OpenAL which I didn't get yesterday when I compiled older code. I double-checked and my system does have libopenal installed.

-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found SDL2: /usr/local/lib/libSDL2main.a;/usr/local/lib/libSDL2.so;-lpthread (Required is at least version "2")
-- Found SDL2_image: /usr/include/SDL2 (found suitable version "2.0.0", minimum required is "2")
-- Found SDL2_ttf: /usr/local/include/SDL2 (found suitable version "2.0.12", minimum required is "2.0.12")
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find OpenAL (missing: OPENAL_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindOpenAL.cmake:97 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:18 (find_package)


-- Configuring incomplete, errors occurred!

This is strange, nothing has recently changed with OpenAL.

Hmmm... I'll triple check my system config - I just thought I'd check with you too!