Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for some reason, this script restarts my homebrew channel: #2

Closed
ACIDULATED opened this issue May 8, 2022 · 11 comments
Closed

for some reason, this script restarts my homebrew channel: #2

ACIDULATED opened this issue May 8, 2022 · 11 comments

Comments

@ACIDULATED
Copy link

function love.load()
    frames = {}

    for i = 1, 4 do
        table.insert(frames, love.graphics.newTexture("kris" .. i .. ".png"))
    end

    currentFrame = 1
    wiimote = love.wiimote.getWiimotes()[1]
    y = 100
end

function love.update(dt)
    currentFrame = currentFrame + dt;
    if currentFrame >= 5 then
        currentFrame = 1
    end
    if wiimote:isDown("down") then
        y += 50;
    end
end

function love.draw()
    if wiimote:isDown("down") then
        love.graphics.draw(frames[math.floor(currentFrame)], 100, y, 0, 1, 1, 48, 48)
    else
        love.graphics.draw(frames[1], 100, y, 0, 1, 1, 48, 48)
    end
end

title says it all. btw, i think a discussions page would be really helpful so nobody has to post every single coding issue they have in the issues page.

@HTV04
Copy link
Owner

HTV04 commented May 8, 2022

I think I need more info. What does your file structure look like?

@ACIDULATED
Copy link
Author

ACIDULATED commented May 8, 2022

I have my images (kris(number).png) in data folder with main.lua. That's about it.

@HTV04
Copy link
Owner

HTV04 commented May 9, 2022

Looking at your code again, I think you missed a tostring() statement on line 5. It should read like this:

for i = 1, 4 do
    table.insert(frames, love.graphics.newTexture("kris" .. tostring(i) .. ".png"))
end

The error shouldn't return to the homebrew menu though, it should just show the normal error screen. See if this helps anyway.

@AM7999
Copy link

AM7999 commented May 9, 2022

I have my images (kris(number).png) in data folder with main.lua. That's about it.

kris????

@Lazr1026
Copy link

Lazr1026 commented May 9, 2022

While I really have no say in this at all, its usually a good idea to keep stuff like this serious, but again this is just my two cents.

@TaiAurori
Copy link

Looking at your code again, I think you missed a tostring() statement on line 5.

Concatenation should work automatically with numbers in Lua without needing a string converter, since that behaviour is defined in the Lua docs:

Lua denotes the string concatenation operator by ".." (two dots). If any of its operands is a number, Lua converts that number to a string.

@GuglioIsStupid
Copy link

Doing

the = 1
theThing = "the thing "
print(theThing + the)

Gives the error main.lua:3: attempt to perform arithmetic on a string value
doing tostring(the) does not give this error

@HTV04
Copy link
Owner

HTV04 commented May 16, 2022

Looking at your code again, I think you missed a tostring() statement on line 5.

Concatenation should work automatically with numbers in Lua without needing a string converter, since that behaviour is defined in the Lua docs:

Lua denotes the string concatenation operator by ".." (two dots). If any of its operands is a number, Lua converts that number to a string.

Interesting, might have to look into this more then.

@TaiAurori
Copy link

doing tostring(the) does not give this error

String concatenation in Lua is more officially done with the double-dot syntax, as the issue author has done in their original code. The Lua interpreter I have installed currently outright rejects concatenation of strings with +, even when both variables are strings.

@GuglioIsStupid
Copy link

doing tostring(the) does not give this error

String concatenation in Lua is more officially done with the double-dot syntax, as the issue author has done in their original code. The Lua interpreter I have installed currently outright rejects concatenation of strings with +, even when both variables are strings.

ah ok cuz i swear the same thing happened with me with .. but ig i just got to used to writing tostring()

@HTV04
Copy link
Owner

HTV04 commented Aug 13, 2022

Fixed in 2e7b7fe

@HTV04 HTV04 closed this as completed Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants