I have been creating a basic lua stool to return the mass of a physics object when the user left clicks. Here is the code so far:
TOOL.Category = "Danilo's Tools" TOOL.Name = "Object Mass" TOOL.Command = nil TOOL.ConfigName = "" function TOOL:LeftClick(trace) if not trace.Entity then return end local physobj = trace.Entity:GetPhysicsObject() if physobj then self.Owner:PrintMessage(HUD_PRINTTALK, physobj:GetMass()) end end
Currently, upon start up of the game (fresh install, no console commands), when I use my tool for the first time I get this (blue) error in the console:
" weapons\gmod_tool\stools/mass.lua:10: attempt to call method ‘PrintMessage’ (a nil value) "
In an attempt to recitfy this problem, I ran “lua_reloadents” in the console, and now the tool works as expected! Does anyone know why this happens?
Thanks in advance,