Home Showcase
Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!

Derma Target Finder

KatelynKatelyn Registered, Administrator Posts: 171
edited August 2011 in Showcase #1
Current version: 3.0.0.0
This is the BA Derma Target Finder V2 by me. It allows you to target by class, and sort by owner fast and lag free. It features optional wiring to a seat, saving and removing from a list of classes that load when you spawn the chip, and lots of output data. If you're good with Derma you can even add onto it pretty easy.

How to use:
The top drop down menu is a list of classes. Below that is a text box that you can add or remove classes to the list above. It saves automatically when you add. Below that is the Owner drop down list, and below that is the Entity list that you target.
@name BA Derma Target finder V2
@inputs Apc:wirelink
@outputs Vec:vector Debug
@outputs Ent:entity 
@outputs X Y Z
@outputs Ang:angle
@outputs [Owner, Type, Model]:string
@persist [List, Targets, Listbox, Parr, Master, Default]:array
@persist [Player, Tarr, Aarr, Cfgt]:table
@persist Width Height Count Start
@persist [Pos, Size]:vector2
@persist [Cfg, Targetlist]:string
interval(200)
#By Katelyn

if (first() | dupefinished()) 
{
    runOnFile(1)

    Cfg = "KateKollection/DermaTargetFinderv2/cfg.txt"
    Targets[1, string] = "player"
    Targets[2, string] = "gmod_wire_expression2"
    Targets[3, string] = "resource_node"
    Targets[4, string] = "ship_core*"
    Targets[5, string] = "gyropod_advanced"
    Targets[6, string] = "prop_physics"
    Targets[7, string] = "generator_*"
    
    Cfgt["First", number] = 0
    
    Default = array(glonEncode(Targets), glonEncode(Cfgt))
    Targets:clear()
    Cfgt:clear()
    
    
    
    Width = 150
    Height = 140
    
    
    Pos = vec2(scrW() - Width, 0)
    Size = vec2(Width, Height)
        
    dPod(Apc["Entity", entity])
    dPanel("Targets", Pos, Size)
#    dTabHolder("Tabs", "Targets", vec2(0,0), vec2(Width, 24))
#    dTab("Find", "Tabs")
#    dTab("Options", "Tabs")
    dDropBox("Targetselect", "Targets", vec2(0, 25), Width)
    dTextBox("Label", "Targets", vec2(0, 50), Width)
    dText("Label","")
    dButton("Save", "Targets", vec2(2, 70), vec2((Width / 2) - 4, 20))
    dButton("Del", "Targets", vec2((Width / 2) + 2, 70), vec2((Width / 2) - 4, 20))
    dDropBox("Player", "Targets", vec2(0, 98), Width)
    dDropBox("Target", "Targets", vec2(0, 120), Width)

    dShow("Targets", 0)
    
    
    dRunOnChange("Targetselect", 1)
    dRunOnChange("Target", 1)
    dRunOnChange("Player", 1)

    if (fileCanLoad())
    {
        fileLoad(Cfg)
    }
    else
    {
        print("Config file can not be loaded at this time.")
        Master = Default:clone()
        print("Target finder is now ready for operation")
        dShow("Targets", 1)
    }
    
    
}



if (fileClk(Cfg))
{
    if (fileStatus() != _FILE_OK)
    {        
        Master = Default
        
        fileWrite(Cfg, glonEncode(Master))
        print("Configuration file not found, creating one with default settings.")
    }
    else
    {
        Master = glonDecode(fileRead())
        
        print("Configuration file loaded correctly!")
        
    }
    Targets = glonDecode(Master[1, string])
    Cfgt = glonDecodeTable(Master[2, string])
    
    dArray("Targetselect", Targets)
    print("Target finder is now ready for operation")
    dShow("Targets", 1)
}





Count = numPlayers()
#findExcludePlayer(owner())
findExcludeClass("Ship_Core_Base")
#findExcludePlayerProps(owner())

#Changing target type
if (dClk("Targetselect") | ~Count) 
{
    findByClass(dSval("Targetselect"))
    List = findToArray()
    Listbox:clear()
    Player:clear()
    if (dSval("Targetselect") == "player")
    {
        I = 1
        while (I <= List:count() & perf()) 
        {
            if (List[I, entity]:isPlayer())
            {
                Tarr[List[I, entity]:name(), entity] = List[I, entity]
                Player[List[I, entity]:name(), table] = Tarr
            }
            I++
        }
    }
    else
    {
        I = 1
        while (I <= List:count() & perf()) 
        {
            if (List[I, entity]:owner():isPlayer())
            {
                Temp = Player[List[I, entity]:owner():name(), table]
                M = List[I, entity]:model():explode("/")
                Mtemp = M[M:count(), string]:explode(".mdl")
                Temp["[" + List[I, entity]:id():toString() + "] " + Mtemp[1, string], entity] = List[I, entity]
                Player[List[I, entity]:owner():name(), table] = Temp
            }
            I++
        }
    }
    Parr = Player:keys()
    dSetSval("Player", Parr[1, string])
    
    Aarr = Player[dSval("Player"), table]:clone()
    dSetSval("Target", Aarr:keys()[1, string])
    dArray("Player", Parr)
    dArray("Target", Aarr:keys())
}
if (dClk("Player"))
{
    Aarr = Player[dSval("Player"), table]:clone()

    dArray("Target", Aarr:keys())
    dSetSval("Target", Aarr:keys()[1, string])
    Listbox:clear()

}
if (dClk("Save") & dSval("Label") != "")
{
    for (I=1, Targets:count())
    {
        A = 0
        if (Targets[I, string]:find(dSval("Label")))
        {
            A++
        }
    }
    if (A == 1)
    {
        print("Entry already exists or is a partial phrase in another entry.")
    }
    else
    {
        Targets:pushString(dSval("Label"))
        print("Query saved")

        Master = array(glonEncode(Targets), glonEncode(Cfgt))
        
        fileWrite(Cfg, glonEncode(Master))
        dSetSval("Label", "") 
    }
    dArray("Targetselect", Targets)
    
}
if (dClk("Del") & dSval("Label") != "")
{
    A = 0
    B = 0
    for (I=1, Targets:count())
    {
        if (Targets[I, string]:find(dSval("Label")))
        {
            A++
            B = I
        }
    }
    if (A == 1)
    {
        if (dSval("Targetselect") == Targets[B, string])
        {
            dSetSval("Targetselect", "")  
        }
        Targets:remove(B)
        print("Removed entry")
        fileWrite(Targetlist, glonEncode(Targets))
        dSetSval("Label", "") 
    }
    elseif (A >= 2)
    {
        print("More than one entry detected.")
    }
    else
    {
        print("No entries match query")
    }
    dArray("Targetselect", Targets)
}

#Outputting data
Ent = Aarr[dSval("Target"), entity]
Vec = Ent:pos()
X = Vec:x()
Y = Vec:y()
Z = Vec:z()
Ang = Ent:angles()
Owner = Ent:owner():name()
Type = Ent:type()
Model = Ent:model()

Comments

  • Alex4921Alex4921 Registered Posts: 139
    Also to mention,when you select player as target the "Owner" box shows everyone,apparently everybody is owned by everybody and you DO NOT need to select the "Owner" of the player as well as the player target in order to target him,it will still target the target player regardless of owner selected.
    The quieter you are,the more you are able to hear.
  • NormallyClosedSwitchNormallyClosedSwitch Registered Posts: 137
    Thank you very very much katelyn, you'r like a genius or something

    I'm not on the server often these days but my mind is still building ships, and that is the corner stone of my futur ships.

    Thank you again, you are amazing
    "...wait, this IS rocket science!!!"
  • Paper ClipPaper Clip Registered, Moderator, Administrator Posts: 87
    You should consider posting your chips on the wiremod contraption forum as well kate!
  • KatelynKatelyn Registered, Administrator Posts: 171
    Why? I never go there.
  • DaraconDaracon Registered Posts: 41
    We need to get factions off the ground again, get a list somewhere and have it intergrated into the chip, maybe have it do checks like mouldys resourcechip to make sure it's members directory is upto date.
  • KatelynKatelyn Registered, Administrator Posts: 171
    Apparently, something broke it, so I am going to remake it from scratch. Any ideas?
  • Alex4921Alex4921 Registered Posts: 139
    Katelyn wrote:
    Apparently, something broke it, so I am going to remake it from scratch. Any ideas?
    I spammed you yesterday with ideas but i'm gonna make a list.

    Atmosphere detection with a warning like "YOU ARE TARGETING SPAWN" if you target a ship that happens to be on the spawn planet.
    Grabbing E2 names for the E2 targeting
    Priority list option in the targeting that orders everyone's ship cored ships in order of how many weapons/danger level they have.
    Im sure i had more but that's all I can remember for the moment.
    The quieter you are,the more you are able to hear.
  • KatelynKatelyn Registered, Administrator Posts: 171
    The problem with those ideas are that they are extensions of a target finder. This is simply a target finder. I'm going to code it with a buttload of comments so that it is easier to mod for you guys.
  • KatelynKatelyn Registered, Administrator Posts: 171
    It is looking good so far. I've added an Options tab, because I spent the time actually figuring out why I couldn't get tabs to work last time. So now it is going to look like how I was originally going to release it. I will use hard coded chat commands instead of my custom command system as it is more taxing, and I want this to be as light as I can make it.
  • SandersSanders Registered Posts: 1
    This probably doesn't even affect you anymore, but I think I found what broke your Derma Target Finder. While taking it apart for integrating into my hud (I sincerely hope you dont mind) I learned that a bug in the derma extension seems to have broken the "Player" drop box. If you change the name of the dropbox (in my case, I changed it to "Zlayer") and properly change the name of everything that references it as well it works again. It might be related to the fact that you have another variable named "Player", but I don't know.

    For all I know, you might have already figured this out since the last post was a long time ago but, if you haven't, there you go.
    @name BA Derma Target finder V2 - 1
    @inputs Apc:wirelink
    @outputs Vec:vector Debug
    @outputs Ent:entity
    @outputs X Y Z
    @outputs Ang:angle
    @outputs [Owner, Type, Model]:string
    @persist [List, Targets, Listbox, Parr, Master, Default]:array
    @persist [Player, Tarr, Aarr, Cfgt]:table
    @persist Width Height Count Start
    @persist [Pos, Size]:vector2
    @persist [Cfg, Targetlist]:string
    interval(200)
    #By Katelyn
    
    if (first() | dupefinished())
    {
        runOnFile(1)
    
        Cfg = "KateKollection/DermaTargetFinderv2/cfg.txt"
        Targets[1, string] = "player"
        Targets[2, string] = "gmod_wire_expression2"
        Targets[3, string] = "resource_node"
        Targets[4, string] = "ship_core*"
        Targets[5, string] = "gyropod_advanced"
        Targets[6, string] = "prop_physics"
        Targets[7, string] = "generator_*"
       
        Cfgt["First", number] = 0
       
        Default = array(glonEncode(Targets), glonEncode(Cfgt))
        Targets:clear()
        Cfgt:clear()
       
       
       
        Width = 150
        Height = 140
       
       
        Pos = vec2(scrW() - Width, 0)
        Size = vec2(Width, Height)
           
        dPod(Apc["Entity", entity])
        dPanel("Targets", Pos, Size)
    #    dTabHolder("Tabs", "Targets", vec2(0,0), vec2(Width, 24))
    #    dTab("Find", "Tabs")
    #    dTab("Options", "Tabs")
        dDropBox("Targetselect", "Targets", vec2(0, 25), Width)
        dTextBox("Label", "Targets", vec2(0, 50), Width)
        dText("Label","")
        dButton("Save", "Targets", vec2(2, 70), vec2((Width / 2) - 4, 20))
        dButton("Del", "Targets", vec2((Width / 2) + 2, 70), vec2((Width / 2) - 4, 20))
        dDropBox("Zlayer", "Targets", vec2(0, 98), Width)
        dDropBox("Target", "Targets", vec2(0, 120), Width)
    
        dShow("Targets", 0)
       
       
        dRunOnChange("Targetselect", 1)
        dRunOnChange("Target", 1)
        dRunOnChange("Zlayer", 1)
    
        if (fileCanLoad())
        {
            fileLoad(Cfg)
        }
        else
        {
            print("Config file can not be loaded at this time.")
            Master = Default:clone()
            print("Target finder is now ready for operation")
            dShow("Targets", 1)
        }
       
       
    }
    
    
    
    if (fileClk(Cfg))
    {
        if (fileStatus() != _FILE_OK)
        {       
            Master = Default
           
            fileWrite(Cfg, glonEncode(Master))
            print("Configuration file not found, creating one with default settings.")
        }
        else
        {
            Master = glonDecode(fileRead())
           
            print("Configuration file loaded correctly!")
           
        }
        Targets = glonDecode(Master[1, string])
        Cfgt = glonDecodeTable(Master[2, string])
       
        dArray("Targetselect", Targets)
        print("Target finder is now ready for operation")
        dShow("Targets", 1)
    }
    
    
    
    
    
    Count = numPlayers()
    #findExcludePlayer(owner())
    findExcludeClass("Ship_Core_Base")
    #findExcludePlayerProps(owner())
    
    #Changing target type
    if (dClk("Targetselect") | ~Count)
    {
        findByClass(dSval("Targetselect"))
        List = findToArray()
        Listbox:clear()
        Player:clear()
        if (dSval("Targetselect") == "player")
        {
            I = 1
            while (I <= List:count() & perf())
            {
                if (List[I, entity]:isPlayer())
                {
                    Tarr[List[I, entity]:name(), entity] = List[I, entity]
                    Player[List[I, entity]:name(), table] = Tarr
                }
                I++
            }
        }
        else
        {
            I = 1
            while (I <= List:count() & perf())
            {
                if (List[I, entity]:owner():isPlayer())
                {
                    Temp = Player[List[I, entity]:owner():name(), table]
                    M = List[I, entity]:model():explode("/")
                    Mtemp = M[M:count(), string]:explode(".mdl")
                    Temp["[" + List[I, entity]:id():toString() + "] " + Mtemp[1, string], entity] = List[I, entity]
                    Player[List[I, entity]:owner():name(), table] = Temp
                }
                I++
            }
        }
        Parr = Player:keys()
        dSetSval("Zlayer", Parr[1, string])
       
        Aarr = Player[dSval("Player"), table]:clone()
        dSetSval("Target", Aarr:keys()[1, string])
        dArray("Zlayer", Parr)
        dArray("Target", Aarr:keys())
    }
    if (dClk("Zlayer"))
    {
        Aarr = Player[dSval("Zlayer"), table]:clone()
    
        dArray("Target", Aarr:keys())
        dSetSval("Target", Aarr:keys()[1, string])
        Listbox:clear()
    
    }
    if (dClk("Save") & dSval("Label") != "")
    {
        for (I=1, Targets:count())
        {
            A = 0
            if (Targets[I, string]:find(dSval("Label")))
            {
                A++
            }
        }
        if (A == 1)
        {
            print("Entry already exists or is a partial phrase in another entry.")
        }
        else
        {
            Targets:pushString(dSval("Label"))
            print("Query saved")
    
            Master = array(glonEncode(Targets), glonEncode(Cfgt))
           
            fileWrite(Cfg, glonEncode(Master))
            dSetSval("Label", "")
        }
        dArray("Targetselect", Targets)
       
    }
    if (dClk("Del") & dSval("Label") != "")
    {
        A = 0
        B = 0
        for (I=1, Targets:count())
        {
            if (Targets[I, string]:find(dSval("Label")))
            {
                A++
                B = I
            }
        }
        if (A == 1)
        {
            if (dSval("Targetselect") == Targets[B, string])
            {
                dSetSval("Targetselect", "") 
            }
            Targets:remove(B)
            print("Removed entry")
            fileWrite(Targetlist, glonEncode(Targets))
            dSetSval("Label", "")
        }
        elseif (A >= 2)
        {
            print("More than one entry detected.")
        }
        else
        {
            print("No entries match query")
        }
        dArray("Targetselect", Targets)
    }
    
    #Outputting data
    Ent = Aarr[dSval("Target"), entity]
    Vec = Ent:pos()
    X = Vec:x()
    Y = Vec:y()
    Z = Vec:z()
    Ang = Ent:angles()
    Owner = Ent:owner():name()
    Type = Ent:type()
    Model = Ent:model()
    


    P.S. I hate your variable names :(
  • Lambda217Lambda217 Registered, Moderator Posts: 534
    Also, you could try removing the "dupefinished()" bit, cause I believe that's constantly true after duping is finished, making the E2 constantly start itself.


    "I want you to show this world what it means to fear the sky."
  • KatelynKatelyn Registered, Administrator Posts: 171
    This is an old chip, and I actually never figured the bug out that was causing this. I don't mind what anyone does with my E2s, so thanks for figuring out that enigma!

    P.S. My variable names hate you too! :P
  • LtBrandonLtBrandon Registered, Administrator Posts: 507
    Am I the only one that likes Kate's variable names? :lol:
    This is a block of text that can be added to posts you make. There is a 255 character limit.

    Lλmbdλ: donations for coding the space future of diaspora :>

    Get your extra long EVE trial here!
  • SteeveeoSteeveeo Registered, Administrator Posts: 849
    Lambda217 wrote:
    Also, you could try removing the "dupefinished()" bit, cause I believe that's constantly true after duping is finished, making the E2 constantly start itself.
    It's not, that's a ClkCheck function. Advanced Duplicator will run any E2 chips it placed when the contraption is finished pasting, and that is the only time dupefinished() is ever true.

    In short, dupefinished() == "PasteClk" (like useClk() or tickClk()).

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file