Homebrew [Release] - LövePotion - LÖVE API for 3DS Homebrew - BETA

XavyrrVaati

Hobbyist programmer?
Member
Joined
Feb 23, 2014
Messages
385
Trophies
0
XP
478
Country
United States
Ahhh, I was using .lua, no wonder. Thanks both of you!
EDIT: Lol, I got a half error screen. Left eye sees the error, right eye sees what I want it to, lmao. Trippy.
 
Last edited by XavyrrVaati,
  • Like
Reactions: VideahGams

Tobold

Member
Newcomer
Joined
Jan 13, 2016
Messages
8
Trophies
0
Age
40
XP
52
Country
Gambia, The
Yup, I use it like this:

Code:
require("stuff.stuff.code")

You don't have to write a full path, the points are used as separators, and you don't have to write .lua.

Seperators in what way? In your example, would the full path be:
Code:
/3ds/lovepotion/game/stuff/stuff/code.lua
?
 

Tobold

Member
Newcomer
Joined
Jan 13, 2016
Messages
8
Trophies
0
Age
40
XP
52
Country
Gambia, The
Is there a way for my program to tell if it runs on a 3DS?
Would be cool if it could configure itself on the fly instead of me making different packages.
 

haazet

Well-Known Member
Newcomer
Joined
Dec 15, 2015
Messages
64
Trophies
0
XP
159
Country
United States
Substance's Sig reminds me I cant build my project for the life of me. I followed the tutorial linked on the github. I run the make file and it builds until it gets to linking build.elf part and it says i was missing things in my devkitARM\arm-none-eabi like libpng and libjpeg. So I installed those portlibs and that message went away but now its saying I dont have libsf2d and libsfil.

Anyone wants to try it out here is the Main and assets to run. Still needs a lot of work
http://giphy.com/gifs/3o6UB9fUwC82bnWqsg
http://s000.tinyupload.com/index.php?file_id=79154826757403831196
 

Substance12

Well-Known Member
Member
Joined
Aug 2, 2015
Messages
562
Trophies
0
XP
549
Country
Argentina
Substance's Sig reminds me I cant build my project for the life of me. I followed the tutorial linked on the github. I run the make file and it builds until it gets to linking build.elf part and it says i was missing things in my devkitARM\arm-none-eabi like libpng and libjpeg. So I installed those portlibs and that message went away but now its saying I dont have libsf2d and libsfil.

Anyone wants to try it out here is the Main and assets to run. Still needs a lot of work
http://giphy.com/gifs/3o6UB9fUwC82bnWqsg
http://s000.tinyupload.com/index.php?file_id=79154826757403831196

Are you on Windows? I made a guide for compiling under Windows a couple days ago:

https://github.com/VideahGams/LovePotion/wiki/Building-LÖVEPotion
 

Substance12

Well-Known Member
Member
Joined
Aug 2, 2015
Messages
562
Trophies
0
XP
549
Country
Argentina
@VideahGams
I setup the font for use, and tried to make it draw "Hello World!"
But i get two white screens..
Could anyone help me with this issue i seem to be having? If they could i would greatly appreciate it.

Your problem is that it's drawing both the background and the text in white. Your code should be like this:


Code:
function love.load()
     love.graphics.set3D(false)
     love.graphics.setScreen('bottom')
     love.graphics.setBackgroundColor(0,0,0) --Black background
     font = love.graphics.newFont("font.ttf",15)
     love.graphics.setFont("font.ttf")
end

function love.draw()
     love.graphics.setColor(255,255,255) --White text
     love.graphics.print('Hello World!',20,20)
end
 

GalladeGuy

Cool and Epic
Member
Joined
Oct 28, 2015
Messages
2,686
Trophies
1
XP
3,115
Country
United States
I have another question. (Im sorry)
How could i make my main.lua load another lua file?
For example
Code:
function love.keypressed(key)
if key == "select" then
        I want to load another lua file here

How could i do this?
Code:
function love.keypressed(key)
if key == "select" then
        dofile(/3ds/homebrew-name]/code.lua)
end
I think this is how you do it.
 
  • Like
Reactions: Fr0zenIce

TurtleP

Well-Known Member
Member
Joined
Oct 7, 2015
Messages
140
Trophies
0
Age
28
Website
TurtleP.github.io
XP
308
Country
United States
More likely:

function love.keypressed(key)
if key == "select" then
require ("someluafile")​
end​
end

The 'someluafile' should be the path to the .lua file you wish to load. I'm not sure why you'd do this, as it's good practice to require any and all .lua files above love.load in global space.
 

VideahGams

Well-Known Member
OP
Newcomer
Joined
Aug 29, 2015
Messages
91
Trophies
0
Age
26
Location
Glasgow, Scotland
Website
videah.xyz
XP
156
Country
Code:
function love.keypressed(key)
if key == "select" then
        dofile(/3ds/homebrew-name]/code.lua)
end
I think this is how you do it.

Using dofile() is bad practice, you should use require() instead.
Code:
function love.keypressed(key)
   if key == "select" then
     require('path.to.lua.file') -- Don't add .lua at the end, use dots instead of slashes
   end
end

The path is relative from the game folder, so if you wanted to require game/stuff/character.lua, it would be require('stuff.character')

As TurtleP said above though, you probably just want to require stuff at the top of the script rather than in a function.
 
Last edited by VideahGams,

XavyrrVaati

Hobbyist programmer?
Member
Joined
Feb 23, 2014
Messages
385
Trophies
0
XP
478
Country
United States
Another question! (I really am sorry if im bothering anyone :P)
Lets say i have a character on the screen, this character has a position of X:25
and Y:25, how can i make it so the character cant go below the 25 X point? Kind of like it can go above 25 but not below.
(Sorry if im not making any sense)
In the logic section (I believe that's the love.update?)
You could do this several ways, I like to do it like this:
Code:
if (player.x + player.xspeed < 25) {
     player.xspeed = 0;
} //sorry if this isn't lua, I think in C++ lol
//What this does is it checks to see if the player's movement would cause the
//player's x value to be below 25, and if it would, it makes the player's speed 0.
//This probably need a little work to be a tiny bit better, but it should work, and
//this how most collision detection would work. (I'm bad at coding so don't actually
// take my word for anything though hhahaha....)

EDIT: This is lua style (I think):
Code:
if player.x + player.hsp < 25 then --player.hsp is whatever you use for your player's horizontal movement!
     player.hsp = 0
end
 
Last edited by XavyrrVaati,
  • Like
Reactions: Fr0zenIce

VideahGams

Well-Known Member
OP
Newcomer
Joined
Aug 29, 2015
Messages
91
Trophies
0
Age
26
Location
Glasgow, Scotland
Website
videah.xyz
XP
156
Country
Just curious, why is that?

dofile() loads a file and executes it, require() keeps a track of what you've already loaded so you don't accidentally load the same code twice.
require() is also the Lua standard way of loading modules, at least for Lua 5.1 onwards (LövePotion uses 5.1)

Another question! (I really am sorry if im bothering anyone :P)
Lets say i have a character on the screen, this character has a position of X:25
and Y:25, how can i make it so the character cant go below the 25 X point? Kind of like it can go above 25 but not below.
(Sorry if im not making any sense)

The absolute simplest way of doing that is something like this:
Code:
if character.x < 25 then
   character.x = 25
end
 
  • Like
Reactions: Fr0zenIce

XavyrrVaati

Hobbyist programmer?
Member
Joined
Feb 23, 2014
Messages
385
Trophies
0
XP
478
Country
United States
I've absolutely rekt my brain on this, but I'm trying to get a finite state machine to work, my code looks like this:
main.lua
Code:
gameStates = {
  intro = {load, draw, update},
  select = {load, draw, update}
}
gameState = 1
require('intro')
require('select')

function love.load()
  --blahblah
  gameStates[gameState]:load()
end

function love.draw()
  --blahblah
  gameStates[gameState]:draw()
end

function love.update(dt)
  --blahblah
  gameStates[gameState]:update(dt)
end
intro.lua
Code:
function gameStates.intro.load()
  --blahblah more code
end
function gameStates.intro.draw()
  --blahblah more code
end
function gameStates.intro.update(dt)
  --blahblah more code
end
When it gets to
Code:
gameStates[gameState]:load()
I get an error saying "Attempt to index field '?' (a nil value)"
It it how I'm calling the function? I've tried other ways but it throws the same error.
 
Last edited by XavyrrVaati,

VideahGams

Well-Known Member
OP
Newcomer
Joined
Aug 29, 2015
Messages
91
Trophies
0
Age
26
Location
Glasgow, Scotland
Website
videah.xyz
XP
156
Country
I've absolutely rekt my brain on this, but I'm trying to get a finite state machine to work, my code looks like this:
main.lua
Code:
gameStates = {
  intro = {load, draw, update},
  select = {load, draw, update}
}
gameState = 1
require('intro')
require('select')

function love.load()
  --blahblah
  gameStates[gameState]:load()
end

function love.draw()
  --blahblah
  gameStates[gameState]:draw()
end

function love.update(dt)
  --blahblah
  gameStates[gameState]:update(dt)
end
intro.lua
Code:
function gameStates.intro.load()
  --blahblah more code
end
function gameStates.intro.draw()
  --blahblah more code
end
function gameStates.intro.update(dt)
  --blahblah more code
end
When it gets to
Code:
gameStates[gameState]:load()
I get an error saying "Attempt to index field '?' (a nil value)"
It it how I'm calling the function? I've tried other ways but it throws the same error.

A couple of things are wrong with this.

Code:
function love.update(dt)
  --blahblah
  gameStates[gameState]:update(dt)
end

Calling a table function with a colon, puts the table (aka self) as the first argument.
So technically, it's passing itself as dt, and the actual dt is the second argument.

It's equivalent to:

Code:
gameStates[gameState].update(gameStates, dt)

The second problem is you have a table indexed with strings instead of numbers, so gameStates[1] will return nil.
Instead you should use the string index like so:
Code:
gameStates['intro']
 
  • Like
Reactions: XavyrrVaati

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • BakerMan @ BakerMan:
    i said i was sleeping...
  • BakerMan @ BakerMan:
    sleeping with uremum
  • K3Nv2 @ K3Nv2:
    Even my mum slept on that uremum
  • TwoSpikedHands @ TwoSpikedHands:
    yall im torn... ive been hacking away at tales of phantasia GBA (the USA version) and have so many documents of reverse engineering i've done
  • TwoSpikedHands @ TwoSpikedHands:
    I just found out that the EU version is better in literally every way, better sound quality, better lighting, and there's even a patch someone made to make the text look nicer
  • TwoSpikedHands @ TwoSpikedHands:
    Do I restart now using what i've learned on the EU version since it's a better overall experience? or do I continue with the US version since that is what ive been using, and if someone decides to play my hack, it would most likely be that version?
  • Sicklyboy @ Sicklyboy:
    @TwoSpikedHands, I'll preface this with the fact that I know nothing about the game, but, I think it depends on what your goals are. Are you trying to make a definitive version of the game? You may want to refocus your efforts on the EU version then. Or, are you trying to make a better US version? In which case, the only way to make a better US version is to keep on plugging away at that one ;)
  • Sicklyboy @ Sicklyboy:
    I'm not familiar with the technicalities of the differences between the two versions, but I'm wondering if at least some of those differences are things that you could port over to the US version in your patch without having to include copyrighted assets from the EU version
  • TwoSpikedHands @ TwoSpikedHands:
    @Sicklyboy I am wanting to fully change the game and bend it to my will lol. I would like to eventually have the ability to add more characters, enemies, even have a completely different story if i wanted. I already have the ability to change the tilemaps in the US version, so I can basically make my own map and warp to it in game - so I'm pretty far into it!
  • TwoSpikedHands @ TwoSpikedHands:
    I really would like to make a hack that I would enjoy playing, and maybe other people would too. swapping to the EU version would also mean my US friends could not legally play it
  • TwoSpikedHands @ TwoSpikedHands:
    I am definitely considering porting over some of the EU features without using the actual ROM itself, tbh that would probably be the best way to go about it... but i'm sad that the voice acting is so.... not good on the US version. May not be a way around that though
  • TwoSpikedHands @ TwoSpikedHands:
    I appreciate the insight!
  • The Real Jdbye @ The Real Jdbye:
    @TwoSpikedHands just switch, all the knowledge you learned still applies and most of the code and assets should be the same anyway
  • The Real Jdbye @ The Real Jdbye:
    and realistically they wouldn't

    be able to play it legally anyway since they need a ROM and they probably don't have the means to dump it themselves
  • The Real Jdbye @ The Real Jdbye:
    why the shit does the shitbox randomly insert newlines in my messages
  • Veho @ Veho:
    It does that when I edit a post.
  • Veho @ Veho:
    It inserts a newline in a random spot.
  • The Real Jdbye @ The Real Jdbye:
    never had that i don't think
  • Karma177 @ Karma177:
    do y'all think having an sd card that has a write speed of 700kb/s is a bad idea?
    trying to restore emunand rn but it's taking ages... (also when I finished the first time hekate decided to delete all my fucking files :wacko:)
  • The Real Jdbye @ The Real Jdbye:
    @Karma177 that sd card is 100% faulty so yes, its a bad idea
  • The Real Jdbye @ The Real Jdbye:
    even the slowest non-sdhc sd cards are a few MB/s
  • Karma177 @ Karma177:
    @The Real Jdbye it hasn't given me any error trying to write things on it so I don't really think it's faulty (pasted 40/50gb+ folders and no write errors)
  • DinohScene @ DinohScene:
    run h2testw on it
  • DinohScene @ DinohScene:
    when SD cards/microSD write speeds drop below a meg a sec, they're usually on the verge of dying
    DinohScene @ DinohScene: when SD cards/microSD write speeds drop below a meg a sec, they're usually on the verge of dying