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.
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.
/3ds/lovepotion/game/stuff/stuff/code.lua
Seperators in what way? In your example, would the full path be:
?Code:/3ds/lovepotion/game/stuff/stuff/code.lua
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.
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
@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.
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
Thanks for the quick reply! But when running your code i get this error:
Code:main.lua:6: bad argument #1 to 'setFont' (bad type)
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?
function love.keypressed(key)
if key == "select" then
dofile(/3ds/homebrew-name]/code.lua)
end
I think this is how you do it.Code:function love.keypressed(key) if key == "select" then dofile(/3ds/homebrew-name]/code.lua) end
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
Using dofile() is bad practice, you should use require() instead.
In the logic section (I believe that's the love.update?)Another question! (I really am sorry if im bothering anyone )
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)
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....)
if player.x + player.hsp < 25 then --player.hsp is whatever you use for your player's horizontal movement!
player.hsp = 0
end
Just curious, why is that?
Another question! (I really am sorry if im bothering anyone )
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)
if character.x < 25 then
character.x = 25
end
That works well, but I've seen that cause rubberbanding. Might've done it wrong too. :v /shrugThe absolute simplest way of doing that is something like this:
Code:if character.x < 25 then character.x = 25 end
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
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
gameStates[gameState]:load()
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
intro.luaCode: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
When it gets toCode: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
I get an error saying "Attempt to index field '?' (a nil value)"Code:gameStates[gameState]:load()
It it how I'm calling the function? I've tried other ways but it throws the same error.
function love.update(dt)
--blahblah
gameStates[gameState]:update(dt)
end
gameStates[gameState].update(gameStates, dt)
gameStates['intro']