Jump to content
  • 2
Hammelpilaw

Scripting API requests

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)

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

I'm trying to use the forceDock() function, but its final two arguments, which should indicate the dockee's look and up vectors, don't seem to do anything, no matter what sort of matrix I use. I'm using console print-outs to confirm that the matrices themselves are accurate, but the dockee simply never rotates. It always uses the parent's look and up vectors, as if I entered nil for those final two arguments.

Is that expected behaviour?

If not, could you please look into this? I have a great mod in the making (some nice docking mechanics!), but it's stopped totally dead in its tracks because of this behaviour.

====

Koonschi reported that this is already possible / more workable if you use strings for the axes you want your dockees to align to, eg. "x", "-z". I have found it quite tricky to find the right combinations of vectors (which are in the parent's LOCAL SPACE!) to get the orientation I need, as many of the ones I expect to function given the colours of the axes reported in Build Mode as well as console read-outs of Block positions, don't behave to expectations, but with some fiddling of letters you can find them. I reserve the right to hide the fact I may just be terrible at vector Maths. 😉

Edited by Shrooblord

Share this post


Link to post
Share on other sites
  • 0

Yet Another Request™

Add this code (or something similar) to AsyncPirateGenerator:

function AsyncPirateGenerator:setPirateFactionByLevel(_PirateLevel)
    self.pirateLevel = _PirateLevel
end

Or at least make it so I can modify the pirate level of the generator somehow. I already have this set up myself, but I think it would be a nice addition to anyone who wanted to feature the same pirate faction in a mission that spanned two sectors over a large distance.

Share this post


Link to post
Share on other sites
  • 0
local generator = AsyncPirateGenerator()
generator.pirateLevel = my_desired_pirate_level

This is all you need to modify the pirate level.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
On 11/11/2020 at 3:40 AM, koonschi said:

local generator = AsyncPirateGenerator()
generator.pirateLevel = my_desired_pirate_level

This is all you need to modify the pirate level.

Thank you! I'll take a note of that.

Share this post


Link to post
Share on other sites
  • 0

Is there an example of how to color dialogs or change the name in the upper left corner somewhere? I can't find any examples in the script or the documentation.

EDIT / UPDATE: I actually managed to figure this out through pure guesswork / conjecture based on some of the mission utility functions / names, but I still think it would be a good idea to add a resource for others somewhere in the documentation.

EDIT / UPDATE2: I just saw the updated documentation! Looks great!

Edited by Sathaerz

Share this post


Link to post
Share on other sites
  • 0

.borderCombo and .sortCombo are not valid when trying to :hide() them in a InventorySelection()
while .filterTextBox is valid and can be hidden. It'd be nice to be able to hide these elements too.

Share this post


Link to post
Share on other sites
  • 0

Some method to get the camera position in 3d space so i can do projections onto the 2d screen. Was planning on making lead indicators. Or alternatively a vec3/matrix method to project to screenspace so i don't have to do all the math 😛

Edited by Bubbet

Share this post


Link to post
Share on other sites
  • 0
Quote

.borderCombo and .sortCombo are not valid when trying to :hide() them in a InventorySelection()
while .filterTextBox is valid and can be hidden. It'd be nice to be able to hide these elements too.

There are some technical limitations considering the internal types of those ComboBoxes that prohibit a proper exposure to the Scripting API. I'm afraid those will never be available unless we're doing some major internal refactorings, which is unlikely.

Quote

Some method to get the camera position in 3d space so i can do projections onto the 2d screen. Was planning on making lead indicators. Or alternatively a vec3/matrix method to project to screenspace so i don't have to do all the math 😛

Exposing the camera to the Scripting API is planned.

Share this post


Link to post
Share on other sites
  • 0
On 11/25/2020 at 2:16 AM, koonschi said:

Exposing the camera to the Scripting API is planned.

All i was really asking for was something like UIRenderer():calculateEntityTargeter() but for a vec3 in the sector. But full camera modding would be pretty cool too.

Share this post


Link to post
Share on other sites
  • 0

Modding support to change the color and look of the nebulae generated in a sector, the background. Stuff like planets and dustiness is controlled by lua, why not the color and other properties of the sector?

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

I'm not sure if there's already a way to do this in structured mission, but a way to differentiate between client-only triggers and server-only triggers would be awesome.

I guess I could always wrap the declarations in onServer / onClient but that feels kind of gross.

Edited by Sathaerz

Share this post


Link to post
Share on other sites
  • 0

A userdata to emulate ControlAction presses, so i can release the cursor when making a Hud():createWindow() though I'm sure it has plenty of other uses.

Or some functions added to GameInput to set key presses I.E.

GameInput():setKeyDown(ControlAction.ReleaseMouse)

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

The API for torpedoes could use some work. I have a ship with two torpedo tubes that each have 6 available slots. The following code:

local _Player = Player(callingPlayer)
local _Craft = _Player.craft
local _Launcher = TorpedoLauncher(_Craft.index)
local _Shafts = {_Launcher:getShafts()}

for _, _Shaft in pairs(_Shafts) do
    print("K : " .. tostring(_) .. " - V : " .. tostring(_Shaft))
end

print("numShafts : " .. tostring(_Launcher.numShafts) .. " - maxShafts : " .. tostring(_Launcher.maxShafts))

returns 10 shafts in _Shafts, and both numShafts and maxShafts returns 10.

_Launcher:getFreeSlots(_Shaft) will also return 15 if the shaft is unavailable for use.

Trying to dynamically load the launchers based on the number of available slots will KILL the game and corrupt a save to the point where it needs to be restored from a backup.

Edited by Sathaerz

Share this post


Link to post
Share on other sites
  • 0

 

On 1/4/2021 at 4:06 PM, Bubbet said:

A userdata to emulate ControlAction presses, so i can release the cursor when making a Hud():createWindow() though I'm sure it has plenty of other uses.

Or some functions added to GameInput to set key presses I.E.

GameInput():setKeyDown(ControlAction.ReleaseMouse)

Emulation of KeyPresses is not possible.

On 1/9/2021 at 7:56 AM, Sathaerz said:

The API for torpedoes could use some work. I have a ship with two torpedo tubes that each have 6 available slots. The following code:


local _Player = Player(callingPlayer)
local _Craft = _Player.craft
local _Launcher = TorpedoLauncher(_Craft.index)
local _Shafts = {_Launcher:getShafts()}

for _, _Shaft in pairs(_Shafts) do
    print("K : " .. tostring(_) .. " - V : " .. tostring(_Shaft))
end

print("numShafts : " .. tostring(_Launcher.numShafts) .. " - maxShafts : " .. tostring(_Launcher.maxShafts))

returns 10 shafts in _Shafts, and both numShafts and maxShafts returns 10.

_Launcher:getFreeSlots(_Shaft) will also return 15 if the shaft is unavailable for use.

Trying to dynamically load the launchers based on the number of available slots will KILL the game and corrupt a save to the point where it needs to be restored from a backup.

If you encounter crashes in the API, please submit a bug report with a fully working example.

Share this post


Link to post
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

×
×
  • Create New...