Homebrew [Release] Lua Player Plus 3DS (lpp-3ds) - LUA interpreter for 3DS

  • Thread starter Thread starter Rinnegatamante
  • Start date Start date
  • Views Views 187,225
  • Replies Replies 1,199
  • Likes Likes 35
Here it is
System.currentDirectory("/CTGP-7/")
function getconfig()
local config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
local cfgtrack = io.open(System.currentDirectory().."config/tracknames.cfg",FWRITE)
local cfgcustra = io.open(System.currentDirectory().."config/ctnames.cfg",FWRITE)
trackn = (io.size(config) - 1)
local stringtrck = io.read(cfgtrack, 0, io.size(cfgtrack))
local stringct = io.read(cfgcustra, 0, io.size(cfgtrack))
tracks = {}
cts = {}
local l = 1
local m = 1
for i in string.gmatch(stringtrck, "%S+") do
tracks[l] = i -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC.
l = l + 1
end
for s in string.gmatch(stringct, '([^,]+)') do
cts[m] = s -- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC.
m = m + 1
end
cts[trackn + 1] = nil
if not (tracks[trackn + 1] == nil) or not (cts[trackn + 1] == nil) then
System.exit()
end
if (tracks[trackn] == nil) or (cts[trackn] == nil) then
System.exit()
end
local tracken = {}
tracke = {}
local k = 1
for k = 1, trackn, 1 do
tracken[k] = io.read(config, (k-1), 1) -- Get data from config.cfg
if (tracken[k] == "0") then
tracke[k] = false
elseif (tracken[k] == "1") then
tracke[k] = true
end
end
io.close(config)
io.close(cfgtrack)
return true
end
function saveconfig()
local sconfig = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
-- Course order: GBABC, CTRIS, CTRTC, CTRWI1, N64KD, SFCMC
local y
local tracken = {}
for y = 1, trackn, 1 do
if (tracke[y]) then
tracken[y] = "1"
elseif not (tracke[y]) then
tracken[y] = "0"
end
io.write(sconfig,(y - 1),tracken[y], 1)
end
io.close(sconfig)
return true
end
function applyconfig()
local z
for z = 1, trackn, 1 do
if (System.doesFileExist("/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs")) then
if not (tracke[z]) then
System.renameFile("/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs", "/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs")
end
elseif (System.doesFileExist("/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs")) then
if (tracke[z]) then
System.renameFile("/0004000000030"..gamergn.."00/Course/"..tracks[z].."1.szs", "/0004000000030"..gamergn.."00/Course/"..tracks[z]..".szs")
end
end
end
return true
end
function getgamergn()
local config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
if (io.read(config, io.size(config) - 1, 1) == "0") then
askrgn = 1
else
submen = 0
end
gamergn = io.read(config, io.size(config) - 1,1)
io.close(config)
return true
end
topimgl = Screen.loadImage(System.currentDirectory().."resources/top_l.bmp")
submen0 = Screen.loadImage(System.currentDirectory().."resources/submen0.bmp")
submen1 = Screen.loadImage(System.currentDirectory().."resources/submen1.bmp")
submen2 = Screen.loadImage(System.currentDirectory().."resources/submen2.bmp")
submen3 = Screen.loadImage(System.currentDirectory().."resources/submen3.bmp")
music0 = Sound.openWav(System.currentDirectory().."resources/music0.wav",false)
music1 = Sound.openWav(System.currentDirectory().."resources/music1.wav",false)
mus0 = 0
men = 0
men1 = 0
men3 = 1
getgamergn()
oldpad = Controls.read
topscreen = topimgl
bottomscreen = submen0
Sound.init()
Sound.play(music0,NO_LOOP,0x09)
while true do
Screen.waitVblankStart()
Screen.refresh()
Screen.clear(BOTTOM_SCREEN)
Screen.drawImage(0,0,topscreen,TOP_SCREEN)
Screen.drawImage(0,0,bottomscreen,BOTTOM_SCREEN)
checkbutton = true
pad = Controls.read()
if (mus0 == 0) then
if (Sound.getTime(music0) == 18) then
Sound.play(music1,LOOP,0x0A)
Sound.close(music0)
mus0 = 1
end
end
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
men = men + 1
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
men = men - 1
end
if (Controls.check(pad,KEY_DRIGHT)) and not (Controls.check(oldpad,KEY_DRIGHT)) then
men1 = men1 + 1
elseif (Controls.check(pad,KEY_DLEFT)) and not (Controls.check(oldpad,KEY_DLEFT)) then
men1 = men1 - 1
end
if (men > 1) then
men = 0
elseif (men < 0) then
men = 1
end
if (men1 > 1) then
men1 = 0
elseif (men1 < 0) then
men1 = 1
end
if (askrgn == 1) then
submen = 255
dispreg = "None"
if (men == 0) then
gamergn = 7
dispreg = "EUR"
elseif (men == 1) then
gamergn = 8
dispreg = "USA"
end
Screen.debugPrint(0, 0, "Current selected game region is: "..dispreg, Color.new(255,255,255), BOTTOM_SCREEN)
Screen.debugPrint(0, 0, "DPAD up or down to choose, A to confirm.", Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and not (dispreg == "None") then
config = io.open(System.currentDirectory().."config/config.cfg",FWRITE)
io.write(config, io.size(config) - 1, gamergn, 1)
io.close(config)
askrgn = 0
submen = 0
men = 0
men1 = 0
end
end
if (submen == 0) then -- main menu
bottomscreen = submen0
if (men == 0) then
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
getconfig()
applyconfig()
System.launchGamecard()
end
else
Screen.fillEmptyRect(159, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 1
men = 0
men1 = 0
checkbutton = false
end
end
else
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
men = 0
men1 = 0
submen = 2
checkbutton = false
end
else
Screen.fillEmptyRect(159, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
Sound.term()
System.exit()
end
end
end
end
if (submen == 1) then -- CTGP-7 manager
bottomscreen = submen1
if (men == 0) then
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 3
men = 0
men1 = 0
checkbutton = false
getconfig()
end
else
Screen.fillEmptyRect(159, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
end
else
if (men1 == 0) then
Screen.fillEmptyRect(0, 159, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
else
Screen.fillEmptyRect(159, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 0
men = 0
men1 = 0
checkbutton = false
end
end
end
end
if (submen == 2) then -- Options
bottomscreen = submen2
if (men == 0) then
Screen.fillEmptyRect(0, 319, 0, 119, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
askrgn = 1
getconfig()
submen = 0
men = 0
men1 = 0
checkbutton = false
end
else
Screen.fillEmptyRect(0, 319, 119, 239, Color.new(255,255,255), BOTTOM_SCREEN)
if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and (checkbutton) then
submen = 0
men = 0
men1 = 0
checkbutton = false
end
end
end
if (submen == 3) then -- Course manager
bottomscreen = submen3
if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
men3 = men3 - 1
elseif (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
men3 = men3 + 1
end
if (men3 == trackn + 1) then
men3 = 1
elseif (men3 == 0) then
men3 = trackn
end
if (Controls.check(pad,KEY_DRIGHT)) and not (Controls.check(oldpad,KEY_DRIGHT)) and (checkbutton) or (Controls.check(pad,KEY_DLEFT)) and not (Controls.check(oldpad,KEY_DLEFT)) and (checkbutton)then
tracke[men3] = not tracke[men3]
end
if (Controls.check(pad,KEY_B)) and not (Controls.check(oldpad,KEY_B)) and (checkbutton) then
submen = 1
men = 0
men1 = 0
checkbutton = false
saveconfig()
end
enadisa = {}
for x = 1, trackn, 1 do
if (tracke[x]) then
enadisa[x] = "enabled"
elseif not (tracke[x]) then
enadisa[x] = "disabled"
end
end
Screen.debugPrint(0, 0, men3..": "..cts[men3].." = "..enadisa[men3], Color.new(255,255,255), BOTTOM_SCREEN)
end
Screen.debugPrint(0, 100, System.getGWRomID(), Color.new(255,255,255), BOTTOM_SCREEN)
oldpad = pad
Screen.flip()
end

Code seems fine.
What workarounds are you using and what version of makerom?
 
I'm using lastest commit, and the makerom and rsf from lpp git. The app inits fine, but fails loading the code, because the green pixel.

Try renaming your file to sun_index.lua and use this CIA file and tell me if it works.
 

Attachments

Yep, it worked. (But the music corrupted).

I also noticed when I use the function to launch the gamecard, the system reboots first, could that be avoided?
 
Yep, it worked. (But the music corrupted).

I also noticed when I use the function to launch the gamecard, the system reboots first, could that be avoided?

Reboot is needed to bypass region lock, anyway it could be avoided by changing how gamecard is launched in the sourcecode (if you have a working development environment to make changes to the src).
 
Wait, so if you can't compile this, then how is CHMM (1) written with this but has no .LUA files, only the 3dsx?
 
You should edit this: https://github.com/Rinnegatamante/lpp-3ds/blob/master/source/luaSystem.cpp#L1256-L1258
Which uses ns:s service (what regionThree, regionFour uses) with something like this:
https://github.com/Rinnegatamante/lpp-3ds/blob/master/source/luaSystem.cpp#L1297-L1300
Which is how lpp-3ds launches installed CIA titles.

It worked, thanks. However, NTR CFW is incompatible with lpp, so all my plans are destroyed.... It also isn't compatible with apt service, so meh, I imagined it would fail.
 
I have here something special. I have this layout for the touchscreen

touchLayout.png


and have no idee how to code this. is there some way to code triangular touch regions?
 
I have here something special. I have this layout for the touchscreen

touchLayout.png


and have no idee how to code this. is there some way to code triangular touch regions?
mmmmm Maybe you can do this:
1- declare an array of points (Extremes of the polygon) for each touch region
2-append to a list of arrays
3-Make a function which when touch a position on the screen return which touch region are you touching, if is one of them.

Maybe you can make a Button Class for that, I guess.
 
mmmmm Maybe you can do this:
1- declare an array of points (Extremes of the polygon) for each touch region
2-append to a list of arrays
3-Make a function which when touch a position on the screen return which touch region are you touching, if is one of them.

Maybe you can make a Button Class for that, I guess.

Print on the screen this template and then check for the color of the pixel you touched with getPixel (an example of this can be found in PixelRoad src: http://gbatemp.net/threads/pixelroad-a-stupid-game-hb-to-test-lpp.375292/ )
 
But he only will know if a button is touched, not which of them is

Just color the different areas with different colors <.< You can also just load a similar image with different colors and use getPixel with this image without printing it on the screen at all.
 
worked.
but another question (am i asking to many questions?) how about gif support? for a simple and little animation without sound we dont need jpgv/bmpv. And if gif support will wont be: why?

You can write a tile-based animation like RPG Maker 3DS does.
GIF support is not in my plans (at least not for the near future)
 

Site & Scene News

Popular threads in this forum