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.



#include multi.lua
-- this works when run with ctrl+r
-- it crashes when running with "run"


local multi = {}
multi.__index = multi
        return cls.new(...)

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

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

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

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)

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

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

I hope this helps.

P#63575 2019-04-16 12:16

@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

If anyone is still having this problem, it's failing because of the end of line character. if you change it from Carriage Return (CRLF) to Line feed (LF) the problem goes away.

@zep I don't know what the code looks like on the backend, but having the includer convert CRLF's to LF's or whatever would solve this.

P#65314 2019-06-21 00:09

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-07-16 03:19 | 0.044s | 4194k | Q:28