Canonical way to find the stockpile by id.

develop
Eric Wald 2014-09-07 14:55:34 -06:00
parent 74e709ec19
commit 1ce07c063d
1 changed files with 1 additions and 3 deletions

@ -1,7 +1,6 @@
local _ENV = mkmodule('plugins.stockflow') local _ENV = mkmodule('plugins.stockflow')
local gui = require "gui" local gui = require "gui"
local utils = require "utils"
reaction_list = reaction_list or {} reaction_list = reaction_list or {}
saved_orders = saved_orders or {} saved_orders = saved_orders or {}
@ -116,10 +115,9 @@ function collect_orders()
local result = {} local result = {}
local entries = dfhack.persistent.get_all("stockflow/entry", true) local entries = dfhack.persistent.get_all("stockflow/entry", true)
if entries then if entries then
local stockpiles = df.global.world.buildings.other.STOCKPILE
for _, entry in ipairs(entries) do for _, entry in ipairs(entries) do
local spid = entry.ints[entry_ints.stockpile_id] local spid = entry.ints[entry_ints.stockpile_id]
local stockpile = utils.binsearch(stockpiles, spid, "id") local stockpile = df.building.find(spid)
if stockpile then if stockpile then
local order_number = entry.ints[entry_ints.order_number] local order_number = entry.ints[entry_ints.order_number]
if reaction_list[order_number] and entry.value == reaction_list[order_number].name then if reaction_list[order_number] and entry.value == reaction_list[order_number].name then