Jump to content
  • 1
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 totally agree, stations have a higher weight in the equation but due to OOSP there's no need to keep them loaded over sectors with ships in them.

 

Maybe we should make an API request (sticky)  thread to keep track of these as the requests have been quite scattered around on the forums.

Share this post


Link to post
Share on other sites
  • 0

Maybe we should make an API request (sticky)  thread to keep track of these as the requests have been quite scattered around on the forums.

 

Good Idea. Well I'll turn this thread into such one and ask devs to make it sticky.

 

Already got another request for scritping API:

 

Galaxy().name

is really missing.

 

Also it would be great to get the path to the galaxy folder like

Galaxy():getPath()

Share this post


Link to post
Share on other sites
  • 0

In any patch some time ago Timer().microseconds was removed from API. The lowest unit is now milliseconds, wich may be still too huge sometimes for performence improvements. Can you please give us back microseconds?

Share this post


Link to post
Share on other sites
  • 0

In any patch some time ago Timer().microseconds was removed from API. The lowest unit is now milliseconds, wich may be still too huge sometimes for performence improvements. Can you please give us back microseconds?

 

We can't, sadly. Not all operating systems (including Windows) support sub-millisecond resolution. That means, the microsecond api already only gave you millisecond resolution, meaning it didn't behave as intended. That's why we removed it.

Share this post


Link to post
Share on other sites
  • 0

Not sure if this is the correct place to request such a thing, but certain read-only attributes would be really nice to have writable. I'm thinking of things like Sector.name.

 

If we could rename our Sectors, we can make our Galaxy feel much more alive, and part of our own creative expression. I'm only asking for a switch from a read-only attribute to a writable format. I could take care of the renaming functionality (including checks to see if you "own" the Sector etc. etc.) by way of a mod. But I can't mod in the write attribute of engine-defined values...!

 

Other read-onlys that would be awesome to have writable:

-Alliance.name

-Alliance.color1, Alliance.color2, Alliance.color3

-Faction.name

-Faction.color1, Faction.color2, Faction.color3

-Player.color1, Player.color2, Player.color3

 

This request is basically all in name of carving your own identity into the Galaxy as you play Avorion, which in my opinion is one of the key draws that make Avorion so engaging. Let's make that even more engaging.

Share this post


Link to post
Share on other sites
  • 0

We need an API to turn turrets on and off and to make them attack different targets (or to not attack anything). This would be useful for AI ships.

For example you could have a mining ship with a "setPassiveShooting(true)" so it could mine with mining turrets and defend itself with battle turrets at the same time.

Share this post


Link to post
Share on other sites
  • 0

We can't, sadly. Not all operating systems (including Windows) support sub-millisecond resolution. That means, the microsecond api already only gave you millisecond resolution, meaning it didn't behave as intended. That's why we removed it.

 

This answer is from 7 years ago. QueryPerformanceCounter has been around since WinXP. In fact, I can't find any common OS /Language that doesn't support microsecond timing.

Share this post


Link to post
Share on other sites
  • 0

We can't, sadly. Not all operating systems (including Windows) support sub-millisecond resolution. That means, the microsecond api already only gave you millisecond resolution, meaning it didn't behave as intended. That's why we removed it.

 

This answer is from 7 years ago. QueryPerformanceCounter has been around since WinXP. In fact, I can't find any common OS /Language that doesn't support microsecond timing.

 

As far as I remember microseconds worked fine until it got removed... wich means it really threw out microseconds and not milliseconds.

Share this post


Link to post
Share on other sites
  • 0

We can't, sadly. Not all operating systems (including Windows) support sub-millisecond resolution. That means, the microsecond api already only gave you millisecond resolution, meaning it didn't behave as intended. That's why we removed it.

 

This answer is from 7 years ago. QueryPerformanceCounter has been around since WinXP. In fact, I can't find any common OS /Language that doesn't support microsecond timing.

 

Hey!

 

I think I have some explaining to do here.

There is different kinds of time measurement that can be done. Absolute and relative measurements.

The difference is that absolute measurements guarantee do be consistent (multiple timers return the same value, distant machines can be synchronized).

Relative time measurements do not guarantee that, therefore they can only be used to measure small intervals. They are mainly used for performance optimization. They can NOT be used to actually time stuff that needs to be consistent.

 

In the actual game code, we have two timers, one default timer for absolute values and a HighResolutionTimer for performance optimizations.

The timer that is exposed in lua is the default timer. It is based on std::chrono::high_resolution_clock and only gives millisecond resolution on windows.

There is no way to measure absolute sub-millisecond resolution time on windows.

The second timer also uses std::chrono::high_resolution_clock on linux, but falls back on QueryPerformanceCounter on windows. By that, it loses its absolute property.

It can only be used for performace optimization and is currently not exposed to lua. If you guys need that, we could write a lua api for that HighResolutionTimer (just for performance optimizations).

 

I hope that  clears things up. Let me know if we should write an api for the second timer.

 

Edit: There IS a sub-millisecond absolute timer on windows, called GetSystemTimePreciseAsFileTime. It got introduced in Windows 8 though, and as we support Windows 7 we can't use it.

Share this post


Link to post
Share on other sites
  • 0

 

I hope that  clears things up. Let me know if we should write an api for the second timer.

 

 

Sometime I just have to laugh at myself. For me, this is a single player game. When I made my original comment I never even considered having to synchronize clients over the internet. And now that you brought it up, I *do* remember seeing this post on Stack Overflow but didn't actually scroll all the way down to read some other answers.  Live and learn.

 

As far as implementing QueryPerformanceCounter - I don't see myself using it, nothing I plan on modding needs that kind of precision.

 

However, with hopes that you (the developer) may read this -  could you please keep this project in the back of your minds, or others like it - I know it's a long shot, but my brain tingles with the possibilities.

Share this post


Link to post
Share on other sites
  • 0

If you guys need that, we could write a lua api for that HighResolutionTimer (just for performance optimizations).

 

I hope that  clears things up. Let me know if we should write an api for the second timer.

 

Edit: There IS a sub-millisecond absolute timer on windows, called GetSystemTimePreciseAsFileTime. It got introduced in Windows 8 though, and as we support Windows 7 we can't use it.

 

Hi Martin, thank you for the explanations.

 

For performance optimizations a timer with microseconds would be great, cause small operations may be done in 1 or 0 milliseconds. On the other side I think there are currently some more important things that has to be done in the game (bugfixing and so on) then writing a whole API just for better timer resolution.

Share this post


Link to post
Share on other sites
  • 0

Hi Martin, thank you for the explanations.

 

For performance optimizations a timer with microseconds would be great, cause small operations may be done in 1 or 0 milliseconds. On the other side I think there are currently some more important things that has to be done in the game (bugfixing and so on) then writing a whole API just for better timer resolution.

Don't worry, it's basically just copy-paste of the other timer. Should be available in the next patch.

Share this post


Link to post
Share on other sites
  • 0

It would be cool to have an API that would allow to attack an entity without moving the ship.

Currently I'm trying to use:

local ai = ShipAI()
ai:registerEnemyEntity(target.index)
ai:setPassiveShooting(true)

But it doesn't work well and in theory ship may switch targets automatically if it will find another enemy ship nearby.

Share this post


Link to post
Share on other sites
  • 0

Also, currently there is no cheat-proof way for server-side to know when sector is loaded on client-side.

Callbacks like "onPlayerEntered" and other fire when player changes sector on server-side.

 

Maybe you could prevent any actions from player until they will confirm that sector is loaded on their side and make a callback out of it? It would be useful, for example modders could use it to protect ships after jump while player is loading.

Share this post


Link to post
Share on other sites
  • 0

I've got a relatively small request:

 

add something like

function Entity, ... getEnemies(var relationThreshold)

to shipAI.

The Intention is to have quick access to all Enemy Entities, in cases where "getNearestEnemy()" does not return the most reasonable target. (E.g. it selects a fighter close by, but the Big Mainship might be a better target...)

Share this post


Link to post
Share on other sites
  • 0

A function to get the started fighters of a specific squad of an specific Entity.

It would best reside in FighterController, because it already controls them.

Something like this:

 

function Entity... getStartedFightersOfSquad(unsigned int squadIndex)

 

That should be much better than (my) current workaround:

local fighters = {Sector():getEntitiesByType(EntityType.Fighter)}
for _,fighter in pairs(fighters) do
    local fAI = FighterAI(fighter)
    if fAI.mothershipId.number == Entity().index.number and fAI.squad == searchedSquadIndex then
        --do something
    end
end

Share this post


Link to post
Share on other sites
  • 0

There is no way to know if the chat is open. So for example I want to track when presses "T" key. And it will fire even when player types in the chat.

I'm not saying it shouldn't fire, just add the way to know when player types in the chat and when they just press a key during the game.

Share this post


Link to post
Share on other sites
  • 0

Expose some Sector() variables that are currently read-only to have write-access, such as the Sector name. Being able to rename your claimed Sectors would help considerably in immersing yourself in the "Galactic Civilisation Sim" that is such a large part of what Avorion is about.

 

I'm not asking for the renaming functionality. I could mod in the renaming functionality. I'm only asking for write-access to the Sector() values that are currently locked behind a C++ wall that I can't do anything about.

 

Thank you for your consideration.

Share this post


Link to post
Share on other sites
  • 0

Expose Custom Turret Designs to scripts by creating a loadTurretPlanFromFile(path) function that works the same as LoadPlanFromFile(path), except it specifically works for Turret Designs so we can stick them onto our Turret Blocks in-script. This would be excellent for designing custom turrets to be used by custom ships spawned in by scripts. For example: custom-designed coaxial guns for a giant boss battle with a ship designed specifically for that mod.

Share this post


Link to post
Share on other sites
  • 0

It would be really nice to get a few options in regards to the debug console:

 

1) Option to set number of lines shown / use more than half the screen

 

2) Scrolling up - some mistakes output more then you can fit on a screen

 

3) Fontsize would be nice - the eyestrain can get pretty bad

Share this post


Link to post
Share on other sites
  • 0

It would be nice to be able to check if faction/entity is registered as enemy/friendly in the ShipAI.

So, for example when you provoke Xsotan, they register your faction as enemy. And you can't effectively check if you provoked them.

Something like:

ShipAI(entity):isFriendlyFaction(factionIndex)

Share this post


Link to post
Share on other sites
  • 0

Add a way to highlight multiple sectors on Galaxy Map like when player types something in the search bar.

Modders could use it to show where event is happenning or make a custom search etc.

Share this post


Link to post
Share on other sites
Guest
Answer this suggestion...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...