Player (12)
Joined: 9/14/2022
Posts: 5
Hi all, I'm trying to make a simple GUI using multiple PictureBoxes, but I'm confused about how they're supposed to work. I can't tell if I've found a bug in the Lua wrappers or I just don't understand their implementation. Suppose I have code like this:
Language: lua

local main_form = forms.newform(100, 300) local box1 = forms.pictureBox(main_form, 0, 0, 100, 100) -- This draws in box1 as expected forms.drawText(box1, 0, 0, '1') local box2 = forms.pictureBox(main_form, 0, 100, 100, 100) -- I only want to draw in box2 here, but it draws in both box1 and box2 forms.drawText(box2, 20, 0, '2') local box3 = forms.pictureBox(main_form, 0, 200, 100, 100) -- And now it draws in box1, box2 and box3 forms.drawText(box3, 40, 0, '3') -- Even with an invalid handle, it draws in box1, box2 and box3 forms.drawText(0, 60, 0, '4')
It seems that drawText() (as well as drawImage(), drawRectangle(), clear(), etc.) will always draw in all PictureBox instances in existence when it's called. I even tried associating the PictureBoxes with separate parent forms, but it didn't make a difference. Is this intentional? Is there any way to have two PictureBoxes that can be drawn in independently?
tom_mai78101
He/Him
Player (127)
Joined: 3/16/2015
Posts: 160
I haven't dabbled too deeply in this. In your code, it seems you are adding new picture boxes to the same form, and thus you are stacking the forms together. What if you add new picture boxes to different forms?
Player (12)
Joined: 9/14/2022
Posts: 5
tom_mai78101 wrote:
I haven't dabbled too deeply in this. In your code, it seems you are adding new picture boxes to the same form, and thus you are stacking the forms together. What if you add new picture boxes to different forms?
Like this?
Language: lua

local form1 = forms.newform(100, 300) local box1 = forms.pictureBox(form1, 0, 0, 100, 100) -- draws on box1 forms.drawText(box1, 0, 0, '1') local form2 = forms.newform(100, 300) local box2 = forms.pictureBox(form2, 0, 100, 100, 100) -- draws on box1 & box2 forms.drawText(box2, 20, 0, '2')
It still draws on both PictureBoxes.
Editor, Player (175)
Joined: 4/7/2015
Posts: 331
Location: Porto Alegre, RS, Brazil
I have to exact same issue in my Yoshi's Island utility script, my workaround was forcing frameadvance between each drawing to force it to "wait" a little, it's definitely a picturebox bug.
Games are basically math with a visual representation of this math, that's why I make the scripts, to re-see games as math. My things: YouTube, GitHub, Pastebin, Twitter
tom_mai78101
He/Him
Player (127)
Joined: 3/16/2015
Posts: 160
brunovalads wrote:
it's definitely a picturebox bug.
Has it been reported on Github?
Editor, Player (175)
Joined: 4/7/2015
Posts: 331
Location: Porto Alegre, RS, Brazil
tom_mai78101 wrote:
Has it been reported on Github?
Nope, mind opening one?
Games are basically math with a visual representation of this math, that's why I make the scripts, to re-see games as math. My things: YouTube, GitHub, Pastebin, Twitter
tom_mai78101
He/Him
Player (127)
Joined: 3/16/2015
Posts: 160
brunovalads wrote:
tom_mai78101 wrote:
Has it been reported on Github?
Nope, mind opening one?
I'm not that knowledgeable on this. In my opinion, the author should be the one to post the issue on Github.
Editor, Player (175)
Joined: 4/7/2015
Posts: 331
Location: Porto Alegre, RS, Brazil
I took the initiative to open this issue.
Games are basically math with a visual representation of this math, that's why I make the scripts, to re-see games as math. My things: YouTube, GitHub, Pastebin, Twitter