Rinnegatamante / lpp-vita

Lua Player Plus for PSVITA. Documentation on: http://rinnegatamante.github.io/lpp-vita/
GNU General Public License v3.0
179 stars 27 forks source link

require() crashes vita #30

Closed svennd closed 1 year ago

svennd commented 6 years ago

Would it be possible to implement/patch the require() function in lua

Rinnegatamante commented 6 years ago

That should allow require usage. Scripts must be placed in app0: partition. Let me know if it works so i can update VPS environment too. eboot_safe.zip

svennd commented 6 years ago

Will try this weekend.

svennd commented 6 years ago

tried, failed. I tried both the 5x and 5.1-5.2 method, they both crash the lpp. I have the dumps but cannot post them here...

Anyway its doable to work around with do() so its totally up to you if you wish to hunt for this bug.

Rinnegatamante commented 6 years ago

Can you pastebin the exact code you tried? Crashdumps too can be helpful.

svennd commented 6 years ago

Hey Rinny,

I tried these methods : http://lua-users.org/wiki/ModulesTutorial (adapted to vita hello world) the last one was : (there are both methods)

index.lua

mymodule = require("app0:/test.lua")
mymodule.foo()

test.lua

module("mymodule", package.seeall)

function foo()
    -- Create a new color
    local white = Color.new(255,255,255) 

    -- Main loop
    while true do

        -- Draw a string on the screen
        Graphics.initBlend()
        Screen.clear()
        Graphics.debugPrint(5, 5, "Hello World!", white)
        Graphics.debugPrint(5, 25, "Press TRIANGLE to return to the sample selector.", white)
        Graphics.termBlend()

        -- Update screen (For double buffering)
        Screen.flip()

        -- Check controls for exiting
        if Controls.check(Controls.read(), SCE_CTRL_TRIANGLE) then
            break
        end

    end
end

dump : https://ufile.io/ioblf

Rinnegatamante commented 6 years ago

You must use "test.lua" or "test" and place the script in app0:.

svennd commented 6 years ago
mymodule = require("app0:/test")
mymodule.foo()

this ?

Rinnegatamante commented 6 years ago

"test.lua" or "test", not "app0:test"...

svennd commented 6 years ago

both crash : https://ufile.io/wo766

Rinnegatamante commented 6 years ago

According to the crashdump, it's a issue related to vita-libdl: https://github.com/hyln9/vita-libdl/issues/1

0x8080 commented 6 years ago

Still an issue, I need this dearly for something I'm working on.

svennd commented 6 years ago

Yes, its still open. I hope this can get fixed some day, currently its not possible to load code w/o executing it directly, which is a huge help for keeping code clean. I tried to work around require() with loadfile() but that also does not work.

also load() and the deprecated loadstring() crash it ... seems we have to wait for hyln9 to fix ... :(

Rinnegatamante commented 1 year ago

This now works with replaced luajit+libdl.