Jump to content

Welcome to the Forum!

The best place to exchange builds and ideas! Vote for the best ideas and suggestions here.

Join the Avorion Discord!

Connect with other passionate players and talk about the latest news.
Discord

DLC Avorion Into the Rift Out Now!

Now available on Steam!
Steam
  • 16

Scripting API requests


Hammelpilaw
 Share

Suggestion

When playing online every player got some sectors wich always be kept alive. The order wich sectors will be alive is hardcoded. It would be awesome for modders to be able to change the order.

 

The reason is simple: When you got many stations in different sectors you do not need all the secors to be up because the production will be calculated when the sector gets restored from disk. But your salvage ship in another sector does not keep the sector alive, you have to calculate how many ships you need there to make its score bigger then the stations in other sectors. This is only one example, there are many situations where I wished I could modify it.

 

Some examples what Im thinking of.

 

Manually define the sector score.

function getSectorUpkeepScore(Entities, Player)  local score = 0
  for _,entity in pairs(Entities)
    if entity.factionIndex == Player.index then
      if entity.hasScript("salvage.lua") then
        score = score + 5
      end
      -- do some more stuff
    end
  end
end

 

 

Manually define the entities score

function getEntityUpkeepScore(Entity, Player)
  -- Calculate entity score
end

 

 

Also it would be great to see wich sectors are alive.

Player():getAliveSectors()
-- or
Server():getAliveSectors(playerIndex)

  • Like 1
Link to comment
Share on other sites

Recommended Posts

  • 0

Would be nice if we could get some info on exactly how TurretTemplate.simultaneousShooting works. An answer here would be fine but I'd like to see an update to the documentation so other modders aren't as confused as I am when looking at it.

It looks like it instantly overheats the turret but fires all of a turret's weapons at the same time?

That means that the tooltips that say that say that it offers multiple continuous shots are wrong, since it only fires once before overheating.

Edited by Sathaerz
Link to comment
Share on other sites

  • 0
2 hours ago, Sathaerz said:

Would be nice if we could get some info on exactly how TurretTemplate.simultaneousShooting works. An answer here would be fine but I'd like to see an update to the documentation so other modders aren't as confused as I am when looking at it.

It looks like it instantly overheats the turret but fires all of a turret's weapons at the same time?

That means that the tooltips that say that say that it offers multiple continuous shots are wrong, since it only fires once before overheating.

Hey, I might have some insight on this.

Some weapons will apply huge amounts of heat per shot, but between the cooldown rate and the firerate, this allows the turret to cool off enough before the next shot, allowing the continuous shots figure you see.  However, I don't believe the vanilla calculations take into account simultaneous shooting.  Or at least it doesn't do it properly.  I believe max heat is 100, so if all weapons firing together are enough, it'll put it over this with ease.

There's also a mod out there, Detailed Turret Tooltips, I think it's called?  This mod shows the actual heat level applied per shot and the amount cooled off per second.  Might help visualizing it better.

  • Like 1
Link to comment
Share on other sites

  • 0

I’m not sure if this is the proper place for this or if I’m asking the right thing, but....

 

addShipProblem, for placing an icon at the top of the players screen, will cause that icon to periodically flash. However, I’ve noticed the icon for indicating there is a shipyard present in sector does not.

 

I’m asking if the command for doing that is already exposed/known to modders (and what is it), or if not, can it be exposed for us to use?

 

Thanks.

Link to comment
Share on other sites

  • 0

It would be nice to have something for manipulating ship maneuverability other than Thrusters().

Thrusters() only seems to work in certain situations (unless I'm doing something wrong, but there's no real documentation on how to use it "right"), and it only seems to act as an absolute override.

Perhaps new StatsBonuses of Yaw, Pitch, and Roll that can then be used in Entity methods like addAbsoluteBias, addBaseMultiplier, addKeyedMultiplier, etc?

 

In my use case, I'm trying to apply a multiplier to yaw/pitch/roll based on ship mass, but need to be able to modify this modifier every time someone alters their ship, while still allowing for bonuses through crew overstaffing and system upgrades.

Edited by FuryoftheStars
Link to comment
Share on other sites

  • 0

Make so ScriptUI() "registerInteraction" and "registerWindow" return their optionIndex. This will allow to properly track with what option a player interacts in following functions:

onInteract(optionIndex)
onShowWindow(optionIndex)
onCloseWindow(optionIndex)
interactionPossible(playerIndex, optionIndex)

This is especially useful when several mods add interactions to the same entity or even modify each other.

----

On the same note it would be good to have "ScriptUI():getInteractions()" which would return a table of scripts with all their registered interactions. Numerical keys are optionIndex-es.

{
  ["data/scripts/entity/merchants/researchstation.lua"] = {
    [0] = "Research"
  },
  ["data/scripts/entity/merchants/consumer.lua"] = {
    [0] = "Trade Goods"
  },
  ["data/scripts/entity/somemod.lua"] = {
    [0] = "Do this",
    [1] = "Do that"
  }
}

 

----

Now to the matter of starting interactions via code. Currently it's only possible to start/force Dialog, but not function/window. To fix this I propose adding "interactScript" function, which would start any type of interaction in any script as long as correct script path optionIndex is provided.

ScriptUI():interactScript(scriptPath, optionIndex)
-- Example:
ScriptUI():interactScript("data/scripts/entity/merchants/researchstation.lua", 0)

 

Edited by Rinart73
Link to comment
Share on other sites

  • 0

The current bonus system is amazing. It's extremely powerful.

result = (base * baseMultiplier + multiplyableBias) * multiplier + absoluteBias

Hovewer there are still "stats" that don't follow this system:

  1. Thrusters - basePitch, baseRoll, baseYaw
  2. Entity - damageMultiplier
  3. Durability - maxDurabilityFactor

I understand that it would require lots of changes but I propose to change the listed stats above into StatsBonuses and to use this system for the future stats, since it allows finer control and for multiple mods to modify the same stat without conflicting each other or breaking stuff.

I've seen at least 3 separate people trying to make a yaw/roll/pitch system upgrade. They all run into issues.

I personally wanted to use all of the stats above in my mods. But currently damageMultiplier and maxDurabilityFactor are just sometimes directly set by the game which overwrites my changes. And thruster stats are reset on plan update I believe and stacking them is pain.

Edited by Rinart73
Link to comment
Share on other sites

  • 0
5 hours ago, Rinart73 said:

The current bonus system is amazing. It's extremely powerful.

result = (base * baseMultiplier + multiplyableBias) * multiplier + absoluteBias

Hovewer there are still "stats" that don't follow this system:

  1. Thrusters - basePitch, baseRoll, baseYaw
  2. Entity - damageMultiplier
  3. Durability - maxDurabilityFactor

I understand that it would require lots of changes but I propose to change the listed stats above into StatsBonuses and to use this system for the future stats, since it allows finer control and for multiple mods to modify the same stat without conflicting each other or breaking stuff.

I've seen at least 3 separate people trying to make a yaw/roll/pitch system upgrade. They all run into issues.

I personally wanted to use all of the stats above in my mods. But currently damageMultiplier and maxDurabilityFactor are just sometimes directly set by the game which overwrites my changes. And thruster stats are reset on plan update I believe and stacking them is pain.

Add to this Deceleration, too (unless I'm missing it somewhere).

Also, the yaw/pitch/roll should be of the entire ship (thrusters + gyros), not just thrusters (like the Thrusters() object apparently does).

Link to comment
Share on other sites

  • 0

The following Player client callbacks would allow to do some build mode modding:

  • onBuildModeBlockSelected(lastBlock, blockIds) - would fire when player selects block or group of blocks.
    lastBlock is the block that was just selected. blockIds represents ids of all selected blocks.
  • onBuildModeBlockUnselected(lastBlock, blockIds) - would fire when player unselects block/group.
    lastBlock is the id of the block that was just unselected. blockIds are all blocks that are still selected after that. Or nil/empty table if none.

Examples of that people want to do with it:

  • Color-picker - I actually already have one written already
  • Custom color presets/palettes
Link to comment
Share on other sites

  • 0

The ability to change faction name would be nice. Even if it's only when it's just being created:

function initializeAIFaction(faction)
    faction.name = "United Federation of Planets"
    
    -- other code
end

While we do have the "Galaxy():createFaction(name, x, y)" function, it doesn't allow us to insert that faction into factionmap and automatically give it a bunch of sectors.

Edited by Rinart73
Link to comment
Share on other sites

  • 0

TextBox:

It would be nice to have "setTextNoCallback" function similar to what we have with CheckBox, ComboBox and other elements.

Another great thing would be to have the "cursor" property both writable and readable. Right now if I'm changing TextBox value while user is typing, cursor is always reset to the end, which could be confusing for them.
If "cursor" was readable, I could've saved old position, changed the text and then restored the position.

Link to comment
Share on other sites

  • 0

My apologies for the long list  ; D

#1. Expand StatBonuses to affect the following:

  •     Deceleration - (AFAIK not possible to modify from scripts at all)
  •     Yaw\Pitch\Roll - separately ( currently possible via clientside edit of Thrusters().basePitch/Roll/Yaw )
  •     Thrust - (as in sideways acceleration - currently affected by vec3 Thrusters().thrust)

#2. Ability to set specific Entity as target for Turret / TurretAI

  •     What we have now:

    TurretAI().targetedEntity - seems to be ignored or overriden after change
    ShipAI().setAttack() - Spamming this every Tick seems to be as far as we can get to fire directly at specific Entity

  •     Request example:
    -- When valid, will always aim at Entity, if nil, leaves control to ShipAI/TurretAI
    TurretAI().SetAimOverride( _Entity )

#3. Ability to Fire specific Turret on demand ( regardless of target )

  •     What we have now:

    TurretAI().shouldFire - is read only

  •     Request example:
    -- Turret will try to fire on every tick, if capable
    TurretAI().SetFiringEnabled( bool )
    
    -- Try to fire just once, if capable
    TurretAI().FireOnce()

#4. Ability to launch Torpedos from scripts

  •     Request example:
    TorpedoLauncher().LaunchTorpedo( _Shaft, _TargetEntity )


#5. Ability to assign continuous thrust for Entities/AI Ships

    This one is difficult. The purpose is to let AI fly smoothly when turning, strafe as player would, or move out of collisions without rotating.
    And that is actually a performance related request.

  •     What we have now:

    vec3 Velocity().velocityf - can actually be used with direction vectors, though this seems hacky, and has to be done on tick in scripts.
    

  •     Request example:  
    -- What it would do in C++ : apply local space force constantly, until disabled.
    Entity/ShipAI/Velocity().SetContinuousThrust( vec3 _LocalSpaceDirection, float _Speed )
    


    
#6. Reading pure block plan stats without modifiers    

    Not sure about this one, AFAIK the only way is to manually count & calculate blocks using formulas from wiki.
    The purpose of this is to allow alternative balancing of ships, without costly overrides.
    For example, to scale stats of larger ships, without breaking the purpose of Build Mode.

  •     Request example: 
    BlockPlan().getBaseStats()

 

  • Like 1
Link to comment
Share on other sites

  • 0

I'd love to have a little more exposure to galaxy map functionality. Specifically:

  • the ability to interact with the upper-left search box for sector highlighting; getSearchText, setSearchText, focusSearchText (for things like a search hotkey), and onSearchTextChanged would open a lot of cool possibilities
  • equivalent capability to things in the right-click context menu for a sector, e.g. inputting a jump path (without turning autopilot on), tagging a sector, changing notes, and all that -- *tons* of really cool things mods could do with this

Having all the new hotness with 2.0 captains in the .lua layer has been very nice, but it's also made me yearn for having even more I can do in this more-used-than-ever mode of the game.

Thanks!

Link to comment
Share on other sites

  • 0

For doing more interesting things with the new Captain commands, it'd be great to have more robust information available for background/out-of-sector ships (via ShipDatabaseEntry or otherwise). Specifically, I'd love to be able to get a CraftStatsOverview or equivalent to experiment with adding more "lifelike" variables into ambush and yield calculations.

Link to comment
Share on other sites

  • 0

# Add method getEngineProperties to ShipDatabaseEntry

local acceleration, decceleration, maxVelocity, yaw, pitch, roll = ShipDatabaseEntry:getEngineProperties()

Could be used to estimate per sector duration of map commands.

# Add required energy to the return values of ShipDatabaseEntry:getHyperSpaceProperties

local jumpRange, canJumpRifts, hyperspaceCooldown, isHyperspaceEngineImpaired, requiredEnergy = ShipDatabaseEntry.getHyperspaceProperties

Could be used to calculate the travel time between sectors for a map command. i.e. the maximum between the hyperspace cooldown and the time it takes to recharge the energy required for the jump.

# Document behaviour of Galaxy:getSectorView

seems to only return a sectorView for the sector you are in and sectors that are connected to your current sector. Fortunately there is Player:getKnownSector, otherwise the mod I am working on would've turned out to be a waste of time.

  • Like 1
Link to comment
Share on other sites

  • 0
On 9/20/2023 at 1:34 AM, sineme said:

# Add method getEngineProperties to ShipDatabaseEntry

local acceleration, decceleration, maxVelocity, yaw, pitch, roll = ShipDatabaseEntry:getEngineProperties()

Could be used to estimate per sector duration of map commands.

# Add required energy to the return values of ShipDatabaseEntry:getHyperSpaceProperties

local jumpRange, canJumpRifts, hyperspaceCooldown, isHyperspaceEngineImpaired, requiredEnergy = ShipDatabaseEntry.getHyperspaceProperties

Could be used to calculate the travel time between sectors for a map command. i.e. the maximum between the hyperspace cooldown and the time it takes to recharge the energy required for the jump.

# Document behaviour of Galaxy:getSectorView

seems to only return a sectorView for the sector you are in and sectors that are connected to your current sector. Fortunately there is Player:getKnownSector, otherwise the mod I am working on would've turned out to be a waste of time.

TTTTTTTTTTTT    HH     HH    III          SSSS
           TT               HH     HH    III       SS
           TT               HHHHHH    III          SSS
           TT               HH     HH    III                SS
           TT               HH     HH    III         SSSS



#####AND####
#############

Add method to get docking blocks to only attach to other specific docking blocks.
To fix problems laid out here:

(Assuming)
local docking, docking range, docking bounding box, color--docking stuff=yes, add it

Add multiple docking types to base game: Commerce, structure connect, parasite connect

Commerce works as current docks do.
Structure dock: allows color coded docking blocks that only attract a docking block of the same color (stations)
Parasite dock: allows color coded docking blocks that only attract a docking block of the same color (ships)

Edited by AvorionCraft
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...