@name Wrain Holo Arm
@inputs G:wirelink Pod:wirelink RotateTo GoTo
@outputs 
@persist State RotatingTo GoingTo
@trigger 

runOnTick(1)

if(first()){
#Base
    holoCreate(1)
    holoModel(1,"models/hunter/tubes/circle2x2.mdl")
    holoPos(1,entity():toWorld(vec(0,0,1)))
    holoScale(1,vec(0.5,0.5,0.5))
    holoMaterial(1,"phoenix_storms/car_tire")
    
    holoCreate(5)
    holoModel(5,"models/hunter/tubes/tube4x4x1to2x2.mdl")
    holoPos(5,entity():toWorld(vec(0,0,20)))
    holoScale(5,vec(0.2,0.2,0.2))
    holoMaterial(5,"phoenix_storms/pack2/metalbox2")
    
    holoCreate(6)
    holoModel(6,"models/hunter/misc/shell2x2.mdl")
    holoPos(6,entity():toWorld(vec(0,0,20)))
    holoScale(6,vec(0.2,0.2,0.2))
    holoMaterial(6,"phoenix_storms/pack2/metalbox2")
    
    holoCreate(7)
    holoModel(7,"models/hunter/misc/shell2x2a.mdl")
    holoPos(7,entity():toWorld(vec(0,0,1.5)))
    holoScale(7,vec(0.5,0.5,0.34))
    holoMaterial(7,"phoenix_storms/car_tire")
    
#Bottem part of arm
    holoCreate(2)
    holoModel(2,"models/props_c17/signpole001.mdl")
    holoPos(2,entity():toWorld(vec(0,0,19)))
    holoScale(2,vec(2,2,0.5))
    holoMaterial(2,"sprops/textures/sprops_cfiber2")

#Joint
    holoCreate(3)
    holoModel(3,"models/hunter/misc/shell2x2.mdl")
    holoPos(3,entity():toWorld(vec(0,0,79.5)))
    holoScale(3,vec(0.15,0.15,0.15))
    holoAng(3,ang(90,90,90))
    holoMaterial(3,"phoenix_storms/pack2/metalbox2")
    
#Top part of arm
    holoCreate(4)
    holoModel(4,"models/props_c17/signpole001.mdl")
    holoPos(4,entity():toWorld(vec(0,0,85)))
    holoScale(4,vec(2,2,0.5))
    holoMaterial(4,"sprops/textures/sprops_cfiber2")
    
#Claw
    holoCreate(8)
    holoModel(8,"models/hunter/tubes/tube2x2x025d.mdl")
    holoPos(8,entity():toWorld(vec(0,0,160)))
    holoAng(8,ang(360,-90,90))
    holoScale(8,vec(0.42,0.42,0.4))
    holoMaterial(8,"phoenix_storms/pack2/interior_top")
    
    holoCreate(9)
    holoModel(9,"models/hunter/tubes/tube2x2x025d.mdl")
    holoPos(9,entity():toWorld(vec(-5,0,160)))
    holoAng(9,ang(-90,-180,180))
    holoScale(9,vec(0.42,0.42,0.4))
    holoMaterial(9,"phoenix_storms/pack2/interior_top")
    
    holoCreate(10)
    holoModel(10,"models/hunter/tubes/tube2x2x025d.mdl")
    holoPos(10,entity():toWorld(vec(5,0,160)))
    holoAng(10,ang(-90,-180,180))
    holoScale(10,vec(0.42,0.42,0.4))
    holoMaterial(10,"phoenix_storms/pack2/interior_top")
    
#Claw joint
    holoCreate(11)
    holoModel(11,"models/Combine_Helicopter/helicopter_bomb01.mdl")
    holoPos(11,entity():toWorld(vec(0,0,140)))
    holoAng(11,ang(90,0,0))
    holoScale(11,vec(0.2,0.25,0.4))
    holoMaterial(11,"phoenix_storms/pack2/metalbox2")
    
#Bones
    #Bottem
    holoCreate(12)
    holoModel(12,"spuare")
    holoPos(12,entity():toWorld(vec(0,0,20)))
    
    #Middle
    holoCreate(13)
    holoModel(13,"spuare")
    holoPos(13,entity():toWorld(vec(0,0,79.5)))
    
    #Top
    holoCreate(14)
    holoModel(14,"spuare")
    holoPos(14,entity():toWorld(vec(0,0,140)))
    
#Parenting
    holoParent(6,12)
    holoParent(2,12)
    holoParent(13,12)
    
    holoParent(14,13)
    holoParent(4,13)
    holoParent(3,13)
    
    holoParent(11,14)
    holoParent(8,14)
    holoParent(9,14)
    holoParent(10,14)
}

#Colors for bones
    holoColor(12,vec(0,0,0),0)
    holoColor(13,vec(0,0,0),0)
    holoColor(14,vec(0,0,0),0)

local Seat = Pod["Entity",entity]
local Driver = Seat:driver()
local W = Driver:keyForward()
local A = Driver:keyLeft()
local S = Driver:keyBack()
local D = Driver:keyRight()
local Mouse1 = Driver:keyAttack1()
local Mouse2 = Driver:keyAttack2()
local Space = Driver:keyJump()
local Shift = Driver:keySprint()
local Active = Driver:isPlayer()
local On = Active
local HoloEnd = holoEntity(14)
G:entity():setPos(HoloEnd:pos()+vec(0,0,0))
G:entity():setAng(HoloEnd:toWorld(ang(0,0,0)))

if (W)
{
    holoAng(13,holoEntity(13):angles()-ang(0,0,1))
}
if (S)
{
    holoAng(13,holoEntity(13):angles()+ang(0,0,1))
}
if (A)
{
    holoAng(12,holoEntity(12):angles()+ang(0,1,0))
}
if (D)
{
    holoAng(12,holoEntity(12):angles()-ang(0,1,0))
}
if (Space)
{
    holoAng(12,holoEntity(12):angles()-ang(0,0,1))
}
if (Shift)
{
    holoAng(12,holoEntity(12):angles()+ang(0,0,1))
}

#[
if (Mouse1)
{
    G["Grab",number] = 1
}
if (Mouse2)
{
    G["Grab",number] = 0
}
]#

if(first()) {
    G:entity():propFreeze(1)
    G:entity():setMass(50000)
}

#Top Bone
holoAng(14,holoEntity(14):angles()+ang(0,0,0))

#Middle Bone
holoAng(13,holoEntity(13):angles()+ang(0,0,0))

#Bottem Bone
holoAng(12,holoEntity(12):angles()+ang(0,0,0))
#[
# *** ROTATING *** #
if(RotateTo != -9999  & RotatingTo == -9999) {
    RotatingTo = round(entity():angles():pitch() + RotateTo) RotatingState = 0
}

if(RotatingTo != -9999) {
    local ActualPanning = round(holoEntity(6):angles():pitch())
    
    if((ActualPanning < RotatingTo & RotatingState == 0)) {
        holoAng(12, holoEntity(12):angles() + ang(1, 0, 0))
    }
    
    if(ActualPanning > RotatingTo | RotatingState == 1) {
        holoAng(12, holoEntity(12):angles() - ang(0, 1, 0))
    }
    
    if(ActualPanning == RotatingTo) {RotatingTo = -9999 RotatingState = 0}
}
]#

