Hello, trying to print a text i input

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Hello, trying to print a text i input

Post 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)
MysticPing2
Prole
Posts: 33
Joined: Tue Dec 10, 2013 7:08 pm

Re: Hello, trying to print a text i input

Post 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
Attachments
Tax.love
(1.82 KiB) Downloaded 67 times
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Hello, trying to print a text i input

Post 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.
Last edited by veethree on Thu Dec 12, 2013 7:24 pm, edited 1 time in total.
MysticPing2
Prole
Posts: 33
Joined: Tue Dec 10, 2013 7:08 pm

Re: Hello, trying to print a text i input

Post 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.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Hello, trying to print a text i input

Post 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.
Attachments
main.lua
(3.87 KiB) Downloaded 67 times
MysticPing2
Prole
Posts: 33
Joined: Tue Dec 10, 2013 7:08 pm

Re: Hello, trying to print a text i input

Post 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
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 2 guests