in this case, I am having the value 150 passed over from another class using OOP and i need to have the 150 encased in quotation marks…
basically i need to have
function Score:__init(numberOfBricks – 150)
self.numberOfBricks = numberOfBricks
but
self.numberOfBricks = “numberOfBricks”
I am checking whether
if score.text == numberOfBricks then …
but it only works if i have
if score.text == “150” then
my purpose is to make my code as adaptable to change as possible so if i changed 150 in one class it would automatically change in the class it is passed over to. thanks for any help.
In Lua if you want a number, just type in the number without any quote marks. When you put quote marks around it, you get a string.
Lua will try to automatically convert numbers to strings and strings to numbers where it makes sense.
Since we can’t see where you’re calling your .__init() function, it’s going to be hard to say. Also when posting code, it’s best to copy/paste from your text editor. Then use the blue <> button in the row with bold & italic and paste the code into the popup window.
In Lua if you want a number, just type in the number without any quote marks. When you put quote marks around it, you get a string.
Lua will try to automatically convert numbers to strings and strings to numbers where it makes sense.
Since we can’t see where you’re calling your .__init() function, it’s going to be hard to say. Also when posting code, it’s best to copy/paste from your text editor. Then use the blue <> button in the row with bold & italic and paste the code into the popup window.