[Zucchini Universe] Updated EmpyrionModdingFramework 2.0 - Now with both API support

Discussion in 'Empyrion API' started by elmorti, Sep 14, 2020.

  1. elmorti

    elmorti Ensign

    Joined:
    Jul 20, 2020
    Messages:
    6
    Likes Received:
    7
    Hello Explorers, Content Creators and Server Owners!

    TL;DR; Grab it and start coding your mods with EmpyrionModdingFramework!

    From the labs of
    Zucchini Universe we have created a new, refreshed, open source and very simple to use modding framework.

    If you are used to work with ASTIC-TC EmpyrionNetAPIAccess, you will find this fork a refreshed rework, cleaned up and minimalist so that you can focus on quality mods and quality code.

    The instructions are very easy to follow, the code is very easy to read, the mods are fun to make!

    Yours!
    elmorti (on behalf of Zucchini Universe)
     
    #1
    Last edited: Feb 21, 2021
    zaphodikus, byo13, Jascha and 2 others like this.
  2. Xango2000

    Xango2000 Captain

    Joined:
    Jun 15, 2016
    Messages:
    385
    Likes Received:
    202
    Awesome!
    Empyrion needs more Modders.
    At first glance, this looks like it uses API1. So, Server only, not available for single player unless you set up your own server. I wrote a guide to walk you thru that process, it's really simple... ish.
    https://steamcommunity.com/sharedfiles/filedetails/?id=1368270700

    Welcome to the modding community
     
    #2
  3. elmorti

    elmorti Ensign

    Joined:
    Jul 20, 2020
    Messages:
    6
    Likes Received:
    7
    Hi Xango2000, thanks for your interest!

    The framework main pillar is that is only focused on server side mods and as thus, in multiplayer servers, this is and will be the main focus of our work.

    The second major pillar of our work is: modern, simple and clean quality code, we are working on a test framework as well and we expect our mods to follow some best practices to improve the reliability.

    And the third pillar is, open source, we chose GPLv3 because we would like everyone else not to only enjoy the code but also contribute back and create something good over time.

    Is good to see you around, I've seen some of your mods but I thought you were out of the scene already :) You undoubtedly inspired us.
     
    #3
    byo13 likes this.
  4. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Well, then I'm curious to see what's coming from you. So far I'm the only active modder who shares mods with source in the community. And the api version 1 & 2 from Eleon is really bitchy with no examples.
     
    #4
    byo13 and zaphodikus like this.
  5. Wren

    Wren Ensign

    Joined:
    Nov 13, 2015
    Messages:
    14
    Likes Received:
    3
    I'm happy to announce that I will be working on some mods here for the Community. I have written many mods for Starbound and No Man Sky. I'm a Veteran Coder been Coding and Hosting Servers for over 15 years. Any way I will be starting this weekend. And yes I do have a Custom Server up. Msg me for Details.
     
    #5
    byo13 and zaphodikus like this.
  6. Polnoch

    Polnoch Lieutenant

    Joined:
    Sep 26, 2017
    Messages:
    43
    Likes Received:
    9
    Not sure, lol.
     
    #6
  7. byo13

    byo13 Captain

    Joined:
    Jul 13, 2020
    Messages:
    415
    Likes Received:
    638
    Excellent work.
    I found the syntax and method call in your PlayerInfo example ideal for beginners.
    How complete is the framework?
     
    #7
  8. elmorti

    elmorti Ensign

    Joined:
    Jul 20, 2020
    Messages:
    6
    Likes Received:
    7
    Hi everyone, it has been quite a while due to personal circumstances but I have applied myself recently and updated the framework to make use of both ModAPI and ModInterface (aka new vs legacy API).

    Plus I am reorganizing my repositories so you will find this now here:

    https://github.com/elmorti/zucchini-empyrion/tree/main/modding-framework

    It has a companion "skeleton mod" where you can see and get introduced on how to use it:

    https://github.com/elmorti/zucchini-empyrion/tree/main/zucchini-skeleton

    Thanks!
     
    #8
    byo13 likes this.
  9. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    384
    Likes Received:
    131
    I tryed to compile the skeleton mod, and run it...
    but i get an error in the log and client and the server tasks freeze:
    Code:
    01-15:23:42.124 16_23 -LOG- {zucchini-skeleton} SaveGame: D:\servers\empyrionserver\PlayfieldServer/../Saves/Games/ReforgedEden
    01-15:23:42.125 16_23 -LOG- {zucchini-skeleton} ActiveScenario:
    01-15:23:42.125 16_23 -LOG- {zucchini-skeleton} Cache: D:\servers\empyrionserver\PlayfieldServer/../Saves/Cache
    01-15:23:42.125 16_23 -LOG- {zucchini-skeleton} Content: D:\servers\empyrionserver\PlayfieldServer/../Content
    01-15:23:42.125 16_23 -LOG- {zucchini-skeleton} Dedicated:
    01-15:23:42.125 16_23 -LOG- {zucchini-skeleton} Mod: D:\servers\empyrionserver\PlayfieldServer/../Content/Mods
    01-15:23:42.125 16_23 -LOG- {zucchini-skeleton} Root: D:\servers\empyrionserver\PlayfieldServer/..
    NullReferenceException: Object reference not set to an instance of an object
      at ZucchiniSkeleton.ZucchiniSkeleton.Application_GameEntered (System.Boolean hasEntered) [0x0004d] in <39c21b4603a345c1a2e805e5a01f7a92>:0
      at Eleon.ModBridge.ApplicationBridgeCommon.OnGameEntered (System.Boolean entered) [0x0000a] in <c30ce2538bc04869b332978f1f540f6f>:0
      at Assembly-CSharp.DockingPaneQueue.HideQueue () [0x00025] in <c30ce2538bc04869b332978f1f540f6f>:0
      at Assembly-CSharp.EditorType.CopyOutline (System.String , Assembly-CSharp.EmulatorLayout , System.String , System.String , System.UInt64 , System.Int32 , System.Int32 , System.Int16 ) [0x001da] in <c30ce2538bc04869b332978f1f540f6f>:0
      at Assembly-CSharp.ReferencePcitureStack.CloseQueue (Assembly-CSharp.CommandFactory+TextFileToken ) [0x00018] in <c30ce2538bc04869b332978f1f540f6f>:0
      at Assembly-CSharp.ReferencePcitureStack.RegisterEmulator () [0x00178] in <c30ce2538bc04869b332978f1f540f6f>:0
      at Assembly-CSharp.EditorType.GenerateView () [0x00038] in <c30ce2538bc04869b332978f1f540f6f>:0
      at MBS.Update () [0x00008] in <c30ce2538bc04869b332978f1f540f6f>:0
     
    (Filename: <39c21b4603a345c1a2e805e5a01f7a92> Line: 0)
    
    01-15:23:42.218 16_23 -LOG- Task Type=versionCache ThreadId=5268 ManagedId=10
    Did I mess up somewhere?

    forgot to say:
    tryed it on a dedicated server, and also have empyrion scripting installed.
     
    #9
    Last edited: Mar 1, 2021
  10. elmorti

    elmorti Ensign

    Joined:
    Jul 20, 2020
    Messages:
    6
    Likes Received:
    7
    Hi there!

    You are not doing anything wrong :)

    It is a bug because:

    // The following line is also available when the mod is running on Client mode.
    ModAPI.Application.GameEntered += Application_GameEntered;


    Therefore ModAPI.Application.GameEntered is NULL and that is why you get no reference and the exception.

    That makes also the following delegate useless on Dedi:

    // This is also only useful when in Client mode.
    private void Application_GameEntered(bool hasEntered) {}


    I did not catch this on time because I was doing my tests on Client mode.

    I will update the repository for the skeleton-mod and the framework in the next one or two days since the framework also has a bug that can lead to deadlocks (will actually cause deadlocks) on the CommandManager due to bad handling of async code.

    In the meantime, you can replace ModAPI.Application.GameEntered and the delegate private void Application_GameEntered(bool hasEntered) {} with this:

    // Subscribe to DediAPI Game_EventRaised:
    Game_EventRaised += StructureManager_Game_EventRaised;


    And then create a delegate StructureManager_Game_EventRaised like this:

    private void StructureManager_Game_EventRaised(CmdId eventId, ushort seqNr, object data)
    {
    if (eventId == CmdId.Event_Player_Connected)
    {
    PlayerInfo player = (PlayerInfo)data;
    Log($"Player {player.playerName} has logged in.");
    }
    }


    Or replace the eventId with whichever one you would like to catch and process with the delegate.

    Also you can create as many delegates as you need, the important part is catching the eventId and processing the object data, and make sure they are subscribed to the event Game_EventRaised.

    Note that:
    • The DediAPI code won't work in Client mode
    • Make sure that the <modname>_Info.yml file is correctly set to run in the right mode (i.e. Dedi).
    Thank you very much!
    elmorti
     
    #10
  11. elmorti

    elmorti Ensign

    Joined:
    Jul 20, 2020
    Messages:
    6
    Likes Received:
    7
    Just to clarify, the name of the delegate can be anything you like:

    StructureManager_Game_EventRaised is just one I copied from a work in progress project I had nearby :)

    The delegate method just needs to follow the same signature all the time:

    WhateverNameYouWantToUseForYourDelegate(CmdId eventId, ushort seqNr, object data)

    Hope it helps!
     
    #11
  12. elmorti

    elmorti Ensign

    Joined:
    Jul 20, 2020
    Messages:
    6
    Likes Received:
    7

Share This Page