Page 4 of 4

Re: Hello, trying to print a text i input

Posted: Thu Dec 12, 2013 5:13 pm
by veethree
MysticPing2 wrote:

Code: Select all

pop = tonumber(textboxes[1.text])
income = tonumber(textboxes[2.text])
tax = tonumber(textboxes[3.text])
healthcare = tonumber(textboxes[4.text])
education = tonumber(textboxes[5.text])
Im trying to do this and im getting a syntax error on the first line, any idea why?
i think i know the problem, unsure on how to fix it
should be textboxes[1].text (same for the other ones)

Re: Hello, trying to print a text i input

Posted: Thu Dec 12, 2013 6:59 pm
by MysticPing2
Ok, last time i need help, i want it to update every secound and print output2, but its not working, im using a delta time loop.

And thanks for everything sofar, ive learned ALOT

Re: Hello, trying to print a text i input

Posted: Thu Dec 12, 2013 7:22 pm
by veethree
MysticPing2 wrote:Ok, last time i need help, i want it to update every secound and print output2, but its not working, im using a delta time loop.

And thanks for everything sofar, ive learned ALOT
Drawing calls outside of love.draw() aren't drawn, this include love.graphics.print, What exactly do you want it to do? Should it print output2 constantly and update it every second?

Also you have an unnecessary nested loop in love.draw (a loop within a loop), You can use an ipairs loop for the comments as well as the textboxes.

Re: Hello, trying to print a text i input

Posted: Thu Dec 12, 2013 7:24 pm
by MysticPing2
I want it to print output, but output 2 (which is a stringified output) doesnt exist untill after i have filled in the text boxes, i thought i could check this every second.

Re: Hello, trying to print a text i input

Posted: Thu Dec 12, 2013 7:45 pm
by veethree
MysticPing2 wrote:I want it to print output, but output 2 (which is a stringified output) doesnt exist untill after i have filled in the text boxes, i thought i could check this every second.
You can print numbers directly, So there's no need for the output2 variable. Also the getwpop function is never called, so the code in it isn't executed.

Also you put love.update() into that function, You generally don't want a functions inside of other functions.

Aside from the nested loop in love.draw, You're also setting the background color multiple times every frame (inside of the comments loop), You generally don't need to do that unless the backgroundcolor is changed on runtime, If it's not just put that into love.load()

Another thing is you usually want to make any variables inside a function that aren't used anywhere outside of it local, More information on that here.

I fixed up alot of those things, You can compare it to your original code to see what exactly i did. I did remove love.update completely as it wasn't necessary, And i set it up so getwpop() is called when you press space, note that will cause a crash if you haven't filled in the textboxes, or filled them in with letters instead of numbers.

Re: Hello, trying to print a text i input

Posted: Thu Dec 12, 2013 8:15 pm
by MysticPing2
My post didnt get posted, AGAIN but thanks, althou i cant export it for some tupid reason, im doing exactly as the tutorials says -.- but g2g