Using vehicle.vehicle_logistic_requests_enabled allows me to change the state of a spider-vehicles "Personal logistics and auto-trash" checkbox, but I can't figure out how to modify the "Request from buffer chests" checkbox. Apparently, vehicle.request_from_buffers works for requester chests only, not for spider-vehicles. Could somebody tell me which property I need to modify that checkbox?
Spider-vehicle: How do I set "Request from buffer chests?"
Spider-vehicle: How do I set "Request from buffer chests?"
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Spider-vehicle: How do I set "Request from buffer chests?"
From https://lua-api.factorio.com/latest/Classes.html:
vehicle_logistic_requests_enabled
:: boolean
[RW]
If personal logistic requests are enabled for this vehicle (spidertron).
vehicle_logistic_requests_enabled
:: boolean
[RW]
If personal logistic requests are enabled for this vehicle (spidertron).
Re: Spider-vehicle: How do I set "Request from buffer chests?"
Thanks, I know that, this actually works. I was interested in the other setting (the one marked with red). However, it occurred to me that it may work after all: To enabele vehicle_logistic_requests_enabled, I had to insert an item into the grid, and then switch over to the logistics tab. When I activated request_from_buffer_chests from my own GUI, the state of the checkbox on the spider-tron's GUI didn't change. That may have been because I didn't update the display. But I can't test that right now -- not at the computer with Factorio.mrvn wrote: Mon Sep 12, 2022 9:09 pm From https://lua-api.factorio.com/latest/Classes.html:
vehicle_logistic_requests_enabled
:: boolean
[RW]
If personal logistic requests are enabled for this vehicle (spidertron).

A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Spider-vehicle: How do I set "Request from buffer chests?"
Ah, sorry. I was confused because you already had the only other thing related to the logistic requests in the spidertron in the question.
But you might be right that you actually just have to close and reopen the GUI to see any changes made by scripts.
But you might be right that you actually just have to close and reopen the GUI to see any changes made by scripts.
Re: Spider-vehicle: How do I set "Request from buffer chests?"
No problem!mrvn wrote: Tue Sep 13, 2022 12:43 am Ah, sorry. I was confused because you already had the only other thing related to the logistic requests in the spidertron in the question.
That worked! Too bad we can't auto-update the display. Closing and reopening the GUI has no effect when it's done on the same tick, and reopening the GUI on the next tick comes with a bit of overhead: store open GUI of player, then check all players in on_tick if they have a GUI to reopen.But you might be right that you actually just have to close and reopen the GUI to see any changes made by scripts.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Spider-vehicle: How do I set "Request from buffer chests?"
You can register an event for 1 tick later so it's no overhead unless a GUI was closed. How often are you going to toggle this?Pi-C wrote: Tue Sep 13, 2022 9:35 pmNo problem!mrvn wrote: Tue Sep 13, 2022 12:43 am Ah, sorry. I was confused because you already had the only other thing related to the logistic requests in the spidertron in the question.
That worked! Too bad we can't auto-update the display. Closing and reopening the GUI has no effect when it's done on the same tick, and reopening the GUI on the next tick comes with a bit of overhead: store open GUI of player, then check all players in on_tick if they have a GUI to reopen.But you might be right that you actually just have to close and reopen the GUI to see any changes made by scripts.
Re: Spider-vehicle: How do I set "Request from buffer chests?"
Autodrive already checks the vehicles it's managing on every tick, skipping expensive things like charting most of the time:mrvn wrote: Wed Sep 14, 2022 12:10 amYou can register an event for 1 tick later so it's no overhead unless a GUI was closed. How often are you going to toggle this?Pi-C wrote: Tue Sep 13, 2022 9:35 pm Too bad we can't auto-update the display. Closing and reopening the GUI has no effect when it's done on the same tick, and reopening the GUI on the next tick comes with a bit of overhead: store open GUI of player, then check all players in on_tick if they have a GUI to reopen.
Code: Select all
-- tick_distributor = vehicle.unit_number % 6
local tick = game.tick + state.tick_distributor
local cron_fuel = (tick % 360 == 0)
local cron_chart = (tick % 300 == 0)
local cron_ammo = (tick % 180 == 0)
local cron_circuit = (tick % 60 == 0)
local cron_enemy = state.panic or (tick % 30 == 0)
local cron_logistic = (tick % 30 == 0)
local cron_follow = (tick % 30 == 0)
"Request from buffer chests" can be set from my mod's GUI, and it should be in sync with the state of the vehicle's checkbox. When vehicle.request_from_buffers is different from what the GUI says, I'll overwrite the vehicle's checkbox state. Unfortunately, there's no way to find out when the vehicle's checkbox is changed, so my idea was to use
Code: Select all
if vehicle.request_from_buffers ~= state.request_from_buffers then
vehicle.request_from_buffers = state.request_from_buffers or false
if player.opened == vehicle then
player_data.re_open = vehicle
player.opened = nil
end
end
Code: Select all
if player_data.re_open then
player.opened = player_data.re_open
player_data.re_open = nil
end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Spider-vehicle: How do I set "Request from buffer chests?"
I think you can ignore that. That fraction of time the player has the GUI opened and plays with the button compared to the rest is nothing. Unless you have a massive multiplayer game and all player decide to play with the checkbox at the same time it should be ok.