[mod] Empyrion Scripting Mod

Discussion in 'Empyrion API' started by ASTIC, May 25, 2019.

Tags:
  1. kkin形影

    kkin形影 Ensign

    Joined:
    Oct 17, 2022
    Messages:
    23
    Likes Received:
    0
    #381
  2. kkin形影

    kkin形影 Ensign

    Joined:
    Oct 17, 2022
    Messages:
    23
    Likes Received:
    0
    How to implement automatic classification of items through scripts? For example, I store all items in the 'A' box and automatically classify them into the BCD box.
     
    #382
  3. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    There are many ships and bases in the workshop that use sorting via scripting. Just search for "script
     
    #383
  4. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    Is it possible to use item Keys instead of IDs for the config? Adding and changing the IDs I want to use for the decon script is a pain after each wipe. Using Keys would negate this issue.
     
    #384
  5. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    Yes, is is shorter thus more often used, but shpuld work just the same with keys.
    You can work with id lists (@ids.xy) as well!
     
    #385
  6. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    Ok! So I just need to put the keys I want to use just like I would the IDs? Fabulous!!
     
    #386
  7. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    405
    Likes Received:
    138
    ASTIC, Ich hab 2 Fragen:

    Laufen C# LCD Scripte seltener als Handlebars? (Ich habe experimentiert und das Ergebnis einer Änderung hat recht lange gebraucht)
    Ist der Schild Status auch in Handlebars? (in der Doku hab ich 's nicht gefunden) über C# komme ich dran, aber habe da oben genantes Problem.

    War warscheinlch langsam weil ein altes Mod noch auf dem Testserver gelaufen ist....

    nochmal n edit:

    wie kann ich mit (ingame LCD) C# n Lever / Signal setzen?


    Danke!
     
    #387
    Last edited: Jan 17, 2024
  8. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    Code:
    {{E.S.IsShieldActive}}
    {{E.S.ShieldLevel}}
     
    #388
  9. JMFB6125

    JMFB6125 Ensign

    Joined:
    Jan 21, 2024
    Messages:
    1
    Likes Received:
    0
    I am not sure what I am doing wrong here. I'm trying to use a shop script for my player shop. The script I have requires someone to put in the exact amount of currency for each transaction. I want to make it so that you can place a stack of currency into the sale box and then it gives you as many items as you can with that amount of currency and then gives you the items and any change at the end. I can attach the script I have below.


    <align=center><size=+1><color=purple>Item Name Here</color></size></align>
    {{set 'cost' 5000}}
    {{set 'volume' 1}}
    {{#items E.S 'box33-item'}}
    {{set 'itemID' Id}}
    {{/items}}
    {{#items E.S 'box33'}}
    {{#test Id 'eq' 4347}}
    {{#test Count 'eq' @root.Data.cost}}
    {{set 'Payed' true}}
    <color=green>Thank you for the correct deposit.</color>
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'box33-item'}}
    {{#test Id 'eq' @root.Data.itemID}}
    {{#test Count 'lt' @root.Data.volume}}
    <color=red>Not enough item.
    {{set 'emptybox' true}}
    {{/test}}
    {{/test}}
    {{else}}
    {{set 'emptybox' true}}
    <color=red>The shop is empty.
    {{/items}}
    {{#items E.S 'box33'}}
    {{#test Id 'eq' @root.Data.itemID}}
    <color=red>Please remove your item.
    No new transactions until previous item has been removed.
    {{set 'emptybox' true}}
    {{/test}}
    {{/items}}
    {{#if @root.Data.emptybox}}
    Transactions halted
    {{else}}
    {{#if @root.Data.Payed}}
    {{#items E.S 'box33-item,box33'}}
    {{~set 'ShopBox1NB' ''}}
    {{~set 'Amount' ''}}
    <color=orange>Transfer In Progress</color>
    {{#test Id in '4347'}}
    {{~set 'ShopBox1NB' 'moneybox'}}
    {{/test}}
    {{#test Id in @root.Data.itemID}}
    {{~set 'ShopBox1NB' 'box33'}}
    {{~set 'Amount' @root.Data.volume}}
    {{/test}}
    {{#ok @root.Data.ShopBox1NB}}
    {{#move ../. @root.E.S @root.Data.ShopBox1NB @root.Data.Amount}}
    {{Source}} -> {{Destination}}
    {{/move}}
    {{/ok}}
    {{/items}}
    {{else}}
    {{#items E.S 'box33-item'}}
    <align=center><color=green>This box is selling
    {{@root.Data.volume}} {{Name}}
    for {{@root.Data.cost}} Gold Coins.
    There is {{Count}}
    available to purchase.
    Deposit exactly {{@root.Data.cost}} Gold Coins into the box and wait for this screen to inform you that your item is ready to retrieve.
    <smallcaps><color=red>No refunds
    Do no open the box until instructed to or you may lose your money</color>
    Item ID {{Id}}
    </color>
    {{/items}}
    {{/if}}
    {{/if}}
     
    #389
  10. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    #390
  11. lateniter

    lateniter Ensign

    Joined:
    Jan 31, 2024
    Messages:
    1
    Likes Received:
    0
    Love the Mod, even though we are still running on 11.4.6...
    Is there a variable for showing the maximum Shield like... E.S.Shieldlevel ?

    I'd like to have a bar display and not have to recode the 15550 if I update the ship in a manner that affects the shield

    <color=#ffd700>
    {{#use E.S.ShieldLevel}}
    {{bar . 0 15550 16 }}
    {{~format . '{0,8:}'}}
    {{/use}}</color>

    Thanks, and any help appeciated
     
    #391
  12. SAP

    SAP Lieutenant

    Joined:
    Mar 2, 2017
    Messages:
    10
    Likes Received:
    2
    I can't get the commands to work. I have.
    The source, Script: Deconstruct, the destination, DeconstructLcd.
    On the script I have the following:

    (LCD Names)

    Script: DeconstructLcd
    DeconstructLcd

    (Script)

    {{gettext Script: Deconstruct}}
    {{settext DeconstructLcd}}

    This outputs an error on DeconstructLcd of: Reached end of template before block expression 'gettext' was closed.
    So, I closed the expressions with the following:

    {{gettext Script: Deconstruct}}
    {{/gettext}}
    {{settext DeconstructLcd text}}
    {{/settext}}

    Expressions are closed, no more error message. But now, DeconstructLcd displays nothing
     
    #392
    Last edited: Jul 18, 2024
  13. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    Code:
    {{settext DeconstructLcd (gettext Script:Deconstruct)}}
    gettext is a single command that returns the text directly.
    settext is also a single command for setting a text to a LCD
     
    #393
  14. SAP

    SAP Lieutenant

    Joined:
    Mar 2, 2017
    Messages:
    10
    Likes Received:
    2
    Tryd it but get this in the DeconstructLcd
    An unhandled exception occurred while trying to compile the template 5:02:42 PM

    What im atemting to do is put the script for public use on the base so thay can copy it with out wrecking the original text.
     
    #394
  15. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    I forgot the quotes
    Code:
    {{settext "DeconstructLcd"
    (gettext "Script:Deconstruct")}}
    Or try the
    Code:
    {{#settextblock "DeconstructLcd"}}
    {{gettext "Script:Deconstruct"}}
    {{/settextblock}}
     
    #395
  16. SAP

    SAP Lieutenant

    Joined:
    Mar 2, 2017
    Messages:
    10
    Likes Received:
    2
    still get the error on the first set of code
    An unhandled exception occurred while trying to compile the template 1:40:39 AM

    Second set of code tels me
    Reached end of template before block expression 'gettext' was closed 1:43:06 AM
    so I closed it
    Code:
    {{#settextblock "DeconstructLcd"}}
    {{gettext "Script:Deconstruct"}}
    {{/gettext}}
    {{/settextblock}}
    no error but the DeconstructLcd is empty no text
     
    #396
  17. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    I'm currently on holiday and unfortunately can't try it out in the game.

    So unfortunately I have to leave you with a "verified" version
     
    #397
  18. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    405
    Likes Received:
    138
    Sorry ASTIC, I have a savegame cs problem:

    after some try/error I figured out sending a chat message in cs wont work and cause an error.
    I use almost the same code as in an working api script.
    Is there a better / working way to send a chat message?

    the "bad" line is:
    Code:
    root.ModApi.Application.SendChatMessage(new Eleon.MessageData()
    {
        Channel = Eleon.MsgChannel.SinglePlayer,
        RecipientEntityId = root.E.S.Pilot.Id ,
        SenderNameOverride = "TEST",
        SenderType = Eleon.SenderType.ServerPrio,
        Text = "TEST"
    });
    
    and the error is
    Code:
    09-13:47:42.256 15_47 -ERR- {EmpyrionScripting} C# Run [80001/C:\SERVERS\EMPYRIONDEDICATEDSERVER\SAVES\GAMES\RE2BETA2\MODS\EMPYRIONSCRIPTING\SCRIPTS\CV\WARP.CS]:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
      at Submission#0+ModMain.Main (EmpyrionScripting.Interface.IScriptModData rootObject) [0x00083] in <737b1f52dad04767bb3f6e356af88985>:0
      at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
      at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <27124aa0e30a41659b903b822b959bc7>:0
       --- End of inner exception stack trace ---
      at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <27124aa0e30a41659b903b822b959bc7>:0
      at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <27124aa0e30a41659b903b822b959bc7>:0
      at EmpyrionScripting.CsCompiler.CsCompiler+<>c__DisplayClass49_0`1[T].<GetExec>b__2 (System.Object rootObject) [0x00169] in <2d5bec663c06439caa55fa8470927ffb>:0 
    Ans as always thank You for the great mods you make.
     
    #398
  19. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
  20. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    Try "CsRoot.Root." instead of "root."
     
    #400

Share This Page