Hey, I'm trying to make a entity run a console command when you press E on it...
init.lua
[code]function ENT:Initialize( )
self:SetModel( "models/props_lab/monitor01a.mdl" )
self:SetSolid( SOLID_BBOX )
self:SetUseType( SIMPLE_USE )
end
function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
RunConsoleCommand("pweb")
end
end[/code]
cl_init.lua
[code]
include('shared.lua')
ENT.RenderGroup = RENDERGROUP_OPAQUE
/*---------------------------------------------------------
Name: Draw
Desc: Draw it!
---------------------------------------------------------*/
function ENT:Draw()
self.Entity:DrawModel()
end[/code]
shared.lua
[code]
ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "Computer"
ENT.Author = "Polar"
ENT.Contact = "http://www.fusion-gaming.org"
ENT.Spawnable = false
ENT.AdminSpawnable = true
AddCSLuaFile( "shared.lua" )
/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()
end
function ENT:Use( activator, caller )
if CLIENT then return end
if ( activator:IsPlayer() ) then
RunConsoleCommand("pweb")
end
end
[/code]
Error...
[code]
[lua\vgui\dimage.lua:63] Material missing: VGUI/entities/polar_computer
[/code]
Any help would be fantastic!
Can you show us your dimage.lua code? Also, make sure polar_computer is added with resource.AddFile(). Also, use [lua][./lua] tags, without the . of course.
-snip-
\/
That's not a lua error from your code. It just means you have not setup an icon for it in the spawnmenu.
[QUOTE=Crazy Quebec;24844672]That's not a lua error from your code. It just means you have not setup an icon for it in the spawnmenu.[/QUOTE]
Ah, well.
Then it just doesn't spawn, any ideas why?
Try spawning it with ent_create.
To spawn it using the spawnmenu you'll need to add a spawn function to it.
[url]http://wiki.garrysmod.com/?title=Entity.SpawnFunction[/url]
[QUOTE=Crazy Quebec;24845158]Try spawning it with ent_create.
To spawn it using the spawnmenu you'll need to add a spawn function to it.
[url]http://wiki.garrysmod.com/?title=Entity.SpawnFunction[/url][/QUOTE]
Cool, Many thanks!
Sorry, you need to Log In to post a reply to this thread.