@name DivArmShop EGP
@inputs S:wirelink Prop:entity [S1 S2 S3 S4]:entity 
@outputs User:entity Page 
@persist [Select Select2 Select3 Select4 HoloMod1 HoloMod2 HoloMod3 HoloMod4]:string 
@trigger 
interval(100)

Cursor = S:egpCursor(User)

findByClass("player")
User = findClosest(entity():pos())

if(first() | dupefinished()) {
    print(HoloMod1)
    entity():setAlpha(0)
    
    S:egpClear()
    
    S:egpBox(1,vec2(256,336),vec2(356,366))
    S:egpAlpha(1,0)
    
    S:egpText(2,"Divs Shop",vec2(256,276))
    S:egpSize(2,70)
    S:egpAlign(2,1,1)
    
    S:egpText(3,"(Press E anywhere to begin)",vec2(246,309))
    S:egpSize(3,20)
    S:egpAlign(3,1,1)
    
    function string getShipmentName(Shipment:entity) {
        return Shipment:shipmentName():replace("(Smuggled)", ""):replace("Invalid Shipment", "Out of Stock")
    }
}

Select = getShipmentName(S1)
Select2 = getShipmentName(S2)
Select3 = getShipmentName(S3)
Select4 = getShipmentName(S4)

if (changed(inrange(Cursor,S:egpPos(1)-S:egpSize(1)/2, S:egpPos(1)+S:egpSize(1)/2) & User:keyUse()) & inrange(Cursor,S:egpPos(1)-S:egpSize(1)/2, S:egpPos(1)+S:egpSize(1)/2) & User:keyUse()){
    Page = 2
}

if (Page == 2) {
    S:egpClear()
    
    S:egpRoundedBox(4,vec2(156,254),vec2(140,140))
    S:egpRoundedBox(5,vec2(156,429),vec2(140,140))
    S:egpRoundedBox(6,vec2(356,254),vec2(140,140))
    S:egpRoundedBox(7,vec2(356,429),vec2(140,140))
    
    for (Box = 4,7) {S:egpAlpha(Box,10)}
    
    S:egpText(8,Select,vec2(156,306))
    S:egpColor(8,vec(0,0,0))
    S:egpAlign(8,1,1)
    
    S:egpText(9,Select2,vec2(156,486))
    S:egpColor(9,vec(0,0,0))
    S:egpAlign(9,1,1)
    
    S:egpText(10,Select3,vec2(356,306))
    S:egpColor(10,vec(0,0,0))
    S:egpAlign(10,1,1)
    
    S:egpText(11,Select4,vec2(356,486))
    S:egpColor(11,vec(0,0,0))
    S:egpAlign(11,1,1)
    
    HoloMod1 = S1:shipmentModel()
    HoloMod2 = S2:shipmentModel()
    HoloMod3 = S3:shipmentModel()
    HoloMod4 = S4:shipmentModel()
    
    holoCreate(1)
    holoModel(1,HoloMod1)
    holoPos(1,Prop:toWorld(vec(-24,-25,1.5)))
    holoAng(1,Prop:toWorld(ang(0,-90,90)))
    
    holoCreate(2)
    holoModel(2,HoloMod2)
    holoPos(2,Prop:toWorld(vec(20,-25,1.5)))
    holoAng(2,Prop:toWorld(ang(0,-90,90)))
    
    holoCreate(3)
    holoModel(3,HoloMod3)
    holoPos(3,Prop:toWorld(vec(-24,25,1.5)))
    holoAng(3,Prop:toWorld(ang(0,-90,90)))
    
    holoCreate(4)
    holoModel(4,HoloMod4)
    holoPos(4,Prop:toWorld(vec(20,25,1.5)))
    holoAng(4,Prop:toWorld(ang(0,-90,90)))
    
    if (HoloMod1 == "models/error.mdl") {holoModel(1,"models/props_c17/streetsign004e.mdl")}
    if (HoloMod2 == "models/error.mdl") {holoModel(2,"models/props_c17/streetsign004e.mdl")}
    if (HoloMod3 == "models/error.mdl") {holoModel(3,"models/props_c17/streetsign004e.mdl")}
    if (HoloMod4 == "models/error.mdl") {holoModel(4,"models/props_c17/streetsign004e.mdl")}
} else {
    holoDelete(1)
    holoDelete(2)
    holoDelete(3)
    holoDelete(4)
}

if (changed(Page == 2) & Page == 2) {print(User:name())}
