I was wondering if it is possible using LUA to make a STOOL into a SWEP. Obviously all the variables would need to be pre-set but that is not an issue. I have had a look at the Gmod_tool code and it seems like it could be possible, but difficult.

Basically has this been done before and are there any examples?


It depends on what you want to do, do you mean you want the STOOL itself to be usable outside Sandbox? You’d be better off copying over the stool base.

Or do you want a gun that does what a certain stool do?

They’re both the same btw. A stool is a toolmode for the swep gmod_tool

I want a gun (or hands or whatever, guess the mdl determines that) that performs the same function.

For example I want a player to pick up a piece of rope and be able to use it like the rope tool but only once (like ammo in a gun).

Any help on this would be REALLY appreciated as it’s vital to what I want to do.


Could this work for a nail gun swep for example?

function SWEP:PrimaryAttack()
	local vStart = self.owner:GetShootPos() 
	local vForward = self.owner:GetAimVector()
	local trace = {}
	trace.start = vStart
	trace.endpos = vStart + (vForward * 2048)
	trace.filter = self.owner
	local tr = util.TraceLine( trace )

	if ( tr.HitWorld ) then return end
	local tr2 = {}		
		tr2.start = tr.HitPos
		tr2.endpos = trace.HitPos + (vforward * 2048)
		tr2.filter = { self.owner, tr.Entity }
		local trTwo = util.TraceLine( tr2 )
		if ( trTwo.Hit && !trTwo.Entity:IsPlayer() ) then
			local constraint, nail = MakeNail( trace.Entity, trTwo.Entity, trace.PhysicsBone, trTwo.PhysicsBone, 0, vstart, vforward )