[MOD 0.14] AAI Programmable Vehicles

Topics and discussion about specific mods
alercah
Fast Inserter
Fast Inserter
Posts: 151
Joined: Sun Apr 07, 2019 5:19 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by alercah »

This is very neat! A few quick questions/notes:

1. The images in the first post seem broken and/or misplaced?
2. Can you provide a precise description of how resource exchange works? I'm having a hard time grasping the particulars from the examples. If it's be helpful I can explain exactly the points that aren't clear.
3. Is the blueprint addition you're planning similar to recursive blueprints and similar mods?
4. And one that's technically about the structures: Are the X and Y coordinates in the controller structures absolute or relative? What does sub-X and sub-Y actually mean?

RocketManChronicles
Filter Inserter
Filter Inserter
Posts: 347
Joined: Mon Aug 01, 2016 2:38 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by RocketManChronicles »

I plan to place a few blue prints here in the near future, I just want to make sure some of my builds don't have issues in them before posting. I do have a resource gatherer that is fairly robust. It is based off of Nilaus' build cycling through various states, but at a slower rate to not use a ton of UPS.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Feature request: AAi programmable boat and tanker

Post by mrvn »

It would be nice if there were a small boat with maybe a machine gun and a small radar that it AAI programmable. A ferry for ores might be cool too. I would also love to have a tanker to transport fluids using AAI vehicles.

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by mrvn »

RocketManChronicles wrote:
Wed May 29, 2019 12:21 am
I plan to place a few blue prints here in the near future, I just want to make sure some of my builds don't have issues in them before posting. I do have a resource gatherer that is fairly robust. It is based off of Nilaus' build cycling through various states, but at a slower rate to not use a ton of UPS.
It might be better to add a tutorial to the mod. Even if it just a demo world with some structure set up and some explanations given. It doesn't have to be a step by step guid on how to design everything. The users can then switch to the tutorial any time during the game and make blueprints of things they like or compare your setup against theirs. And you don't end up being on vacation playing factorio unable to access the web for the blueprints.

User avatar
regedit2000
Inserter
Inserter
Posts: 20
Joined: Mon May 23, 2016 4:00 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by regedit2000 »

Earendel wrote:
Thu May 16, 2019 11:45 pm
These changes are part of the mod now. There were a few issues but they have been resolved.
Now there is no need to "cut" the guns at the car
viewtopic.php?p=434545#p4345458

Saevon
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Mar 27, 2016 9:36 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Saevon »

My friends kept trying to attack with vehicles, but were expecting full RTS style controls, aka saving+loading unit groups.

I've modded that in, and would appreciate it if you could include that in your mod? I couldn't find a way to get access to "selected unit" data by writing my own mod (using remote interfaces), nor find a github (or equivalent) to post this as a pull-request instead.

Sorry if this is a little long, wasn't sure how else to post this... (Do you watch/accept PMs for stuff like this instead? is there a better way to get this to you?)

locale/en/strings.cfg

Code: Select all


[aai-programmable-vehicles]
error-no-units-selected=No Units to save as group

[controls]
save-unit-group-1=Save Unit group 1
save-unit-group-2=Save Unit group 2
save-unit-group-3=Save Unit group 3
save-unit-group-4=Save Unit group 4
save-unit-group-5=Save Unit group 5
save-unit-group-6=Save Unit group 6
save-unit-group-7=Save Unit group 7
save-unit-group-8=Save Unit group 8
save-unit-group-9=Save Unit group 9
save-unit-group-0=Save Unit group 0
load-unit-group-1=Load Unit group 1
load-unit-group-2=Load Unit group 2
load-unit-group-3=Load Unit group 3
load-unit-group-4=Load Unit group 4
load-unit-group-5=Load Unit group 5
load-unit-group-6=Load Unit group 6
load-unit-group-7=Load Unit group 7
load-unit-group-8=Load Unit group 8
load-unit-group-9=Load Unit group 9
load-unit-group-0=Load Unit group 0
control.lua

Code: Select all

function on_save_unit_group(event, name)
  local player = game.players[event.player_index]
  UnitRemote.save_unit_group(player, name)
end

function on_load_unit_group(event, name)
  local player = game.players[event.player_index]

  -- Grab a controller if we can (for consistency, though select_units could do this instead)
  on_keypress_create_toggle_controller({player_index=event.player_index})
  if (player.cursor_stack.name ~= 'unit-remote-control') then
    -- Swap to the unit controller if its on the other one
    player.cursor_stack.set_stack({name="unit-remote-control"})
  end

  UnitRemote.load_unit_group(player, name)
end


function on_configuration_changed(data)
    global.unit_selection_groups = global.unit_selection_groups or {}
end


-- Create the event callbacks for save/load unit group
for i = 0,9 do
  -- Closure for saving the i
  (function(i)
    Event.addListener("load-unit-group-" .. i, function(event) on_load_unit_group(event, i) end)
    Event.addListener("save-unit-group-" .. i, function(event) on_save_unit_group(event, i) end)
  end)(i)
end
scripts/unit-remote.lua

Code: Select all


-- Saves the current selection, using the given name
-- (per-player)
function UnitRemote.save_unit_group(player, name)
  local unit_sel = global.player_selected_units[player.index]
  if unit_sel == nil then
    -- No units selected, User mistakenly used this shortcut
    player.print({"aai-programmable-vehicles.error-no-units-selected"})
    return
  end

  if global.unit_selection_groups[player.index] == nil then
    global.unit_selection_groups[player.index] = {}
  end

  local selection = {}
  for _i, unit in pairs(unit_sel) do
    selection[unit.unit.unit_id] = unit.unit
  end

  global.unit_selection_groups[player.index][name] = selection
end

-- Loads the saved selection
-- (per-player)
function UnitRemote.load_unit_group(player, name)
  if global.unit_selection_groups[player.index] == nil then
    return UnitRemote.deselect_units(player)
  end

  local unit_sel = global.unit_selection_groups[player.index][name]

  if unit_sel == nil then
    return UnitRemote.deselect_units(player)
  end

  local units = {}
  for _i, unit in pairs(unit_sel) do
    -- TODO: Handle deleted units (Check for active unit before doing the insert here?)
    table.insert(units, unit)
  end

  -- TODO: selecting units when you're in a vehicle doesn't seem to work
  --    it just selects the vehicle you're in (and doesn't load the group)
  UnitRemote.select_units(player, units)
end
prototypes/input.lua

Code: Select all

    {
        type = "custom-input",
        name = "load-unit-group-1",
        key_sequence = "CONTROL + 1",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-2",
        key_sequence = "CONTROL + 2",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-3",
        key_sequence = "CONTROL + 3",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-4",
        key_sequence = "CONTROL + 4",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-5",
        key_sequence = "CONTROL + 5",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-6",
        key_sequence = "CONTROL + 6",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-7",
        key_sequence = "CONTROL + 7",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-8",
        key_sequence = "CONTROL + 8",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-9",
        key_sequence = "CONTROL + 9",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "load-unit-group-0",
        key_sequence = "CONTROL + 0",
        enabled_while_spectating = true,
    },


    -- Loading a saved group
    {
        type = "custom-input",
        name = "save-unit-group-1",
        key_sequence = "CONTROL + SHIFT + 1",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-2",
        key_sequence = "CONTROL + SHIFT + 2",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-3",
        key_sequence = "CONTROL + SHIFT + 3",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-4",
        key_sequence = "CONTROL + SHIFT + 4",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-5",
        key_sequence = "CONTROL + SHIFT + 5",
        enabled_while_spectating = true,
    },
{
        type = "custom-input",
        name = "save-unit-group-6",
        key_sequence = "CONTROL + SHIFT + 6",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-7",
        key_sequence = "CONTROL + SHIFT + 7",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-8",
        key_sequence = "CONTROL + SHIFT + 8",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-9",
        key_sequence = "CONTROL + SHIFT + 9",
        enabled_while_spectating = true,
    },
    {
        type = "custom-input",
        name = "save-unit-group-0",
        key_sequence = "CONTROL + SHIFT + 0",
        enabled_while_spectating = true,
    },

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

The control groups code looks good. I'll add it in and give it a test.

Saevon
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Mar 27, 2016 9:36 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Saevon »

Theres two TODOs in there I'm trying to figure out:

1) You cannot seem to deselct a vehicle you're in (I notice that normally as well, my unit controller keeps deselecting units other than the one I'm in)
2) Destroyed units can be selected, which causes the game to say "One or more units has no power", but I expected the UnitRemote to prevent selection of dead units (as it seems to when I mine the entity?)

I'll post an update if I can figure it out

Saevon
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Mar 27, 2016 9:36 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Saevon »

I've found a bug, if a dead player attempts to load a unit-group, the game will crash (something about checking their cursor-stack)

Debugging right now

Aerropagus
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Jun 25, 2019 1:54 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Aerropagus »

Hello, I have a new bug to report - I have no idea what info you need from me but will attempt to get it to you if you private message me.
The mod AAI Programmable Vehicles caused a non-recoverable error.
Please report this error to the mod author.

Error while running event aai-programmable-vehicles::on_gui_click (ID 1)
Index out of bounds: 61
stack traceback:
__aai-programmable-vehicles__/control.lua:2957: in function 'set_unit_data_to_combinator'
__aai-programmable-vehicles__/control.lua:3011: in function 'remote_on_gui_click'
__aai-programmable-vehicles__/control.lua:3307: in function 'callback'
__aai-programmable-vehicles__/scripts/event.lua:14: in function <__aai-programmable-vehicles__/scripts/event.lua:12>
stack traceback:
[C]: in function '__newindex'
__aai-programmable-vehicles__/control.lua:2957: in function 'set_unit_data_to_combinator'
__aai-programmable-vehicles__/control.lua:3011: in function 'remote_on_gui_click'
__aai-programmable-vehicles__/control.lua:3307: in function 'callback'
__aai-programmable-vehicles__/scripts/event.lua:14: in function <__aai-programmable-vehicles__/scripts/event.lua:12>

poma
Burner Inserter
Burner Inserter
Posts: 13
Joined: Sun Sep 25, 2016 1:06 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by poma »

Compatibility problem with Angel's vehicles:

When using remote control on a Crawler vehicle, it empties generator's storage in its power grid

Desktop recording: https://youtu.be/S734RCq5sTs

I put coal into generator and after using remote control the coal is gone. The same happens when I first enter and exit the vehicle after using auto pilot, after that manual driving works fine, but when I try to use AI pilot again it again empties generator's fuel slots. It will also cause any Angel's bots from vehicle's roboport to get stuck in the air until I manually mine them.

What do you need to help debugging this?

skipsinclair
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Jul 13, 2016 1:00 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by skipsinclair »

OK, so first off, love the mod. Been following Nilaus' Space Exploration series, got me involved in the AAI programmable stuff. With the video's help, I was able to figure out marking a zone and iterating through the zone to delete non-ore tiles, all set. But, let's say I want to send 10 miners to a particularly large patch of ore... what's the best way of spreading out the miners throughout the (already defined) zone? And how do I get them to move on their own through the zone until it's depleted? I know I can setup a hauler to cycle through the miners, that's no problem. But my miners end up stripping the patch they're on, then just waiting until I manually move them. I didn't think merely setting a loop for them would work, as I need them to process everything around their immediate area, then move on to the next valid ore tile...

Any suggestions? I don't want to have to move them manually, I want to set something in place to have them strip out an entire patch on their own.

slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by slippycheeze »

Hey, I finally got around to trying this out, because it looked cool. Turns out, wow, but it is! Great stuff!

Like a couple people before me I got kind of lost between the first post, and the new 0.17 model; I think I have the basics of the new style strategy now, but I'm not entirely clear on anything beyond that. I think that I use the paths for a brief period with no automation, and for simple things like "patrol the perimeter" or "guard this unit, and it will lead you", but use the "classic" model with, eg, zone scanning, marking, and clearing, to direct things like miners to fetch resources from the right places.

You mentioned earlier that adding more pictures was beyond the forums, and said that maybe something on Google Drive would be a good way to handle the documentation - I'd certainly agree with that. If it was me, I'd just write it up in a Google Doc, then share it with "anyone with the link can view" or maybe "comment" permissions. It'll be fine for simple text and image layout, which is all you really need.... well, ok, all I really need, I guess. :)

If that isn't something you have time, or interest, in doing, let me know. I'll probably write up something for my own use, and share it here so everyone can tell me how much of it I got wrong. ;)


Beside that, can I clarify something:

When I set up a path it'll wayfind to locations, but it will NOT wayfind to a vehicle. That just goes in a direct line, so if I want to navigate I should path to a location, eg, next to the ore patch, then waypoint to the vehicle, then back to a known location waypoint before I start to head out again, yes?

dorfl
Inserter
Inserter
Posts: 44
Joined: Mon May 28, 2018 12:49 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by dorfl »

poma wrote:
Tue Jul 02, 2019 10:48 am
Compatibility problem with Angel's vehicles:

When using remote control on a Crawler vehicle, it empties generator's storage in its power grid

Desktop recording: https://youtu.be/S734RCq5sTs

I put coal into generator and after using remote control the coal is gone. The same happens when I first enter and exit the vehicle after using auto pilot, after that manual driving works fine, but when I try to use AI pilot again it again empties generator's fuel slots. It will also cause any Angel's bots from vehicle's roboport to get stuck in the air until I manually mine them.
I encounter this too, but it's for all vehicles with energy generators in grids. not just Angel's Crawler. Eg, the Warden with Portable Power mod is affected too.

AAI replaces vehicle entities and issues an on_entity_replaced event in several situations. For example, the unit_number of cars changes when they switch AI mode (also when starting moving / pathing I think?). The mod's util.transfer_equipment_grid function needs to know about copying burner inventories for grid equipment. That's probably possible.

But I suspect robots getting stuck might remain a problem whenever vehicles are replaced like this. My theory ;) is the change in vehicle also causes a change of local robot network id for the vehicle grid's roboport, and so the bots get momentarily lost, then freeze or just reassign to the nearest base robot network and fly home.

Samwu
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Aug 03, 2019 9:28 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Samwu »

hello, do you have a plan to create an AAI-specific Combinator to simplify circuit network, vanilla combinator is too simple to process some complex command.
my idea like that, just for your reference ;)
Step 1. build circuit network to create a command and set a function single to the command - like to mine/ to attack / move to position etc.
Step 2. build another circuit network to check the status for all AAI-vehicles
Step 3. when some conditions come true, it will output vehicle id and some other parameters(move to designated position etc)
Step 4. input function single / function parameters(position etc) / vehicle id
Step 5. Designated vehicle will execute the command

good thing is that we can easily to input the different vehicle id to execute the same function, void to build the circuit network again and again, reduce the AAI building can save fps also.

your mod is amazing and could have infinite possibilities :D :D :D :D :D

slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by slippycheeze »

Samwu wrote:
Sat Aug 03, 2019 10:07 am
hello, do you have a plan to create an AAI-specific Combinator to simplify circuit network, vanilla combinator is too simple to process some complex command.
I wouldn't think they really need to: simply use the Lua Combinator 3 (or version 2 of the same), which allow you as much programmability as you wish, as trivially as you could wish.

Samwu
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Aug 03, 2019 9:28 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Samwu »

slippycheeze wrote:
Sat Aug 03, 2019 12:33 pm
Samwu wrote:
Sat Aug 03, 2019 10:07 am
hello, do you have a plan to create an AAI-specific Combinator to simplify circuit network, vanilla combinator is too simple to process some complex command.
I wouldn't think they really need to: simply use the Lua Combinator 3 (or version 2 of the same), which allow you as much programmability as you wish, as trivially as you could wish.
I'm agreed with you Lua Combinator 3 can do anything! because we code it :lol: , but it wouldn't bring me much fun in game, be honest, writing code and building network are different feelings. ;)

JamesFire
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jul 20, 2019 10:32 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by JamesFire »

Can I have circuits automatically modify the unit data so that they accept ammo and fuel? When placed by the vehicle deployment, they have nothing in there. When I place them by hand, they are missing the fuel I want.

RocketManChronicles
Filter Inserter
Filter Inserter
Posts: 347
Joined: Mon Aug 01, 2016 2:38 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by RocketManChronicles »

JamesFire wrote:
Sun Aug 11, 2019 1:36 am
Can I have circuits automatically modify the unit data so that they accept ammo and fuel? When placed by the vehicle deployment, they have nothing in there. When I place them by hand, they are missing the fuel I want.
Yes you can. It has been a couple years (for me), but iirc you can have signals fed into the Vehicle Deployment Building that "program" the vehicle coming out of it. I used this primarily for the Haulers for various resource runs I had going and Wardens that patrolled the perimeter of the base. What resources they can accept, what fuels to use, etc.

Kevinmccart1
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Aug 13, 2019 4:12 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Kevinmccart1 »

Anyone Notice how the Zones are getting auto deleated even when you haven't set up the zone clearer yet is anyone else haveing this problem I first noticed it when I was trying to set up an ore feild to be auto mined and all my Zones just started getting deleated so i put up the auto zone scanner to replaces them faster and they still dissaperred even with out a zone clearing network set up

Post Reply

Return to “Mods”