Author Topic: Space Combat 2 - Ship Core Stats  (Read 8771 times)

kevinminion

  • Global Moderator
  • Full Member
  • *****
  • Posts: 147
  • Karma: +15/-0
    • View Profile
  • IGN: Kevin Minion
Space Combat 2 - Ship Core Stats
« on: September 21, 2015, 09:02:36 pm »
Well, it wasn't what ZE1K was looking for, but maybe someone else can use it...
 
This e2 should work for you as long as your target finder is set to find ship_core*
 
SHIPCORE gets wired to your target finder entity output
EGP[wirelink] gets wired to the wire EGPv3 element (Screen, HUD, Emitter)
 
Code: [Select]
@name SC2_Core_Stats
@inputs SHIPCORE:entity EGP:wirelink
@outputs
@persist
@trigger all

if (first()) {
    EGP:egpResolution(vec2(0,0), vec2(500,500))
       
    K=200
    EGP:egpText(K,SHIPCORE:owner():name(),vec2(50,20))
   
    function clearCoreInfo() {   
        for(K=200,215,1) {
            EGP:egpRemove(K)
        }
    }
    function getCoreInfo(CORE:entity) {
        K=201
        X=20
        Y=60
        if(CORE:isValid()) {
           
            if(SHIPCORE:type():find("ship_core")) {
           
                EGP:egpText(K, "Owner: " + CORE:owner():name(),vec2(X,Y))
                K++
                EGP:egpText(K, "Type: " + CORE:getCoreType(),vec2(X,Y+20))
                K++
                EGP:egpText(K, "Name: " + CORE:getCoreName(),vec2(X,Y+40))
                K++
                EGP:egpText(K, "Shield: " + floor(CORE:getCoreShield()*100/CORE:getCoreMaxShield())+"%", vec2(X,Y+75))
                K++
                EGP:egpText(K,  floor(CORE:getCoreShield()) + " of " + floor(CORE:getCoreMaxShield()) ,vec2(X,Y+100))
                K++
                EGP:egpText(K, "Armor: "  + floor(CORE:getCoreArmor() *100/CORE:getCoreMaxArmor() )+"%",vec2(X,Y+150))
                K++
                EGP:egpText(K,  floor(CORE:getCoreArmor())  + " of " + floor(CORE:getCoreMaxArmor())  ,vec2(X,Y+175))
                K++
                EGP:egpText(K, "Hull: "   + floor(CORE:getCoreHull()  *100/CORE:getCoreMaxHull()  )+"%",vec2(X,Y+225))
                K++
                EGP:egpText(K,  floor(CORE:getCoreHull())   + " of " + floor(CORE:getCoreMaxHull())   ,vec2(X,Y+250))
                K++
                EGP:egpText(K, "Cap: "    + floor(CORE:getCoreCap()   *100/CORE:getCoreMaxCap()   )+"%",vec2(X,Y+300))
                K++
                EGP:egpText(K,  floor(CORE:getCoreCap())    + " of " + floor(CORE:getCoreMaxCap())    ,vec2(X,Y+325))
            } else {
                clearCoreInfo()
           
                EGP:egpText(K,"Entity wired to SHIPCORE is not a ship_core entity", vec2(X,Y))
            }
        } else {
            clearCoreInfo()
           
            EGP:egpText(K,"Entity wired to SHIPCORE is not a valid entity", vec2(X,Y))
        }
    }
}
 
interval(500)
       
getCoreInfo(SHIPCORE)