Log In  

When loading a file via #include, pico-8 crashes when running the program from the command line, like "run".
The code loaded is tested and used correctly and does not cause the crash. Also, running via Ctrl+R works and behaves as expected.

Editor:

Result:

#include multi.lua
m=multi(0,17)
m:draw(10,10)
-- this works when run with ctrl+r
-- it crashes when running with "run"

multi.lua

local multi = {}
multi.__index = multi
setmetatable(multi,{
    __call=function(cls,...)
        return cls.new(...)
    end
    }
)

local function getxy(index)
    local y = flr(index / 16)
    local x = index - y * 16
    return x,y
end

function multi.new(tl,br)
    local self = setmetatable({}, multi)
    local tx,ty = getxy(tl)
    local bx,by = getxy(br)
    local w = bx - tx + 1
    local h = by - ty + 1
    self.tx = tx
    self.ty = ty
    self.bx = bx
    self.by = by
    self.w = w
    self.h = h
    return self
end

local function getindex(x,y)
    return x + y * 16
end

function multi:draw(x,y)
    for u=0,self.w - 1 do
        for v=0,self.h - 1 do
            local index = getindex(self.tx + u, self.ty + v)
            spr(index, x + u * 8, y + v * 8)
        end
    end
end

It also would be great, if the folder for includes was the same folder as the cartridges (AppData).

P#63537 2019-04-15 16:04

:: zep

Thanks @greygraphics

I've fixed a related bug that is now live on the downloads page (0.1.12b), and it looks like it might have been a coincidence that it was crashing for you with RUN instead of CTRL-R. Could you try the new version and see if it works for you now?

P#63552 2019-04-15 21:15 ( Edited 2019-04-15 21:15)

Hi @zep, I tried version 0.1.12b and I have good and bad news.

Good news: It does not crash anymore.
Bad news: It now throws a syntax error on spr(index, x + u * 8, y + v * 8),

namely the first '+'.

When pasting the contents into the editor itself, everything works.

Also, when chaning the line to
spr(index,x-u*8,y+v*8)

(removing all spaces), I get the error
<eof> expected near 'end'.

I hope this helps.

P#63575 2019-04-16 12:16
1

@greygraphics @zep
It is doing the same thing for my friend's windows machine. There is a syntax error for the last line of the file (besides lines that say "end"). I don't have a windows machine to test this more though. But the #include works perfectly in Linux.

P#64577 2019-05-19 05:39

It has something to do with how the files are being parsed. Adding 10 or so spaces to the end of the file being included fixes it. I think the parser is terminating early for some reason.

P#64652 2019-05-21 12:13

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-06-17 12:34 | 0.038s | 4194k | Q:22