I did this myself at one point - for some unknown reason, I have one module that uses a local variable named, and a global for the rest of the program also called mouse. For a while it wasn't an issue, but when I eventually wanted to make use of the functionality of the global version, I found that I was stuck without fixing the whole module . The way I got around it is by making another local variable at the start called gmouse, that was just a reference to the global version - not the most elegant solution, but it works. I now know not to do that.
[Just for fun] Roast my code.
Re: [Just for fun] Roast my code.
Dragon
Re: [Just for fun] Roast my code.
Remember that you can also use _G.mouse. Some style guides even mandate all globals to be referenced through _G.Bobble68 wrote: ↑Sun Dec 31, 2023 1:06 pm I did this myself at one point - for some unknown reason, I have one module that uses a local variable named, and a global for the rest of the program also called mouse. For a while it wasn't an issue, but when I eventually wanted to make use of the functionality of the global version, I found that I was stuck without fixing the whole module . The way I got around it is by making another local variable at the start called gmouse, that was just a reference to the global version - not the most elegant solution, but it works. I now know not to do that.
Re: [Just for fun] Roast my code.
Had not occured to me that this was possible, but I suppose it would be (at the time I did the fix I didn't know about _G).
Dragon
Re: [Just for fun] Roast my code.
This code was for a challenge "Create the worst text editor"(Given by a friend). Sooo the performance has to be.
Using LOVE to make everything except games
Code: Select all
astring = "pog"
print(astring)
--pog
Re: [Just for fun] Roast my code.
Printf kinda breaks the line number system. Soo ill need to fix that before i add printf.Bobble68 wrote: ↑Fri Dec 29, 2023 12:22 pm mr global.png
Also, love.graphics.printf has text wrapping built in, you might want to consider using it instead.
Using LOVE to make everything except games
Code: Select all
astring = "pog"
print(astring)
--pog
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest