Author Topic: Scripting API requests  (Read 2421 times)

Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    586
    • View Profile
on: August 31, 2019, 01:13:38 PM
A function complementary to the Sector() and Entity() API's onRestoredFromDisk() (triggered when the Sector() or Entity() is read from disk and put into active memory). Let's call it onSecuredToDisk() for the purposes of this discussion. It would be called just before the Sector() or Entity() finishes saving to disk and unloads from memory.

It would be cool to be able to act upon the unloading of data from memory, such as triggering a "start simulations now" script, warning the player about the unloading status of a Sector, saving our own data somewhere else than in the secure() space so we still have access to it, a last-known-location type of thing... just knowing that a Sector has become unloaded the instant it happens, because we acted on the callback... the list goes on and on. So many cool use-cases.

EDIT:

An additional callback named something along the lines of onSecureToDisk() which triggers before the saving process begins. This would be used so you can make last-minute changes to a running script before the Sector() or Entity() is well and properly hermetically sealed. This callback is requested because Sectors and Entities can save to disk using secure() without unloading from memory, but it would be useful to act upon the case when and only when the Sector() or Entity() actually unloads from memory.

P.S.
Thanks to Hammelpilaw for the original spark of the suggestion.
« Last Edit: August 31, 2019, 01:27:03 PM by Shrooblord »
Shrooblord



Rinart73

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    345
  • Discord: Rinart73#7304
    • View Profile
on: September 01, 2019, 08:55:51 AM
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 :/



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    586
    • View Profile
on: September 09, 2019, 08:39:25 PM
Expose StatsBonuses.Pilots to lua. Every other profession crewmen can have has been exposed, except this one. PilotsPerFighter exists, but fills a different role.

Reason: StatsBonuses.Engineers and related StatsBonuses exist for a good reason: they allow us to add Crew via System Module Upgrades, or some other "buffing" mechanic. Why should Pilots be excluded from this capability?
Shrooblord



Rinart73

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    345
  • Discord: Rinart73#7304
    • View Profile
on: September 10, 2019, 02:35:38 PM
Add "onTextChangedFunction" for the "MultiLineTextBox" UI element.

 :-\ I needed to limit max amount of characters player can use and without this callback I can only do it after player will do something else (like try to send the data).



Rinart73

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    345
  • Discord: Rinart73#7304
    • View Profile
on: September 13, 2019, 06:09:25 PM
Currently it's impossible to get some basic ship stats before they were affected by bonuses. Stats in "BlockStatistics" are either incomplete or require to use some formula that modders don't know.
  • Hyperspace Reach - "BlockStatistics" has hyperspacePower and it seems that it's hyperspace calculation power from blocks. What does it mean? Is there some formula to transform it into hyperspace reach? (Nvm it's cubic root of "hyperspacePower")
  • Hyperspace Cooldown - No stat or formula
  • Hyperspace Recharge Energy - No stat or formula
  • Shield Recharge Rate - No stat or formula
  • Velocity - When it comes to Avorion stats, velocity is the max speed you can get. No stat or formula
  • Acceleration - I thought that it's "trust" from "BlockStatistics" but I'm getting some weird numbers there
  • Loot Collection Range - Tests show that it's somewhere between 0.95km and 1 km
  • Radar Reach - It seems that default radar reach is 14?
« Last Edit: September 13, 2019, 11:41:04 PM by Rinart73 »



Rinart73

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    345
  • Discord: Rinart73#7304
    • View Profile
on: September 14, 2019, 06:18:04 AM
Can we get a serverside variant of a Player's callback "onAllianceChanged(allianceIndex)"? Otherwise I have to attach "onNewMember" and "onMemberLeft" callbacks to every alliance and it's not great since Alliances get unloaded.
So if Alliance is unloaded and player accepts an invitation, "onNewMember" won't fire.
« Last Edit: September 14, 2019, 06:19:45 AM by Rinart73 »



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    586
    • View Profile
on: September 15, 2019, 02:44:46 PM
I would love the ability to more precisely control what happens to System Module Upgrades. More specifically, I request:
  • A hook to prevent the functionality that triggers the onUninstall() callback from occuring. In other words, prevent a Player from uninstalling an SMU and/or destroying it permanently.
  • Force-install an SMU to a Player's Ship through scripts.
  • Force-uninstall an SMU from a Player's Ship through scripts.

This is because, in certain conditions, we might want to permanently lock-in an SMU into their Ship. Think of vampiric / parasite systems, or exploitable uninstall-reinstall mechanics (when the SMU adds flat bonuses like Crew Workforce for crew such as Pilots and Boarders that might not be on-board the Ship at time of uninstallation) that could be fixed by preventing the uninstallation dead in its tracks.

Additionally, you could add cool questlines with upgrades becoming replaced by some corrupted version of them, and/or have nefarious characters forcibly install systems on your Ship that act like in-game spyware, etc..

EDIT:
Re: Force Uninstallation


You can actually force-uninstall an SMU; in the end they're just scripts added to your Ship. You can remove this script manually using removeScript().

Adding it using addScript() doesn't seem to be fully functional, as the script is loaded and added to the Entity, and when you pass it a sufficient seed and rarity, it runs without errors, but no SMU is ever physically added, and so no bonuses are added to the Ship.

Happy coding with this new knowledge! ^^
« Last Edit: September 15, 2019, 03:08:36 PM by Shrooblord »
Shrooblord



Rinart73

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    345
  • Discord: Rinart73#7304
    • View Profile
on: September 15, 2019, 09:19:46 PM
Quote
Force-install an SMU to a Player's Ship through scripts.
Code: [Select]
ShipSystem():addUpgrade(SystemUpgradeTemplate upgrade, bool permanent)
Quote
You can actually force-uninstall an SMU
Code: [Select]
ShipSystem():removeUpgrade(unsigned int slot)



Rinart73

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    345
  • Discord: Rinart73#7304
    • View Profile
on: September 18, 2019, 12:00:02 AM
Add a way to check if a faction (NPC or alliance) is loaded in memory on server-side.