Jump to content

Rinart73

Members
  • Posts

    416
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Rinart73

  1. Avorion: 0.26

     

    "initializationFinished" doesn't trigger for an entity when script is being attached after entity creation.

     

    How to reproduce:

     

    data/scripts/entity/mymod.lua

    -- namespace MyMod
    MyMod = {}
    
    function MyMod.initialize()
        print("MyMod.initialize happened")
    end
    
    function MyMod.initializationFinished()
        print("MyMod.initializationFinished happened")
    end
    

     

    Try to attach this script to entity that already exists in a loaded sector:

    /run Entity():addScriptOnce("data/scripts/entity/mymod.lua")

    You will get only one message:

    MyMod.initialize happened

     

    If you'll then reload a sector (leave and come back after some time or restart the galaxy), two lines will be printed:

    MyMod.initialize happened
    MyMod.initializationFinished happened

  2. No, it stops.

     

    The problem is that when it comes to ShipAI commands like these

    setAggressive(var attackCivilShips, var canFinish) 
    setFly(vec3 location, float arrivalRadius, var collisionException)

    and others, I can't just easilly reset them via "setIdle - setBackToOriginal", because I don't have a way to get their arguments. I don't know if certain ship was set to attack civil ships or not, which coordinates it's flying to etc.

  3. Add one more value to the "PlayerStateType" - "UsesUI".

    Initially I thought that "PlayerStateType.Interact" is set when player interacts with entities or opens UI windows. But apparently it's set only when player interacts with entities via dialogs.

    "PlayerStateType.UsesUI" should be set when player opens UI windows: Player window, Ship window, custom windows added via "ScriptUI():registedWindow".

     

    Reason: You show player resources when player opens any window. My mod needs to react to that, otherwise UI overlaps :/

  4. Do you need a callback for when the sector was first generated?

    Basically, yes.  Current workarounds work almost fine (although onPlayerEntered makes it delayed), so it's a low-priority request.

     

    Use the "onStateChanged" callback of client Player

    Thank you.

     

    invokeFunction() shouldn't be that much of an issue, secure() and restore() definitely are.

    invokeFunction is much more important, since it would allow instant way of data transfer.

  5. Keep in mind that this mod will not be 100% clientside anymore.

     

    data/scripts/player/init.lua

    if onServer() then
        Player():addScriptOnce("data/scripts/player/ui/mymodname.lua")
    end

     

    data/scripts/player/ui/mymodname.lua

    -- namespace MyModName
    MyModName = {}
    
    if onClient() then
    
    function MyModName.initialize()
        if not GameSettings().infiniteResources then
            Player():registerCallback("onPreRenderHud", "onPreRenderHud")
        end
    end
    
    function MyModName.onPreRenderHud()
        local player = Player()
        if player.infiniteResources then return end
    
        local resources = {player:getResources()}
        local y = 10
        local material, rect
        for i = 1, #resources do
            material = Material(i-1)
            y = y + 18
            rect = Rect(5, y, 295, y + 16)
            drawTextRect(material.name, rect, -1, -1, material.color, 15, 0, 0, 2)
            drawTextRect(createMonetaryString(resources[i]), rect, 1, -1, material.color, 15, 0, 0, 2)
        end
        y = y + 18
        rect = Rect(5, y, 295, y + 16)
        local color = ColorRGB(1, 1, 1)
        drawTextRect("Credits"%_t, rect, -1, -1, color, 15, 0, 0, 2)
        drawTextRect(createMonetaryString(player.money), rect, 1, -1, color, 15, 0, 0, 2)
    end
    
    end
    

  6. Some more API requests :)

     

    1. Please add "initializationFinished" for Sector objects.

    Reasons: Modders need to know when sector was completely generated. Current workaround is a mix of onRestoredFromDisk + onPlayerEntered, which is not bad, but not instant the first time sector is being generated.

     

    2. Also it would be very good to know when Player is in building mode (at least on client side).

    Reasons: Modders could stop drawing custom UI elements that are not needed in building mode (or start drawing useful bulding UI). For example both my Resource Display and Buffs mods are currently messing up building UI because they're overlaping it.

     

    3. It would be great to have serverside player or alliance callbacks when player joins or leaves alliance.

    Reasons: Currently we have clientside callback. Which means modders have to rely on player (which is bad)

     

    4. Please add some sort of "invokeFunction" Entity-like method, and also "secure" and "restore" functions for "main.lua".

    Reasons: Avorion really lacks centralized serverside mod controller, that would store data and would be accessible from any script. Adding functions that were mentioned above to the "main.lua" would turn this script into that mod controller. And mods would be able to communicate with each other efficiently!

    Examples:

    • My Galaxy Map QoL mod that is quite popular needs mod controller in order to store, save and give alliance map markers. Currently I have to rely on horrible workarounds, like bouncing the data between online members and the slightest desync can result in losing data. Having something like:
      ModController("ModName"):invokeFunction("functionName", arg1)
      would make everything much better.
    • My Server Guard mod (will be used on reborn Rusty's Galaxy server) currently has to fetch server variable in "update" function every X seconds via "getValue" in order to transfer data from sector script to the "main.lua".

  7. Avorion: 0.25.2

     

    When finding enemy faction script checks the same coordinates 3 times in a row ignoring "coords" pair from "locations" table:

    File: data\scripts\player\headhunter.lua - Line 71:

    local f = Galaxy():getNearestFaction(x, y)

    should be replaced with

    local f = Galaxy():getNearestFaction(coords.x, coords.y)

     

    UPD: Even though in 0.26 that file was completely changed, it has the same bug on lines 120 and 134.

  8. Avorion: 0.25.2

    Windows 10 x64

     

    I have a script "data/scripts/player/gatefounder.lua" that is attached to a Player object. When I look at the Player object in a dev-mode debug window, I see that for some reason it has following path: "data\scripts\player\gatefounder.lua". Some scripts have forward slashes in their path and some - backwards.

    I'm trying to execute following code on sever side:

    print(player:hasScript("data/scripts/player/gatefounder.lua")) -- returns 1, so script is attached
    local status, success = player:invokeFunction("data/scripts/player/gatefounder.lua", "found", tx, ty, "confirm")
    

    So I should get 0 as my 'status' (according to the Docs) and function return value as my `success`.

    But 'status' is 3, which means that "the given script was not found in the entity". But it is attached to the object.

     

    Then I try to use:

    local status, success = player:invokeFunction("data\\scripts\\player\\gatefounder.lua", "found", tx, ty, "confirm")

    And everything works just fine.

     

    Please either fix  "invokeFunction" or make sure that Avorion transforms all paths to have forward slashes. Because currently I have to invoke function 2 times each time.

  9. Avorion: 0.23.3 (and maybe earlier)

     

    If you remove and add a script back again without any delay, it's clientside counterpart will not be re-added. Is it a bug, unexpected behaviour or intentional mechanics of the game engine?

     

    Attached mod example:

    [*]Type "/refreshui" to add a script to an entity

    [*]Type something in a textbox

    [*]Type "/refreshui" to remove and add the script back

    [*]Textbox will not be cleared

    [*]Repeat, sometimes it happens from a second time

    RefreshUITest.zip

  10. Avorion: 0.18 (and maybe earlier) - 0.23.3

    The closer you look at the jump animation or transport beams, the more FPS drops.

    I remember that one of the devs said this is probably something related to transparency and layer ovelaying (or something like that)

  11. [uBR] Fixed an issue where stations that were set to "don't buy/sell" would still trade with players

    This message refers to the factories only. Currently consumer stations (Research Station, Shipyard e.t.c):

    [*]Buy goods from traders

    [*]You don't pay money for these goods

    [*]Bought goods automatically decay over time

    This is completely another thing and it currently screw ingame balance.

    You can use my mod in order to:

    [*]Have the ability to turn trading off for consumer stations

    [*]Make players pay for these goods

    [*]Disable goods decay

  12. Avorion: 0.22 - 0.23.3, but I believe this is an old bug.

     

    Example:

    [*]Get a xanion turret

    [*]Place a xanion block

    [*]Place turret on that block

    [*]Replace the block with a lower material block

    [*]Turret still here and it works just fine

     

    So one of 2 things needs to happen in this case:

    • Disallow replacing blocks with a lower material if they have a turret
    • Remove a turret from block

  13. Version: 0.18 (and earlier) to 0.23.3

     

    Each adventurer entity remembers players that got the upgrade independently. So in multiplayer each adventurer can give a Radar system upgrade.

    I know it's a minor bug, but still :)

     

    I guess you could set Player variable 'got_adventurer_upgrade' to 'true' and use it to check whether player already got the upgrade.

  14. 0 mods activated:

    Menu client profile: https://drive.google.com/open?id=1ygQOuhoCmz8g_I6NSw1naIW_a7EpPBLR

    Ingame client profile: https://drive.google.com/open?id=10-zxQM-8zPTaxFaM7KJYy_kE6GyYnqAC

    [spoiler=Screenshots]

    Menu: 20190624233949-1.jpg

    Ingame (sector had 2 NPC ships, 2 stations and few asteroids): 20190624233625-1.jpg

     

     

    10 mods activated (all of them were "Example" mods made by the devs):

    Menu client profile: https://drive.google.com/open?id=1vYJfK9_nZaUojviIUdMRpo0GPgRX47US

    Ingame client profile: https://drive.google.com/open?id=1PHV9ViIzyj6ebLQeqS4IJ4yaxzmJImBv

    [spoiler=Screenshots]

    Menu: 20190624234026-1.jpg

    Ingame: 20190624233841-1.jpg

     

     

×
×
  • Create New...