Good way for "calculating" prop "modules"

Hello facepunch, I wanted to ask, if theres a good/easy way, to calculate prop “modules” as seen in some darkrp printer addons (sharprinter etc)

like here:

http://images.akamai.steamusercontent.com/ugc/269471549701583720/80CF1A350B594D548265F4240D74FB4E8CCB5ABD/

I basically want to do that too, but when I look at that code, I dont understand how they “possibly” calculate that…



function ENT:Initialize()
	self.PrinterProcessor = ents.CreateClientProp()
	self.PrinterProcessor:SetPos( self:GetPos() + self:GetAngles():Right() * 3.5 + self:GetAngles():Forward() * 10.6 + self:GetAngles():Up() * 3.7 )
	self.PrinterProcessor:SetModel( "models/props_lab/reciever01a.mdl" )
	self.PrinterProcessor:SetAngles(self:GetAngles())
	self.PrinterProcessor:SetRenderMode( RENDERMODE_TRANSALPHA )
	self.PrinterProcessor:SetParent( self )
	self.PrinterProcessor:Spawn()

	self.PrinterRAM = ents.CreateClientProp()
	self.PrinterRAM:SetPos( self:GetPos() + self:GetAngles():Right() * -10 + self:GetAngles():Forward() * 15 + self:GetAngles():Up() * .5 )
	self.PrinterRAM:SetModel( "models/Items/battery.mdl" )
	self.PrinterRAM:SetAngles(self:GetAngles())
	self.PrinterRAM:SetRenderMode( RENDERMODE_TRANSALPHA )
	self.PrinterRAM:SetParent( self )
	self.PrinterRAM:Spawn()

	self.PrinterRAM2 = ents.CreateClientProp()
	self.PrinterRAM2:SetPos( self:GetPos() + self:GetAngles():Right() * -13.4 + self:GetAngles():Forward() * 15 + self:GetAngles():Up() * .5 )
	self.PrinterRAM2:SetModel( "models/Items/battery.mdl" )
	self.PrinterRAM2:SetAngles(self:GetAngles())
	self.PrinterRAM2:SetRenderMode( RENDERMODE_TRANSALPHA )
	self.PrinterRAM2:SetParent( self )
	self.PrinterRAM2:Spawn()
end


I hope you can help me with this small problem quick, thanks!

Well, this is all done client side, so, what I recommend is this:

Create a file in lua/autorun/client/ (e.g. lua/autorun/client/modules.lua)

Inside that file, put a hook for a concommand or a key so that when you press it, it will run the code,

then copy and paste the code you have there and keep changing the values until things line up where you want them to be.

Once you’ve done that, you can take the code and put it into the ENT:Initialize function for your own entity

You can always just guess and check. Change the code, save it, and spawn one and see what changed.


self.PrinterProcessor:SetPos( self:GetPos() + self:GetAngles():Right() * 3.5 + self:GetAngles():Forward() * 10.6 + self:GetAngles():Up() * 3.7 )

It is right there. SetPos sets the position, and inside is the code to calculate that. Open up the wiki, check the functions and you will understand.

I know how to code it, the only problem I have is to get the actual calculation for specific props. How the fuck should you know its *10.6 or *3.7?

You dont. You just keep quessing.

You can use the prop’s OBBMins and OBBMaxs