How Can I Make An Entity That Has An Interface On It?

Basically I know how to make an entity and such I just want to know what do I code to make it so when I hit e on the entity it will show a HUD or an nicer version of a derma panel.

[lua]
util.AddNetworkString(“OpenMyMenu”)

ENT:OnUse(act)
net.Start(“OpenMyMenu”)
net.Send(act)
end

net.Receive(“OpenMyMenu”,function()
vgui.Create(“MyMenu”)
end)
[/lua]

Ok but does the actually create a menu on screen and if so how would I modify size and color and add rounded boxes and text or stuff like that. By the way i’m new to coding so go easy on me. Also, would that go into shared, cl_init, or init?

I’m still confused tho… I don’t really understand where to put it and what to do with it.

Do you know how to create interfaces right?

Ehh not really again i’m new to this i’m just asking for a little help.

[editline]27th November 2016[/editline]

I’m somewhat good with derma but I don’t really want a derma panel to show up I want a menu with draw.RoundedBox and draw.SimpleText.

You can still do that with derma. The controls will contain the position, size, contents, etc, and you do all of your drawing in the Paint function.

PANEL:Paint

Oh ok all I need know now is how to get it to pop up when I hit e on the entity I created.

Yes I see that but I don’t know where to put that in my code. Here it is. Oh and yes I am using cam2d3d and yes it looks weird don’t worry about that I know it’s shit.

cl_init.lua


include("shared.lua")
surface.CreateFont( "TestFont", {
	font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
	extended = false,
	size = 60,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = true,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = false,
	additive = false,
	outline = false,
} )

function ENT:Draw()

	self:DrawModel()

	local ang = self:GetAngles()

	ang:RotateAroundAxis(self:GetAngles():Right(),0)
	ang:RotateAroundAxis(self:GetAngles():Forward(),0)
	ang:RotateAroundAxis(self:GetAngles():Up(),0)

	cam.Start3D2D(self:GetPos()+Vector(0,0,0) , ang , 0.1)

		draw.RoundedBox(0,0,0,1000,1000,Color(70, 81, 92))

		draw.RoundedBox(0,50,50,1000-100,1000-100,Color(0, 0, 0, 200))

		draw.SimpleText("3D2D Display Test","TestFont",500,500,Color(240,240,240),1,1)

	cam.End3D2D()

end

init.lua


AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()

	self:SetModel("models/props_wasteland/controlroom_desk001b.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)

	local phys = self:GetPhysicsObject()

	if phys:IsValid() then

		phys:Wake()

	end


end

shared.lua


ENT.Type = "anim"
ENT.Base = "base_gmodentity"

ENT.PrintName = "Cam3D2D Test"

ENT.Spawnable = true

[editline]27th November 2016[/editline]

Also, everytime I try to use OnUse, it says it’s a nil value.

I don’t see OnUse in your code, can you post all of it?

Oh my bad I added the OnUse code after I posted that hold on lemme fix it. Ok everything is the same except the cl_init.lua.


include("shared.lua")
surface.CreateFont( "TestFont", {
	font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
	extended = false,
	size = 60,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = true,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = false,
	additive = false,
	outline = false,
} )

util.AddNetworkString("OpenMyMenu")

ENT:OnUse(act)
    net.Start("OpenMyMenu")
    net.Send(act)
end

net.Receive("OpenMyMenu",function()
    vgui.Create("MyMenu")
end)

function ENT:Draw()

	self:DrawModel()

	local ang = self:GetAngles()

	ang:RotateAroundAxis(self:GetAngles():Right(),0)
	ang:RotateAroundAxis(self:GetAngles():Forward(),0)
	ang:RotateAroundAxis(self:GetAngles():Up(),90)

	cam.Start3D2D(self:GetPos()+Vector(25,-45.5,17) , ang , 0.1)

		draw.RoundedBox(0,0,0,1000,280,Color(240, 240, 240))

		draw.SimpleText("3D2D Display Test","TestFont",500,500,Color(0,0,0),1,1)

	cam.End3D2D()

end

you forgot function ENT:OnUse
not ENT:OnUse()

Wait so what would the code look like then?

You did this

ENT:OnUse(act)

You are missing the function there

function ENT:OnUse(act)

Ok so now my console says this:


[ERROR] lua/entities/test_display/cl_init.lua:20: attempt to call field 'AddNetworkString' (a nil value)
  1. unknown - lua/entities/test_display/cl_init.lua:20

[editline]27th November 2016[/editline]

I tried adding function and it says this:



[ERROR] lua/entities/test_display/cl_init.lua:20: <name> or '...' expected near '"OpenMyMenu"'
  1. unknown - lua/entities/test_display/cl_init.lua:0

networkstring and function ent:onuse should be on the server, not on the client.

use

ENT:AcceptInput or

ENT:Use instead of function ent:onuse as im p sure onuse does not exist.

Ok so I have ENT:Use now and moved them to the server but I hit e and nothing happens still?

[editline]27th November 2016[/editline]

Anyone?