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

  • Thread starter Thread starter Rinnegatamante
  • Start date Start date
  • Views Views 187,240
  • Replies Replies 1,199
  • Likes Likes 35
Any way to make it display one image then another and another and loop? Like an animation? I want to make a virtual fireplace.
Code:
Graphics.init()
white = Color.new(255,255,255)
fire_image={} --use arrays (tables) to store animations so that they are far easier to reference
fire_image[0] = Graphics.loadImage(System.currentDirectory().."/fire0.png")
fire_image[1] = Graphics.loadImage(System.currentDirectory().."/fire1.png")
fire_image[2] = Graphics.loadImage(System.currentDirectory().."/fire2.png")
fire_image.frame = 0 --how far through the animation we are

while true do
    fire_image.frame = (fire_image.frame + 1) % 3 --modulo equation to keep the frame looping between 0-2
    Screen.waitVblankStart()
    Graphics.initBlend(TOP_SCREEN)
    Graphics.drawImage(0, 0, fire_image[fire_image.frame], white)
    Graphics.termBlend()
end

Another way would be to put all the fire images onto one image in a big long strip, load it in,
Code:
fire_image.spritesheet = Graphics.loadImage(System.currentDirectory().."/firestrip.png")
and then draw a section of it with Graphics.drawPartialImage(), multiplaying fire_image.frame by however wide your sprite is, like
Code:
Graphics.drawPartialImage(0,0, fire_image.frame * 32,0, 32,32, fire_image.spritesheet, white)
It would load considerably faster on the game's launch, it's just a tad less legible for human eyes.
 
Last edited by HexZyle,
I just got thrown the error:
Code:
Error: attempt to compare nil with number

Why does this error not have an address?
 
It was a couple hours ago, but I believe it was a Graphic.drawImage() with a nil texture variable stored inside a table.
 
What is the limit to the size of images that can be loaded in? I try to load in a 1128x94 image I want to partial draw but it simply doesn't show up regardless of whether I use drawImage or drawPartialImage, so I presume it doesn't fit in the pagefile in RAM. The image loads fine when I crop it down to less than 400 pixels wide.

Additionally, when I use the firmware return feature, it returns a long number. I've looked around and I can't seem to find where this number can be referenced against to figure out the public name for the firmware version.
 
Last edited by HexZyle,
What is the limit to the size of images that can be loaded in? I try to load in a 1128x94 image I want to partial draw but it simply doesn't show up regardless of whether I use drawImage or drawPartialImage, so I presume it doesn't fit in the pagefile in RAM. The image loads fine when I crop it down to less than 400 pixels wide.

Additionally, when I use the firmware return feature, it returns a long number. I've looked around and I can't seem to find where this number can be referenced against to figure out the public name for the firmware version.

I've not tested personally but if i'm not wrong there are size limitations (pixels) for gpu textures.
 
Code:
Graphics.init()
white = Color.new(255,255,255)
fire_image={} --use arrays (tables) to store animations so that they are far easier to reference
fire_image[0] = Graphics.loadImage(System.currentDirectory().."/fire0.png")
fire_image[1] = Graphics.loadImage(System.currentDirectory().."/fire1.png")
fire_image[2] = Graphics.loadImage(System.currentDirectory().."/fire2.png")
fire_image.frame = 0 --how far through the animation we are

while true do
    fire_image.frame = (fire_image.frame + 1) % 3 --modulo equation to keep the frame looping between 0-2
    Screen.waitVblankStart()
    Graphics.initBlend(TOP_SCREEN)
    Graphics.drawImage(0, 0, fire_image[fire_image.frame], white)
    Graphics.termBlend()
end

Another way would be to put all the fire images onto one image in a big long strip, load it in,
Code:
fire_image.spritesheet = Graphics.loadImage(System.currentDirectory().."/firestrip.png")
and then draw a section of it with Graphics.drawPartialImage(), multiplaying fire_image.frame by however wide your sprite is, like
Code:
Graphics.drawPartialImage(0,0, fire_image.frame * 32,0, 32,32, fire_image.spritesheet, white)
It would load considerably faster on the game's launch, it's just a tad less legible for human eyes.
Wow, thanks!
 
What is the limit to the size of images that can be loaded in? I try to load in a 1128x94 image I want to partial draw but it simply doesn't show up regardless of whether I use drawImage or drawPartialImage, so I presume it doesn't fit in the pagefile in RAM. The image loads fine when I crop it down to less than 400 pixels wide.
There is a 1024x1024 texture limit. And for efficiency you should try to make your texture dimensions powers of 2 (e.g. 64x256 or 512x512 or 128x1024 and such). Even if you shrink your texture to 550x200 it's going to be used in GPU as 1024x256 (next power of 2 dimensions) so might as well take advantage and use that space.
 
There is a 1024x1024 texture limit. And for efficiency you should try to make your texture dimensions powers of 2 (e.g. 64x256 or 512x512 or 128x1024 and such). Even if you shrink your texture to 550x200 it's going to be used in GPU as 1024x256 (next power of 2 dimensions) so might as well take advantage and use that space.

I thought it might have been something like this. Thanks.
 
If someone is interested in addNotification feature, i pushed a new update to the ctrulib used by lpp-3ds which should add news:s support (so addNotification should work fine also on NH 2.x). Function is currently untested (due to lack of time) but it should work fine.
 
If someone is interested in addNotification feature, i pushed a new update to the ctrulib used by lpp-3ds which should add news:s support (so addNotification should work fine also on NH 2.x). Function is currently untested (due to lack of time) but it should work fine.

Cool thanks. I'm programming something that's meta/4th wall as shit so having stuff that interacts with things outside of the program is great. (If you're familiar with Christine Love, you'll get my drift)
 
If someone is interested in addNotification feature, i pushed a new update to the ctrulib used by lpp-3ds which should add news:s support (so addNotification should work fine also on NH 2.x). Function is currently untested (due to lack of time) but it should work fine.
Cool thanks. I'm programming something that's meta/4th wall as shit so having stuff that interacts with things outside of the program is great.
seems to have frozen my system when I tried it though. and nothing was added to Notifications. :unsure:
 
How do I make the index.lua put inside of the 3dsx like in CHMM?

You have to compile by yourself a modified lpp-3ds.

Basically you have to:
1) Convert your .lua file in a .h file using bin2c [I personally use the version which came with minimalist pspsdk]
2) Edit main.cpp to load your buffer instead of a file ( https://github.com/Rinnegatamante/CHMM2/blob/master/source/main.cpp#L104 )

CHMM2 uses also bundled assets for images and TTF font. To do this, you have to write from scratch functions you need (Example for TTF fonts: https://github.com/Rinnegatamante/CHMM2/commit/f9ee3431a75e3128c378fd7d4f78daac465cf89b )
 
Last edited by Rinnegatamante,
I helped someone named zeta0134 on IRC once. He was making a lpp-3ds build that read lua scripts from romfs. Not sure what happened with it.

There should be a standard build of lpp-3ds that allows this.
 
  • Like
Reactions: Rinnegatamante
I decided to make the SKIP_ERROR_HANDLING compiling flag much stronger.

What does it means for lpp-3ds users?
When everything will be done, next releases of lpp-3ds will be shipped with two 3dsx files: a debug version and a unsafe version.

The debug version will have the error handler enabled so it's thought to be used by developers to test their homebrew.
The unsafe version will have error handler disabled to have a little speedboost for your homebrews and it's thought to be used as final 3dsx file for your homebrews.
 
Last edited by Rinnegatamante,
  • Like
Reactions: ihaveahax

Site & Scene News

Popular threads in this forum