1

I'm trying to create something in a game called Garry's Mod that uses Lua for addons.

Basically I need to check if the player's cursor has entered a specific area.

if _hitentity:GetClass() == "treasury" then
        draw.RoundedBox(0, 0, 0, 60, 20, Color(255,255,255,255))
        if _hitpos == Vector(self:LocalToWorld(Vector(33, -6, 30)), self:LocalToWorldAngles(Angle(0,90,90))) then
            draw.RoundedBox(0, 0, 60, 20, 20, Color(0,0,0,255))
        end
    end

So I've basically got that, I check where the player's hitpos is (where he's looking) and hitentity (the entity he's looking at) and I need to check if he's looking at draw.RoundedBox.

Problem I'm having is I don't know how I could check if the cursor is inside a graphical box that is displayed on an entity.

This is the white box I need to check if the players hitpos has entered

image

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Alana Stephens
  • 109
  • 1
  • 1
  • 8
  • Do you get the raw world coordinate or the coordinate in model space of the entity you're looking at? Expand on that. – Bartek Banachewicz Nov 21 '14 at 11:55
  • What is the line where you compare hitpos to a point (Vector), is it how you are currently trying to determine if hitpoint is box? That cant work, where are you getting those numbers 33, -3, 30 from? – Oliver Nov 23 '14 at 14:51

1 Answers1

-1

This may be late to the Party but I can only recommend the usage of the imgui library It really makes the creation of buttons and displays easy.

If you don't want to use it, you can check how he did it.

Luiggi33
  • 21
  • 3