Jump to content




Button Acts Differently Each Time It's Run


  • You cannot reply to this topic
4 replies to this topic

#1 OReezy

  • Members
  • 91 posts

Posted 05 February 2014 - 07:00 PM

I wrote up a quick button program to test how I wanted to implement it in my main program and it is acting oddly. The first time I run the program it prints the button in the wrong position. The second time it prints the button in the correct position.

The code http://pastebin.com/tq75PA7H
Spoiler


And here is a picture for clarification. The red button is where it prints the first time the program is run. The second time it prints where the green button is and continues working after that. I have also tried it with different sized screens and it prints in the wrong position the first time no matter what the size. Also, the button changes color correctly no matter which position it is in.

Spoiler


#2 Kashin

  • Members
  • 9 posts

Posted 05 February 2014 - 08:15 PM

Hi there OReezy.

The reason your program is failing is because you change the textScale after having retrieved the size.

Try
m.setTextScale(.5)

before you run
local monx, mony = m.getSize()

So you should end up with something like this
Spoiler

Let me know if it works for you :)

#3 OReezy

  • Members
  • 91 posts

Posted 05 February 2014 - 08:45 PM

facepalm. Thanks, I knew i had to be doing something dumb somewhere.

#4 Kashin

  • Members
  • 9 posts

Posted 05 February 2014 - 09:27 PM

You're quite welcome :)

Good luck with your program!

#5 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 05 February 2014 - 11:10 PM

View PostOReezy, on 05 February 2014 - 08:45 PM, said:

facepalm. Thanks, I knew i had to be doing something dumb somewhere.

We've all been there, OReezy.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users