Thanks to all of you for the help.
I wasn't aware of var = not var, so I'm using it.
Search found 12 matches
- Mon Jan 30, 2023 7:00 pm
- Forum: General
- Topic: Need help with function for changing boolean state
- Replies: 9
- Views: 3106
- Mon Jan 30, 2023 6:34 pm
- Forum: General
- Topic: Need help with function for changing boolean state
- Replies: 9
- Views: 3106
Need help with function for changing boolean state
I wanted to create a function that can change any boolean variable, if true make it false and the other way around. So I came up with this: local test = true function switch_boolean(var) if var then var = false else var = true end end function love.keypressed(key) if key == "<" then switch...
- Fri Apr 03, 2020 6:33 pm
- Forum: Support and Development
- Topic: attempt to index local 'button' (a number value)
- Replies: 2
- Views: 2581
Re: attempt to index local 'button' (a number value)
I was going crazy and only because I wasn't taking into account that it was in a function with an argument that had the same name. I feel stupid, but I also learned something. Thank you so much!
Now it works.
Now it works.
- Fri Apr 03, 2020 12:25 pm
- Forum: Support and Development
- Topic: attempt to index local 'button' (a number value)
- Replies: 2
- Views: 2581
attempt to index local 'button' (a number value)
Error main.lua:492: attempt to index local 'button' (a number value) Traceback main.lua:492: in function <main.lua:486> [C]: in function 'xpcall' After launching I can click anywhere on the screen and I get the error. It refers to: for i,v in ipairs(button.activeId) do The strange part is, that I us...
- Sat Mar 28, 2020 8:19 am
- Forum: Support and Development
- Topic: error appears only if I repeat a couple of steps for several times very fast
- Replies: 4
- Views: 3976
Re: error appears only if I repeat a couple of steps for several times very fast
Thanks for the help. I'll try out strict.lua
- Fri Mar 27, 2020 8:48 pm
- Forum: Support and Development
- Topic: error appears only if I repeat a couple of steps for several times very fast
- Replies: 4
- Views: 3976
Re: error appears only if I repeat a couple of steps for several times very fast
Thank you for your response, MrFariator! As you can see I'm a beginner with coding and I'm learning empirically, so I appreciate the valuable feedback. Well, on line 638 you try to compare value posX to mouse position, and this value is somehow nil. You could potentially check that the relevant vari...
- Fri Mar 27, 2020 1:11 pm
- Forum: Support and Development
- Topic: error appears only if I repeat a couple of steps for several times very fast
- Replies: 4
- Views: 3976
error appears only if I repeat a couple of steps for several times very fast
I'm getting the following error: Error main.lua:638: attempt to compare nil with number Traceback main.lua:638: in function 'mouseHoverMenu' main.lua:909: in function 'update' [C]: in function 'xpcall' I believe it is because my code is not efficient. But I hope the community can help me figure it o...
- Sun Jul 07, 2019 10:43 pm
- Forum: Support and Development
- Topic: How to use same image more than once
- Replies: 7
- Views: 4998
Re: How to use same image more than once
Thanks! That solved my problem!sphyrth wrote: ↑Sun Jul 07, 2019 5:51 am For now, changetoCode: Select all
object[1] = blueprint[1]
Code: Select all
object[1].name = blueprint[1].name
And thanks to the other replies for their input!
- Sun Jul 07, 2019 4:39 am
- Forum: Support and Development
- Topic: How to use same image more than once
- Replies: 7
- Views: 4998
Re: How to use same image more than once
Your object and your blueprint are now the same data entity, and you're editing your blueprint by proxy. You should copy data over from blueprints to your new objects. Thank you for your answer. I learned something new. I have been searching on how to copy tables but I can't find anything that work...
- Sat Jul 06, 2019 10:37 pm
- Forum: Support and Development
- Topic: How to use same image more than once
- Replies: 7
- Views: 4998
How to use same image more than once
I have the following problem: I created a table for blueprints of objects I want to use in my game (sapceships, etc). Every blueprint has an image. Once I need a new object I create it by loading the data of one of the blueprints into the table for objects. When I assign the same blueprint (thus the...