Treefarm and Dytech?

Looking for a mod? Have a review on a mod you'd like to share?
Post Reply
UberJumper
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 08, 2014 8:58 pm
Contact:

Treefarm and Dytech?

Post by UberJumper »

So apparently i need to use Treefarm in order to automate Rubber production with Dytech. I installed the latest version of tree farm, but when ever i load my saved games i get the following error:

> Error while running the onload: ...nk\AppData\Roaming\Factorio\mods\DyTech-Core|control.lua:52: Error when running interface function treefarm.addSeed: ...ppData\Roaming\Factorio\mods\Treefarm-Mod|interfaces.lua:6: attempt to index field 'treefarm' (a nil value)

I am not really sure if this is a Dytech problem or a treefarm problem.

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Treefarm and Dytech?

Post by drs9999 »

My best guess is that the problem is caused by the order in which dytech's and my code is executed. Dytech tries to access something that isn't initialized yet. I'm not entirely sure, but I believe that it only can be fixed with some changes in the dytech code. I'll try to solve that or at least find a workaround in the next days.

Martc
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Wed May 21, 2014 8:20 am
Contact:

Re: Treefarm and Dytech?

Post by Martc »

It only happens when you add treefarm to existing save with DyTech. And there is workaround for that https://forums.factorio.com/forum/vie ... 858#p37858

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Treefarm and Dytech?

Post by drs9999 »

Ok, here is a quick fix for the issue ( not 100% but at least you can load the game without any error-msg popping up)

EDIT: If you use treefarm 1.1.9 (or upwards) you can skip the first step

1. open the interface.lua located in the treefarm-mod folder and paste the following in line 6

Code: Select all

if glob.treefarm == nil then
  return "treefarm isn't initialized yet. Save the game and reload it."
end
It should look like this afterwards:

Code: Select all

remote.addinterface("treefarm",
{
	addSeed = function(seedInfo)
		if glob.treefarm == nil then
			return "treefarm isn't initialized yet. Save the game and reload it."
		end

		if glob.treefarm.seedTypes[seedInfo.name] == nil then
 [...]
2. open the control.lua in the dytech-core folder and replace the Onload-event code(line 47-64) with the following:

Code: Select all

game.onload(function()
	fs.OnLoad()

	if game.itemprototypes.charcoal then -- item "charcoal" is available, that means treefarm-mod is probably used
		if (remote.interfaces.treefarm) and (remote.interfaces.treefarm.addSeed) then -- check if script-interfaces are available
			local errorMsg = remote.call("treefarm", "addSeed", allInOne) -- call the interface and store the return value
				-- the remote function will return nil on success, otherwise a string with the error-msg
			if errorMsg == nil then -- everything worked fine
				glob.compatibility.treefarm = true
			else
				if errorMsg ~= "seed type already present" then game.player.print(errorMsg) end
			end
		end
	else -- charcoal isn't available, so treefarm-mod isn't installed
		glob.compatibility.treefarm = false
		for seedTypeName, seedTypeInfo in pairs (glob.trees.seedTypes) do
			if game.itemprototypes[seedTypeInfo.states[1]] == nil then
				glob.trees.isGrowing[seedTypeName] = nil
				glob.trees.seedTypes[seedTypeName] = nil
			end
		end
	end
end)
3. Load your save-game, you probably receive a message which says that treefarm isn't initialized yet
4. Save the game and reload it, you shouldn't receive a new message and everything should work fine frome here


Note that the need to save/reload your game can be fixed, but this has to be done in dysoch's code and I don't want to mess around with it/change any more than I have to in it.

Post Reply

Return to “Questions, reviews and ratings”