dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php
MIT License
367 stars 46 forks source link

AssertionError when using `_update` in required file #74

Open Kikketer opened 3 years ago

Kikketer commented 3 years ago

I'm attempting to create a little bit of a test for my external files.

I created a file something.lua and it contains the text from the docs:

local HandyPackage = {
  handyfunc = function(x, y)
    return x + y
  end,
  handynumber = 3.14,
}

function _update()
  test1 = HandyPackage.handyfunc(2, 3)
end
function _draw()
  cls()
  print('test1 = '..test1)
end

return HandyPackage

I then have a another.lua file that simply does the require:

Something = require('something')

When I attempt to run the build:

p8tool build side.p8 --lua another.lua

I get the following error:

...
  File "......./picotool/pico8/lua/lua.py", line 502, in _get_text
    assert (self._tokens[self._pos].matches(lexer.TokKeyword(keyword)) or
AssertionError

I did notice that if I include the "game_loop" option in the another.lua file, it doesn't throw this error:

Something = require('something', {use_game_loop=true})

I'd like to write these loops to possibly write some tests. Or maybe there's another way to test some of your utility files and also use them for real without having to alter the code?