@name Weapon Documenter
@persist Stage Current:table
@inputs Scr:wirelink
runOnChat(1)

if (chatClk(owner())) {
    Chat=owner():lastSaid()
    if (Chat:sub(1,1)==".") {
        Chat=Chat:sub(2)
        if (Chat==" ")  {
            Stage=1
            Current=table()
            hint("Please state the name of the weapon.",3)
        } elseif (Stage==1) {
            Current["Name",string]=Chat
            Stage=2
            hint("Logged:  Weapon name is "+Current["Name",string],3)
            hint("Please take out the weapon and chat again.",3)
        } elseif (Stage==2) {
            Stage=3
            Current["Model",string]=owner():weapon():model()
            Current["Type",string]=owner():weapon():type()
            hint("Logged:  Weapon model is "+Current["Model",string],3)
            hint("Logged:  Weapon class is "+Current["Type",string],3)
            hint("Please state the desired EGP icon for the weapon.",3)
            Scr:egpClear()
            Scr:egpBox(3,vec2(256,256),vec2(512,512))
            Scr:egpMaterial(3,"console/title_blue")
            Scr:egpBox(1,vec2(256,256),vec2(256,256))
            Scr:egpMaterial(1,"weapons/"+Current["Type",string])
            Scr:egpText(2,"weapons/"+Current["Type",string],vec2(256,400))
            Scr:egpAlign(2,1,1)
            Scr:egpSize(2,25)
        } elseif (Stage==3) {
            if (Chat=="mad") {
                Current["Icon",string]="weapons/"+Current["Type",string]
            } else {
                Current["Icon",string]=Chat
                Scr:egpMaterial(1,Current["Icon",string])
            }
            Stage=4
            hint("Logged: Weapon icon is "+Current["Icon",string],3)
            hint("What is the most common damage for the weapon?",3)
        } elseif (Stage==4) {
                Stage=5
                Current["Damage",number]=Chat:toNumber()
                hint("Logged: Weapon damage is "+Current["Damage",number],3)
                hint("Give a brief description of the weapon.",3)
            } elseif (Stage==5) {
                Current["Description",string]=Chat
                hint("Please give the price per unit of the weapon.",3)
                Stage=6
            } elseif (Stage==6) {
            Stage=1
            Current["Price",number]=Chat:toNumber()
            hint("Done.  Now we're converting the information to _INFO format.",3)
            #Name, Model, Type, Icon, Damage, Description
            Div=";;;"
            Name=Current["Name",string]
            Model=Current["Model",string]
            Type=Current["Type",string]
            Icon=Current["Icon",string]
            Damage=Current["Damage",number]
            Description=Current["Description",string]
            Price=Current["Price",number]:toString()
            #Type;Name;Model;Damage;Icon;Description
            All=array(Type,Name,Damage,Price,Model,Icon,Description)
            print(All:concat(Div))
        
        }
    }
}

