yojimbo2000’s Trench Run & common problem with old downloaded projects

@yojimbo2000 created a really cool looking Star Wars trench run game thing, see attached screenshot.

It won’t run anymore; attached is a zip of it.

If anyone can help get it working that would be awesome.

I’ve attached an image of the error. This is a frustrating thing that happens with a lot of things I download: Codea shows an error and claims that a function is a nil value when it’s actually not. It’s right there in the file but Codea doesn’t;t seem to see it. Sometimes it seems like old downloaded projects can’t see class functions. @Simeon, could there be something to that?

Anyway, if you want to see it run a little bit, copy and paste this installer into a new project:

local url = "https://raw.githubusercontent.com/Utsira/Codea-OBJ-Importer/master/TrenchRun.codea/"

local function install(data)
    --parse plist into list of tab files
    local array = data:match("<key>Buffer Order</key>%s-<array>(.-)</array>")
    local files = {}

    for tabName in array:gmatch("<string>(.-)</string>%s") do
        table.insert(files, {name = tabName})

    --success function
    local function success(i, name, data)
        if not data then alert("No data", name) return end
        print("Loaded "..i.."/"..#files..":"..name)
        files[i].data = data
        for i,v in ipairs(files) do
            if not v.data then 
                return --quit this function if any files have mssing data
        --if all data is present then save...
        for i,v in ipairs(files) do
            saveProjectTab(v.name, v.data)
            print("Saved "..i.."/"..#files..":"..v.name)
        for i,v in ipairs(files) do --load...
        setup() --and run
    --request all the tab files
    for i,v in ipairs(files) do
        http.request(url..v.name..".lua", function(data) success(i, v.name, data) end, function(error) alert(error, v.name.." not found") end)


http.request(url.."Info.plist", install, function (error) alert(error) end)

It will run a little and then crash, but as soon as you exit to the editor it won’t fully run again ever.

That is really cool. The main problem with the attached project is that some of the tabs are out of order (move Mesh to near the start, after Main). And then for some reason the assets are not being created correctly, specifically the laser bolts aren’t being generated. If you go into the Player class and comment out the line which creates a Bolt on touch (starts Bolt{...) it will run, but you can’t see the shots

This seems to be due to a problem with how it tries to load/build assets using a coroutine

@Simeon using the tried and true debugging-by-print-statements method I trace the problem to the line “local m = matrix():rotate(180):rotate(55, 1,0,0)” on the assets tab.

A print statement put after that line will never print.

If you change that line to just “local m = mesh()” the project runs.

But it’s kind of funny because none of the laser blasts are pointed the right direction.

Curiouser and curiouser: it also runs if you change the line to local m = matrix():rotate(55,1,0,0), and the laser blasts point the right direction mostly, it’s just that your own blasts point towards you, not away from you.

But it’s much better!

Something in Codea is freaking out about matrix():rotate(180)

Try replace the rotate(180) with rotate(180, 0,0,1). Looks like our bug

@Simeon now it works! Awesome. Fun to see this old project run.

Attached zip file has fully working game.