Re: [MOD 0.12.16] Upgrade planner - v1.1.9
Posted: Sun Aug 28, 2016 5:00 pm
Thanks a bunch!!!
Your blue --> purple belts merge is bottlenecked to the speed of 4 blue belts the by your express splitters. You should use purple splitters when merging the blue belts.factoriofrenzy wrote:Here it is
Code: Select all
function upgrade_blueprint(player, blueprint)
if not blueprint.is_blueprint_setup() then return end
local config = global["config"][player.name]
if config ~= nil then
local bluedata=blueprint.get_blueprint_entities()
for i=#bluedata,1,-1 do
local belt=bluedata[i]
local upgrade = get_upgrade_for_entity_name(config,belt.name)
if upgrade ~= nil then
if upgrade ~="deconstruction-planner" then
belt.name=item_name_to_entity_name(upgrade)
else
table.remove(bluedata, i)
end
end
end
blueprint.set_blueprint_entities(bluedata)
if(not blueprint.is_blueprint_setup()) then return end
local icons=blueprint.blueprint_icons
for i = 1,#icons do
local icon=icons[i]
local item_name = signal_to_item_name(icon.signal)
local upgrade = get_upgrade_for_item_name(config,item_name)
if upgrade then
if upgrade ~="deconstruction-planner" then
icon.signal.name=upgrade
else
icon.signal.name=nil
end
end
end
blueprint.blueprint_icons=icons
if #blueprint.blueprint_icons == 0 then blueprint.blueprint_icons=blueprint.default_icons end
end
end
Code: Select all
if element.name == "upgrade-planner-config-button" then
if(player.cursor_stack.valid_for_read and player.cursor_stack.type == "blueprint") then
upgrade_blueprint(player,player.cursor_stack)
else
gui_open_frame(player)
end
Code: Select all
function item_name_to_prototype(name) --or nil
if name then
return game.item_prototypes[name]
end
end
function item_prototype_to_entity_prototype (item) --or nil
if item and item.place_result then
return item.place_result
end
end
function item_name_to_entity_name(name)
local entity = item_prototype_to_entity_prototype(item_name_to_prototype(name))
if entity then
return entity.name
end
end
function signal_to_item_name(signal) --or nil
if signal and signal.type == "item" then
return signal.name
end
end
function get_upgrade_for_item_name(config,name)
local index = 0
for i = 1, #config do
if config[i].from == name then
index = i
break
end
end
if index>0 then
return config[index].to
end
end
function get_upgrade_for_entity_name(config,name)
if name then
local index = 0
for i = 1, #config do
if item_name_to_entity_name(config[i].from) == name then
index = i
break
end
end
if index>0 then
return config[index].to
end
end
end
doktorstick wrote:Whenever you upgrade an entity using upgrade planner, the entity being replaced does not have its defines.events.on_preplayer_mined_item invoked and the upgraded entity does not have its defines.events.on_built_entity invoked.
This effectively breaks any mod that needs state tracking initialized on built/mined.
Urbs wrote:Just upgrade to 1.2.6.
Getting the following error while trying to upgrade belts by hand (not with bots)
got a similar crashaarondeal wrote:Urbs wrote:Just upgrade to 1.2.6.
Getting the following error while trying to upgrade belts by hand (not with bots)
Im getting the same error.
Thanks for the report,Urbs wrote:Just upgrade to 1.2.6.
Getting the following error while trying to upgrade belts by hand (not with bots)
Code: Select all
Error while running event on_gui_click (ID 1)
__upgrade-planner__/control.lua:44: attempt to index field '?' (a nil value)
Code: Select all
2944.003 Error MainLoop.cpp:759: Exception at tick 20508000: Error while running event on_player_selected_area (ID 49)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
__upgrade-planner__/control.lua:619: in function 'on_selected_area'
__upgrade-planner__/control.lua:600: in function <__upgrade-planner__/control.lua:599>
2944.003 Error ServerMultiplayerManager.cpp:95: MultiplayerManager failed: "Error while running event on_player_selected_area (ID 49)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
__upgrade-planner__/control.lua:619: in function 'on_selected_area'
__upgrade-planner__/control.lua:600: in function <__upgrade-planner__/control.lua:599>"
2944.003 Info ServerMultiplayerManager.cpp:636: mapTick(20508000) changing state from(InGame) to(Failed)
Code: Select all
222.386 Info ServerMultiplayerManager.cpp:720: mapTick(21057011) received stateChanged peerID(1) oldState(TryingToCatchUp) newState(WaitingForCommandToStartSendingTickClosures)
222.386 Info GameActionHandler.cpp:2548: MapTick(21057011) processed PlayerJoinGame peerID(1) playerIndex(0) mode(connect)
222.480 Info ServerMultiplayerManager.cpp:720: mapTick(21057017) received stateChanged peerID(1) oldState(WaitingForCommandToStartSendingTickClosures) newState(InGame)
270.753 Error MainLoop.cpp:759: Exception at tick 21059912: Error while running event on_player_selected_area (ID 49)
__upgrade-planner__/control.lua:637: attempt to index local 'belt' (a nil value)
270.754 Error ServerMultiplayerManager.cpp:95: MultiplayerManager failed: "Error while running event on_player_selected_area (ID 49)
__upgrade-planner__/control.lua:637: attempt to index local 'belt' (a nil value)"
270.754 Info ServerMultiplayerManager.cpp:636: mapTick(21059912) changing state from(InGame) to(Failed)
Okay it should be fixed in 1.2.12Ratzap wrote:I tried again just now with 1.2.11 and it crashed the server still.
Code: Select all
222.386 Info ServerMultiplayerManager.cpp:720: mapTick(21057011) received stateChanged peerID(1) oldState(TryingToCatchUp) newState(WaitingForCommandToStartSendingTickClosures) 222.386 Info GameActionHandler.cpp:2548: MapTick(21057011) processed PlayerJoinGame peerID(1) playerIndex(0) mode(connect) 222.480 Info ServerMultiplayerManager.cpp:720: mapTick(21057017) received stateChanged peerID(1) oldState(WaitingForCommandToStartSendingTickClosures) newState(InGame) 270.753 Error MainLoop.cpp:759: Exception at tick 21059912: Error while running event on_player_selected_area (ID 49) __upgrade-planner__/control.lua:637: attempt to index local 'belt' (a nil value) 270.754 Error ServerMultiplayerManager.cpp:95: MultiplayerManager failed: "Error while running event on_player_selected_area (ID 49) __upgrade-planner__/control.lua:637: attempt to index local 'belt' (a nil value)" 270.754 Info ServerMultiplayerManager.cpp:636: mapTick(21059912) changing state from(InGame) to(Failed)
Ok should be fixedkeryja wrote:There's still an error happening when you try to upgrade an underground belt with different ends: