Jump to content

mine.lua and salvage.lua call setAIAction, but it doesn't work


Rinart73

Recommended Posts

When mining/salvaging AI ship can't find an asteroid/wreckage it does this:

 

ShipAI(ship.index):setPassive()
ship:invokeFunction("craftorders.lua", "setAIAction")

 

But CraftOrders.setAIAction calls checkEntityInteractionPermissions function:

local owner, _, player = checkEntityInteractionPermissions(Entity(), AlliancePrivilege.ManageShips)

this functions uses callingPlayer and since it's nil in this case, this check will not be passed and icon will not be changed.

 

Two ways to fix this:

 

1. To fake 'callingPlayer':

if ship.playerOwned then
    callingPlayer = ship.factionIndex
elseif ship.allianceOwned then
    callingPlayer = Alliance(ship.factionIndex).leader
end
ship:invokeFunction("craftorders.lua", "setAIAction")
callingPlayer = nil

 

2. To change checkEntityInteractionPermissions code so if callingPlayer is nil, the result of check is true

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
×
×
  • Create New...