[MOD 0.16] Upgrade planner
-
- Burner Inserter
- Posts: 17
- Joined: Thu Mar 24, 2016 4:44 pm
- Contact:
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
Thanks a bunch!!!
- Attachments
-
- Screen Shot 2016-08-28 at 18.59.47.png (471.4 KiB) Viewed 7516 times
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
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
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
-
- Burner Inserter
- Posts: 12
- Joined: Fri Jul 15, 2016 2:15 am
- Contact:
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
Hello, Great mod, I use this so often and highly suggest to all players.
Can you please update it for 14.x latest?
Thank you and keep up the great work!
Can you please update it for 14.x latest?
Thank you and keep up the great work!
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
I have updated the mod for 0.14, and also added support removing and/or deconstructing trees
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
Small bug report; If you click on a single pixel (no box drag at all) in multiplayer the game instantly crashes.
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
One feature I've been wanting with this mod is the ability to upgrade blueprints. Say I have a yellow belt balancer blueprint, but I've reached the point in the game where I never use yellow, and want blue-belt version. Or say I want to upgreade my normal rail blueprints to use an electric rail mod's rails. Placing the blueprint, upgrading it, and re-creating the blueprint is slow and obnoxious.
So I've coded up a modification of this mod that supports exactly that. With these changes simply clicking the upgrade planner GUI icon with a blueprint in hand will instantly upgrade the blueprint (and also the blueprint's icon), according to the current configuration. A minor caveat: Upgrades to a blurprint where the new object has a different size may not always work correctly. It does not crash, but some entites may not get placed since they would overlap. This can occur even when the upgraded entities don't appear to overlap. So just avoid upgrades to different sized entities when using blueprint upgrades.
The core code is:
That code gets plugged in to the gui_click event like so:
That code uses a few auxiliary functions not currently present in the mod.
They are defined below:
The helpers correctly handle entities whose names do not match their item's name. Having written, I decided to ugrade the rest of the mod to use these helpers, so that the whole mod works with entities whose names don't match their items name, and to fix 2 crashing bugs in version 1.2.5 of the mod. I'm attaching the final control.lua file that can be dropped into the mod. I may have introduced some new bugs, but everything seems to be working for me.
Klonan, I'd appreciate it if you would consider merging in these changes.
So I've coded up a modification of this mod that supports exactly that. With these changes simply clicking the upgrade planner GUI icon with a blueprint in hand will instantly upgrade the blueprint (and also the blueprint's icon), according to the current configuration. A minor caveat: Upgrades to a blurprint where the new object has a different size may not always work correctly. It does not crash, but some entites may not get placed since they would overlap. This can occur even when the upgraded entities don't appear to overlap. So just avoid upgrades to different sized entities when using blueprint upgrades.
The core code 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
They are defined below:
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
Klonan, I'd appreciate it if you would consider merging in these changes.
- Attachments
-
- control.lua
- (32.53 KiB) Downloaded 157 times
-
- Fast Inserter
- Posts: 219
- Joined: Fri Aug 12, 2016 10:22 pm
- Contact:
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
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.
This effectively breaks any mod that needs state tracking initialized on built/mined.
-
- Fast Inserter
- Posts: 219
- Joined: Fri Aug 12, 2016 10:22 pm
- Contact:
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
BTW, as expected, SHIFT-upgrading works with modded items since robots do the deconstruction/construction for reals.
Last edited by doktorstick on Mon Sep 12, 2016 5:20 pm, edited 1 time in total.
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
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.
Thanks for the report,
I will fix it for the next version of the mod
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
Just upgrade to 1.2.6.
Getting the following error while trying to upgrade belts by hand (not with bots)
Getting the following error while trying to upgrade belts by hand (not with bots)
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
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.
-
- Inserter
- Posts: 45
- Joined: Tue Apr 19, 2016 4:32 am
- Contact:
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
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.
Error while running event on_player_selected_area (ID 49)
Error while running event on_built_entity (ID 6)
__Factorissimo__/control.lua:271: attempt to index local 'entity' (a nil value)
stack traceback:
__upgrade-planner__/control.lua:735: in function 'on_selected_area'
__upgrade-planner__/control.lua:592: in function <__upgrade-planner__/control.lua:591>
Author of Personal Teleporter
Re: [MOD 0.12.16] Upgrade planner - v1.1.9
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)
Fixed in 1.2.7
Re: [MOD 0.14] Upgrade planner - v1.2.7
Bug report: 0.14.9 modded game with Bobs + Angels + vanilla+ stuffs.
Clicking on the GUI button in the top left corner of the map I get this error:
It was working in earlier versions, to my memory 0.14.7 or so. It still works as long as I don't click that button. I don't know what has changed.
Clicking on the GUI button in the top left corner of the map I get this error:
Code: Select all
Error while running event on_gui_click (ID 1)
__upgrade-planner__/control.lua:44: attempt to index field '?' (a nil value)
Re: [MOD 0.14] Upgrade planner - v1.2.7
I went to use the planner in a Dytech game, settings were no problem but as soon as I click an area with the planner object in hand the server crashed:
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)
Re: [MOD 0.14] Upgrade planner - v1.2.7
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)
Re: [MOD 0.14] Upgrade planner - v1.2.7
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)
Re: [MOD 0.14] Upgrade planner - v1.2.7
Thanks, that worked now.
Re: [MOD 0.14] Upgrade planner - v1.2.7
There's still an error happening when you try to upgrade an underground belt with different ends:
Re: [MOD 0.14] Upgrade planner - v1.2.7
Ok should be fixedkeryja wrote:There's still an error happening when you try to upgrade an underground belt with different ends: