Trying to add another ingredient to every recipe (liquid)

Place to get help with not working mods / modding interface.
Post Reply
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Trying to add another ingredient to every recipe (liquid)

Post by ficolas »

I am making a mod for assembling machines to work with steam instead of working with electricity (yay pipes everywhere!)
Basically this is the code:

Code: Select all

data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories={"assembling"}
data.raw["assembling-machine"]["assembling-machine-2"].crafting_categories={"assembling"}
data.raw["assembling-machine"]["assembling-machine-3"].crafting_categories={"assembling"}

for i,d in pairs (data.raw.recipe) do
	if string.find(d.name, "-steam", -6)==nil then
		-- I do this ^ so recipes that alredy have steam dont get re-done with even more water in the 
		-- ingredients, and it doesnt go into an infinite loop.
		if d.category=="crafting" then
			recipeingredients={}
			
			
			for ii,dd in pairs (d.ingredients) do 
				-- Here I convert the ingredient table, that can be done in two ways, to the 
				-- way that needs to be used when the ingredient table has a liquid.
				if dd.type~=nil then
					break
				else
					table.insert(recipeingredients,{name=dd[1],amount=dd[2],type="item"})
				end
			end
			
			
			if d.result_count==nil then
				amount=1
			else
				amount=d.result_count
			end
			
			
			if d.results==nil then 
			--Here I'm doing the same, but for the result
				result={name=d.result, type="item", amount= amount}
			else
				result=d.results
			end
			
			
			table.insert(recipeingredients, {type="fluid",name="water", amount=d.energy_required})
			-- And here I'm creating the new recipe, but with a -steam sufix and with the new ingredients.
			data:extend{
				{
					type = "recipe",
					name =  d.name.."-steam",
					results = result,
					ingredients = recipeingredients,
					enabled = d.enabled,
					category = "assembling",
				}
			}
		end
	end
end
So the problem is that it says:

Code: Select all

 Error while loading prototype "small-plane-steam", no such node (name)
What is missing?
The biggest problem is that it can be a "name" field from the recipe, a "name" field from the ingredients, or for the result.
The thing that I have been having more problems with is the result so it may be a "name" field from the result, but I have no idea why D:

If I could print stuff to a log somehow but the i/o api is dissabled in the data.lua afaik, the new functions to create file are also dissabled, and there is no console :S

someloser
Inserter
Inserter
Posts: 24
Joined: Mon May 26, 2014 5:37 am
Contact:

Re: Trying to add another ingredient to every recipe (liquid

Post by someloser »

Is the

Code: Select all

         data:extend{
            {
               type = "recipe",
               name =  d.name.."-steam",
               results = result,
               ingredients = recipeingredients,
               enabled = d.enabled,
               category = "assembling",
            }
         }
just a neater way of saying

Code: Select all

table.insert(data.raw.recipe, { type="recipe", blah, blah, blah, ..., } ) 
?
DT-Extend - DyTech ores and other things.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Trying to add another ingredient to every recipe (liquid

Post by ficolas »

Basically yes, data.raw is a table.
I rewrote the code and now is working, I dont know what was the problem but I have it working now.
Now the problem is that I cant figure out a way to make assembling machines use no power, and I cant figure out how to use energy_required to put the right amount of water, because any multiplication/divition/addition etc done with energy_required seems to threat energy_required as nil...

someloser
Inserter
Inserter
Posts: 24
Joined: Mon May 26, 2014 5:37 am
Contact:

Re: Trying to add another ingredient to every recipe (liquid

Post by someloser »

quite a few recipes don't state the energy_required parameter. IIRC, the default value used in this case is 0.5.

The power usage is set at the entity level, unless you want to add a special "Steam Powered Assembler", I don't think you can turn off the electrical usage based on the recipe used.
DT-Extend - DyTech ores and other things.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Trying to add another ingredient to every recipe (liquid

Post by ficolas »

someloser wrote:quite a few recipes don't state the energy_required parameter. IIRC, the default value used in this case is 0.5.

The power usage is set at the entity level, unless you want to add a special "Steam Powered Assembler", I don't think you can turn off the electrical usage based on the recipe used.
MM yea I should have known that because my mod used to have every recipe with energy_required beeing default...

And yes, I want to have a special steam powered assembler, the problem is that when I put electric usage 0kW, it it needs a electric connection, and when I give one, it says there is no power, maybe if I put electric ussage of 1W I can give it energy by setting the internal storage with the control.lua

someloser
Inserter
Inserter
Posts: 24
Joined: Mon May 26, 2014 5:37 am
Contact:

Re: Trying to add another ingredient to every recipe (liquid

Post by someloser »

energy_source can be either electric or burner.. there seems to be no way to get a normally powered entity to run in a "self-powered" mode.

I suppose you could make it a burner assembler and require it to only use the added water recipes, but then you need to supply it fuel.


Can a fluid also be set as a fuel source?

Is energy_source a required property of type = "assembling-machine"?
DT-Extend - DyTech ores and other things.

Post Reply

Return to “Modding help”