Page 8 of 17

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Sun Aug 28, 2016 5:00 pm
by factoriofrenzy
Thanks a bunch!!!

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Sun Aug 28, 2016 9:39 pm
by Qon
factoriofrenzy wrote:Here it is
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.

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Tue Aug 30, 2016 5:01 pm
by ShawnShepard
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!

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Wed Aug 31, 2016 7:00 pm
by Klonan
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

Posted: Tue Sep 06, 2016 3:09 pm
by Arumba
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

Posted: Thu Sep 08, 2016 1:36 am
by jsmith45
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:

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
That code gets plugged in to the gui_click event like so:

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
That code uses a few auxiliary functions not currently present in the mod.
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
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.

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Fri Sep 09, 2016 3:48 pm
by doktorstick
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.

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Mon Sep 12, 2016 4:33 pm
by doktorstick
BTW, as expected, SHIFT-upgrading works with modded items since robots do the deconstruction/construction for reals.

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Mon Sep 12, 2016 4:51 pm
by Klonan
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

Posted: Wed Sep 14, 2016 12:01 am
by Urbs
Just upgrade to 1.2.6.

Getting the following error while trying to upgrade belts by hand (not with bots)

Image

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Wed Sep 14, 2016 9:45 am
by aarondeal
Urbs wrote:Just upgrade to 1.2.6.

Getting the following error while trying to upgrade belts by hand (not with bots)

Image

Im getting the same error.

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Thu Sep 15, 2016 3:08 am
by WhatheWorld
aarondeal wrote:
Urbs wrote:Just upgrade to 1.2.6.

Getting the following error while trying to upgrade belts by hand (not with bots)

Image

Im getting the same error.
got a similar crash

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>

Re: [MOD 0.12.16] Upgrade planner - v1.1.9

Posted: Thu Sep 15, 2016 10:15 am
by Klonan
Urbs wrote:Just upgrade to 1.2.6.

Getting the following error while trying to upgrade belts by hand (not with bots)

Image
Thanks for the report,

Fixed in 1.2.7

Re: [MOD 0.14] Upgrade planner - v1.2.7

Posted: Sun Sep 25, 2016 1:05 pm
by Arumba
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:

Code: Select all

Error while running event on_gui_click (ID 1)
__upgrade-planner__/control.lua:44: attempt to index field '?' (a nil value)
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.

Re: [MOD 0.14] Upgrade planner - v1.2.7

Posted: Sun Sep 25, 2016 9:06 pm
by Ratzap
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

Posted: Mon Sep 26, 2016 8:57 pm
by Ratzap
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

Posted: Mon Sep 26, 2016 10:25 pm
by Klonan
Ratzap 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)
Okay it should be fixed in 1.2.12

Re: [MOD 0.14] Upgrade planner - v1.2.7

Posted: Tue Sep 27, 2016 8:07 am
by Ratzap
Thanks, that worked now.

Re: [MOD 0.14] Upgrade planner - v1.2.7

Posted: Tue Sep 27, 2016 9:49 pm
by keryja
There's still an error happening when you try to upgrade an underground belt with different ends:
2016-09-27_23-45-40.png
2016-09-27_23-45-40.png (217.97 KiB) Viewed 8095 times
2016-09-27_23-45-49.png
2016-09-27_23-45-49.png (66.71 KiB) Viewed 8095 times

Re: [MOD 0.14] Upgrade planner - v1.2.7

Posted: Wed Sep 28, 2016 10:24 am
by Klonan
keryja wrote:There's still an error happening when you try to upgrade an underground belt with different ends:
2016-09-27_23-45-40.png
2016-09-27_23-45-49.png
Ok should be fixed