summaryrefslogtreecommitdiff
path: root/data/artery/global/sv_dupboat.lua
blob: df613f639b004f572a213cb863967b1a18cfb1cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if not nrequire then return end
duplicator.Allow("prop_physics")

local dups = {}

local function copyplayer(ply,cmd,args)
	local tr = util.TraceLine({
		start = ply:GetPos(),
		endpos = ply:GetPos() + Vector(0,0,-100),
	})
	local ent = tr.Entity
	print('Ent is', ent)
	duplicator.SetLocalPos( ply:GetPos()) 
	local dup = duplicator.Copy(ent)
	duplicator.SetLocalPos(Vector(0,0,0))
	print("After normalizing, dup was")
	PrintTable(dup)
	dups[args[1]] = dup
	print("saved boat as", args[1])
end

local function pasteplayer(ply,cmd,args)
	print("Pasteing ", args[1])
	local dup = dups[args[1]]
	print("Before setting up under player, dup is")
	PrintTable(dup)
	for k,v in pairs(dup.Entities) do
		v.Pos = v.Pos + ply:GetPos()
	end
	print("After setting up under player, dup is")
	PrintTable(dup)
	duplicator.SetLocalPos( ply:GetPos()) 
	duplicator.Paste(ply,dup.Entities, dup.Constraints)
	duplicator.SetLocalPos(Vector(0,0,0))
end

concommand.Add("artery_copyboat",copyplayer)
concommand.Add("artery_pasteboat",pasteplayer)