Weird behaviour from GraphicsContext.button

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Weird behaviour from GraphicsContext.button

Post by minmay »

I'm making a custom skill system, and I'm noticing some very weird behaviour from the GraphicsContext.button() method. Specifically, the button's position seems to be offset up and to the right. For example, if I have the following code:

Code: Select all

context.drawRect(300,300,50,50)
if context.button("rectButton",300,300,50,50) then
  print("pressed")
end
clicking on the rectangle does nothing. To hit the button, I have to click about 100 pixels to the right and 50 pixels up. This behaviour doesn't change when I'm actually drawing inside the skills area, either. If I put this code in onDrawGui, it works as expected and puts the button directly over the rectangle.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply