Re: [MOD 0.14] AAI Programmable Vehicles
Posted: Fri Jun 23, 2017 1:18 pm
you can already provide distance and angle signals to a follow unit or player signal to make a custom formation
I finally got back into the save....sumdawgy wrote: IT worked fine before i got a decider connected to it....hm.
Did you already have the Electric Vehicles mod or did you only install that after the problem started?Mobius1 wrote:Found a bug with Aircraft Mod and AAI PV:
I built an airplane with rocket weapon, placed it down, put "Vehicle Fuel" on it, after it used fully the 2nd unit of fuel, the vehicle just stop completely and didn't want to move again even picking it up and popping it down didn't make it move. The vehicle could turn but not move forward or backwards. Vehicle itself is the Flying Fortress. Tried putting other types of fuel on it and it didn't fill the fuel bar. I installed Electric Vehicles mod, put the electric engine on the plane and then it filled the fuel bar and started to move again.
After the problem. Also I'm running a shitload of mods:Earendel wrote:Did you already have the Electric Vehicles mod or did you only install that after the problem started?
fixed function in control.lua:Earendel wrote:Did you already have the Electric Vehicles mod or did you only install that after the problem started?Mobius1 wrote:Found a bug with Aircraft Mod and AAI PV:
I built an airplane with rocket weapon, placed it down, put "Vehicle Fuel" on it, after it used fully the 2nd unit of fuel, the vehicle just stop completely and didn't want to move again even picking it up and popping it down didn't make it move. The vehicle could turn but not move forward or backwards. Vehicle itself is the Flying Fortress. Tried putting other types of fuel on it and it didn't fill the fuel bar. I installed Electric Vehicles mod, put the electric engine on the plane and then it filled the fuel bar and started to move again.
Code: Select all
local function consume_fuel_or_equipment (unit)
if unit.vehicle.grid and unit.vehicle.grid.available_in_batteries > 10000 then
--Added by Undarl; basic battery fueling logic courtesy of Sirenfal
---Modified by the Nexela
local player = game.players[1]
player.print("consume_fuel_or_equipment")
unit.vehicle.burner.currently_burning = high_fuel_item
local energy_deficit = game.item_prototypes[high_fuel_item].fuel_value - unit.vehicle.burner.remaining_burning_fuel
local batteries = table.filter(unit.vehicle.grid.equipment, function(v) return v.type == "battery-equipment" end)
if batteries then player.print("batteries is present(" .. #batteries .. ") energy = " .. unit.vehicle.grid.available_in_batteries) end
local num_batteries = #batteries
while num_batteries > 0 and energy_deficit > 0 do
local battery = batteries[num_batteries]
local energy_used = math.min(battery.energy, energy_deficit)
player.print("energy_deficit(" .. energy_deficit .. ") energy battery = " .. battery.energy)
player.print("energy_used(" .. energy_used .. ")")
battery.energy = battery.energy - energy_used
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + energy_used
energy_deficit = energy_deficit - energy_used
num_batteries = num_batteries - 1
end
else
for _, inv_num in pairs(inv_nums) do
local inventory = unit.vehicle.get_inventory(inv_num)
if inventory then
local contents = inventory.get_contents()
local fuel_item = get_fuel.item(contents)
if fuel_item then
if inv_num ~= defines.inventory.fuel then
if contents[fuel_item.name] > 1 then
-- move fuel to fuel inventory
unit.vehicle.burner.currently_burning = fuel_item.name
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + fuel_item.fuel_value
local fuel_inv = unit.vehicle.get_inventory(defines.inventory.fuel)
local inserted = fuel_inv.insert{name = fuel_item.name, count = contents[fuel_item.name] -1}
if inserted > 0 then
inventory.remove({name = fuel_item.name, count = inserted})
end
else
unit.vehicle.burner.currently_burning = fuel_item.name
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + fuel_item.fuel_value
inventory.remove({name=fuel_item.name, count=1})
end
else
-- burning from correct slot
unit.vehicle.burner.currently_burning = fuel_item.name
unit.vehicle.burner.remaining_burning_fuel = unit.vehicle.burner.remaining_burning_fuel + fuel_item.fuel_value
inventory.remove({name=fuel_item.name, count=1})
return true
end
end
end
end
end
end
Thanks, added.regedit2000 wrote: fixed function in control.lua:
There is time since last moved and time since last targeted enemy. It's not aware of things like mining or other things that special vehicles do.Sworn wrote:Would be possible to add one more signal to the unit scanner reads. An IsIdle signal? so you don't have to "guess" base on the last command or with some math on the X and Y if the last command was done.
Something like a signal that appears as 1 [or total idle time] since the last command was completed (when the unit has stopped all actions like [not shotting, not moving, not mining, or whatever]).
The API limitation means that the vehicle color can only be changed by a player getting in, there's not much I can do about that.Berkys32 wrote:How to setup vehicle color? I see colored vehicles on your screens, but cant get it too.
And is there any signal to cancel current order? I wanted to send Speed 0 but than realized its not signal at all, than I tried signal X and Y of that vehicle, but instead of just stop its "moving" on place...
And is there any Discord channel for AAI?
Could you explain how the [Time since moved tile] is updated? I was making some test with it and build the following setup:Earendel wrote:regedit2000 wrote:There is time since last moved and time since last targeted enemy. It's not aware of things like mining or other things that special vehicles do.Sworn wrote:Would be possible to add one more signal to the unit scanner reads. An IsIdle signal? so you don't have to "guess" base on the last command or with some math on the X and Y if the last command was done.
Something like a signal that appears as 1 [or total idle time] since the last command was completed (when the unit has stopped all actions like [not shotting, not moving, not mining, or whatever]).
Berkys32 wrote:Signal "Time since moved tile" > 500 seems quite enough for me, even in case it got stuck bcs of tree...
Im not sure what do you mean by "move to tile" signal. You mean go to x/y pos?
Which bits exactly have to be deleted? I broke the mod trying to accomplish that.buggy123 wrote:Would it be possible to add a setting to toggle the 1-weapon-per-vehicle mechanic? It's possible to disable it by deleting a few bits in entity-update and entity-update-external but its kind of annoying doing it after every update.