[MOD EXT] Empyrion Scripting - Scripts

Discussion in 'The Hangar Bay' started by Ephoie, Mar 22, 2020.

  1. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    384
    Likes Received:
    131
    ASTIC, ich habe das Problem das keine Dialoge eingeblendet werden.
    Ich denke die Trigger Platte funktioniert aber das Popup kommt nicht.
    Ist schon seit es Dialoge gibt, aber ich habe mir nix dabei gedacht weil ich die bis jetzt nicht benutzt habe.
    Das mod ist neu runtergeladen und ein neues (vanilla, singleplayer, survival) Spiel gestartet.
     
    #541
  2. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Ich habe es noch nicht ausprobiert aber da es im MP funktioniert könnte es sich hier um einen weiteren Fehler im EGS handeln der die API im SP betrifft - ich werde das mal testen und ggf ein Bugticket schreiben.
     
    #542
  3. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    384
    Likes Received:
    131
    Ja, im MP funktioniert es.

    Ich habe immer SP angeschmissen und dort das Demo Schiff gespawned weil ich auf meinem Server nicht unnötig admin Befehle nutzen wollte... Hat auch so weit gut funktioniert, bis auf die Dialoge, die ich nicht genutzt habe.
     
    #543
  4. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Leider funktionieren weder Dialog noch Teleporter API im SP :-(
     
    #544
  5. SolarTails

    SolarTails Ensign

    Joined:
    Jun 1, 2022
    Messages:
    5
    Likes Received:
    3
    Quick question and I apologise if I overlooked anything or am asking a tired old question. I was wondering if it were possible to display a ship's Shield statistics. Such as it's charge rate, capacity (Either as an actual number or even a charge percentage). I know I can display a shield's activation status, but that's as far as I've gotten. I've not done any real scripting in a long time; on top of which, I'm relatively new to Empyrion and this mod. So any help would be greatly appreciated. Thank you.

    Update: Managed to get what I wanted. Figured I'd post my results here if anyone wants it.
    It's basically a percentage bar for shields. I'd post an image, but I couldn't get it to load.

    Code:
    {{#use E.S.ShieldLevel}} -Shields-
    <color=green>{{bar . 0 199650 25 }}</color>
    {{ ~math . '/' 199650}}
    {{~format . '{0,8:P2}'}}
    {{~/math}} =
    {{~format . '{0,7:0.0}'}} / {{format 199650 '{0,7:0.0}'}}
    {{/use}}</color>
    The downside is, I can't get Content and Capacity to work like with fuel/o2/ect.. So, I have to insert the Shield's max capacity manually. Hense the number 199650. Just replace that with your shields actual capacity and it should work.
     
    #545
    Last edited: Sep 22, 2022
  6. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    From the structure you only get the

    Code:
    @root.E.S.IsShieldActive
    and
    @root.E.S.ShieldLevel
    for the capacity maybe you can "ask" the configuration
     
    #546
    SolarTails likes this.
  7. SolarTails

    SolarTails Ensign

    Joined:
    Jun 1, 2022
    Messages:
    5
    Likes Received:
    3
    lol, I was posting right when you did. Thank you though, I appreciate the help.
     
    #547
    ASTIC likes this.
  8. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    384
    Likes Received:
    131
    Made a litle savegame script, it teleports the ship you pilot to a Point 1km (+2,5%) infront of a friendly target.
    Right now there is no cost, it is more or less is just proof of concept.
    To warp point at target (it must be displayed in the list on the "WarpLCD" and have an angle of less than 5°) and turn on a signal named "Warp" in the controlpannel. (you have to turn it off again to rearm the warp)
    It also checks if there are other ships too close to target - maybe there is more I have to check for - do comment and tell.

    Code:
    using Eleon.Modding;
    using EmpyrionScripting.Interface;
    using System.Linq;
    using UnityEngine;
    
    public class ModMain
    {
        private static bool DoWarp = false;
        private static bool DoWarplock = false;
        private static readonly float langle = 5;
        private static readonly int SaveDistance = 1000;
        //private static string armed = "SAVE";
        public static void Main(IScriptModData rootObject)
        {
            if (!(rootObject is IScriptSaveGameRootData root)) return;
            if (root.E.Faction.Id == 0) return;
            if((root.E.EntityType != EntityType.CV)&&(root.E.EntityType != EntityType.SV)) return;
    
            var infoOutLcds = root.CsRoot.GetDevices<ILcd>(root.CsRoot.Devices(root.E.S, "WarpLCD"));
            if (infoOutLcds.Length == 0) return;
            var Sig = root.E.S.ControlPanelSignals.Where(sig => sig.Name == "Warp").FirstOrDefault();
            if (Sig == null) return;
    
            //WriteTo(infoOutLcds, $"test {S.Name} {S.State}");
            if (Sig.State && !DoWarplock)
            {
                DoWarplock = true;
                DoWarp = true;
            }
            else if (!Sig.State && !DoWarplock)
            {
                DoWarplock = false;
            }
            infoOutLcds.ForEach(L => L.SetText(""));
            root.GetCurrentPlayfield().Entities.ForEach(Ent =>
            {
                if (Ent.Value.Faction.Equals(root.E.Faction) && (Ent.Value.Id != root.E.Id) && (Ent.Value.Type != EntityType.Player))
                {
                    var Tvect = Ent.Value.Position - root.E.Pos;
                    var angle = UnityEngine.Vector3.Angle(root.E.Forward.normalized, (Ent.Value.Position - root.E.Pos).normalized);
                    //if(UnityEngine.Vector3.Angle(root.E.Pos, ) { }
                    WriteTo(infoOutLcds, $"{Ent.Value.Name} {Tvect.magnitude} {angle}");
                    if (DoWarp && (angle < langle) && (Tvect.magnitude > 2 * SaveDistance))
                    {
                        Vector3 WarpTarget = Ent.Value.Position - (Tvect.normalized * (float)SaveDistance * (float)1.05);
                        bool WarpTargetClear = true;
                        root.GetCurrentPlayfield().Entities.ForEach(Ent2 =>
                        {
                            if (((Ent2.Value.Position - Tvect).magnitude < SaveDistance) && (Ent2.Value.Id != Ent.Value.Id))
                            {
                                WarpTargetClear = false;
                            }
                        });
                        if (WarpTargetClear)
                        {
                            DoWarp = false;
                            //IEntity myEnt = root.E.GetCurrent();
                            //myEnt.Position = myEnt.Position + myEnt.Forward * Tvect.magnitude;
                            root.E.S.Pilot.Teleport(WarpTarget);
                            WriteTo(infoOutLcds, $"WARP!!");
                        }
                        else
                        {
                            WriteTo(infoOutLcds, "Warp Blocked");
                        }
                    }
                }
            });
        }
        private static void WriteTo(ILcd[] lcds, string text)
        {
            lcds.ForEach(L => L.SetText($"{text}\n{L.GetText()}"));
        }
    }
    
    *edit2 broke it with update before - now fixed (i hope)*

    P.S. can you set the switches in the controlpanel? reading the code and trying to do it makes me think setting signal only works for block devices, and not the controlpanel :(
     
    #548
    Last edited: Oct 2, 2022
  9. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    384
    Likes Received:
    131
    Got a question: does the {{db ...}} command has an c# version? did not find it on the demo ship and searching the github did not find it either...

    kurze Frage: gibt es die {{db ...}} anweisung auch in c#? hab es weder auf dem demo schiff noch im githug finden können...
     
    #549
  10. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Zur Zeit noch nicht, da die Ergebnisse ja dynamisch sind und ich noch keinen einfachen C# Zugriff auf die Objekte habe.
     
    #550
  11. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    "Empyrion – Galactic Survival - Community Forums - Error
    You do not have permission to view this page or perform this action." <-Error notification

    Why can't I access the images or scripts even though I am logged in?
     
    #551
  12. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    They have changed this here in the forum, since then it is quite inconvenient and only limited usable.
     
    #552
    Palmeza likes this.
  13. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Ok thx :)
     
    #553
  14. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Hallo, wenn ich den "AutoGärtner" benutzen will kann man einfach die Koordinaten des gesamten Feldes eingeben, auch wenn andere Blöcke dazwischen liegen. Mein Feld 2x 9 Pflanzblöcke und das 4x nebeneinander, getrennt duch eine "Fußweg" und Stützsäulen.
     
    #554
  15. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Ja geht, er erkennt selber die Pflanzen, nur wenn der Bereich größer wird dauert das "Abarbeiten" auch länger d.h. bitte nicht das ganze Schiff/Basis definieren ;-)
     
    #555
  16. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Ja , danke :)
     
    #556
  17. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Hi, ich komme mit dem Gärtner nicht weiter.
    Ich habe auch negative Koordinaten und bin mir aber nicht sicher wo sich egentlich der "0 Pkt." befindet. Also wenn ich vor dem Feld stehe,
    von wo zähle ich die die die x,y,z Koordinate...das wird mal kurz was Angezeigt, ist aber sofort wieder weg...
    Bei mir Aufruf : LCD für Gärtner : Script:Harvest
    Aufruf Info LCD : Harvest

    {{#blocks E.S 12 127 -5 6 126 9}}
    {{#each .}}
    {{Id}} {{i18n Id}} X:
    {{~Position.X}} Y:
    {{~Position.Y}} Z:
    {{~Position.Z}}
    {{/each}}
    {{#harvest @root.E.S .
    'MFUG' 6 127 6 true}}
    Harvest: {{i18n Id}}➔
    {{~i18n ChildOnHarvestId}}
    get {{DropOnHarvestCount}}:
    {{~i18n DropOnHarvestId}}
    {{/harvest}}
    {{/blocks}}


    Danke im vorraus.
    EScripting ist die neuste.





    [​IMG] [​IMG]
     
    #557
    Last edited: Oct 22, 2022
  18. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Ich habe jetzt mal die Blöcke reduziert bei den Koordinaten. Jetzt wird mir ganz kurz etwas angezeigt.

    https://ibb.co/CQdDydx


    das wir so ca. alle 10s für 1-2s angezeigt

    https://ibb.co/PZNWKHt
    nach dem der "Gärtner" 1x eine Blockreihe (3) abgeerntet hat.
    und das der Kühlschrank gesperrt ist...
     
    #558
    Last edited: Oct 23, 2022
  19. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Die Position der Pflanzen/Gärtner bekommst du leicht raus wenn du das Konsolekommando 'di' eingibst
     
    #559
  20. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Ja, das mache ich, aber wo setze ich den Ursprung..zB.unten links oben rechts ?oder nur unten links und rechts...
    welcher wert kommt zuerst von - zu + werten oder umgekehrt ?
    https://ibb.co/Mp4G1FJ

    und warum ist der Kühlschrank gesperrt ?
     
    #560

Share This Page