Page 1 of 1

Need help with my first mod

Posted: Sat Apr 16, 2016 11:21 pm
by iCamper
Hey Guys

First my english is not thaaaaaat good i think

A short discribtion
My mod is in the mod folder (the game does not crash) so i think i missed somethink

but I cant find what is missing xD

I would be happy if anyone can have a look at it :)

The mod just should decrase item costs for the circuits

with the best greetings
iCamper

DL Link:
http://www.file-upload.net/download-114 ... 0.rar.html

Re: Need help with my first mod

Posted: Sun Apr 17, 2016 12:27 pm
by YoloJoe
Did you take a look at the modding tutorial? If everything is set up correctly, you should just be able to add a "recipe.lua" and add this code to it:

Code: Select all

data:extend({

{
    type = "recipe",
    name = "YOUR_ITEM_NAME",
    enabled = "true",
    ingredients = 
	{
		{"steel-plate", 1},
	},
    result = "YOUR_ITEM_NAME"
  },  
})
replace "YOUR_ITEM_NAME" with the item you want. (see the item.lua file under D:\Steam\steamapps\common\Factorio\data\base\prototypes\item)

all you need to do then is to require it in the "data.lua" file ;)

Re: Need help with my first mod

Posted: Sun Apr 17, 2016 12:29 pm
by YoloJoe
Add this to the data.lua file:

Code: Select all

require ("prototypes.recipe")

Re: Need help with my first mod

Posted: Sun Apr 17, 2016 9:00 pm
by iCamper
Thanks for youre answer
I did what u say but my mod isnt running yet ._.

Code: Select all

require ("prototypes.demo-item")
require ("prototypes.item")
require ("prototypes.entity")
require ("prototypes.recipe")
require ("prototypes.technology")

Code: Select all

"name": "Advanced_Item_Costs"
"version": "0.1.1",
"title": "Advanced_Item_Costs"
"author": "iCamper"
"contact": "",
"homepage": "",
"description": "This mod reduces costs of some items like the prosessing unit"
}

Code: Select all

data:extend({
  {
    type = "item",
    name = "electronic-circuit",
    icon = "__base__/graphics/icons/electronic-circuit.png",
    flags = {"goes-to-main-inventory"},
    subgroup = "intermediate-product",
    order = "c[electronic-circuit]",
    stack_size = 200
  },
)}
This is entity

Code: Select all

data:extend({


})

Code: Select all

data:extend({
  {
    type = "item",
    name = "advanced-circuit",
    icon = "__base__/graphics/icons/advanced-circuit.png",
    flags = {"goes-to-main-inventory"},
    subgroup = "intermediate-product",
    order = "d[advanced-circuit]",
    stack_size = 200
  },
  {
    type = "item",
    name = "processing-unit",
    icon = "__base__/graphics/icons/processing-unit.png",
    flags = {"goes-to-main-inventory"},
    subgroup = "intermediate-product",
    order = "e[processing-unit]",
    stack_size = 100
   }
)}

Code: Select all

data:extend({
 {
    type = "recipe",
    name = "electronic-circuit",
    ingredients =
    {
      {"iron-plate", 1},
      {"copper-cable", 1},
    },
    result = "electronic-circuit"
 },
 {
    type = "recipe",
    name = "advanced-circuit",
    enabled = false,
    energy_required = 4,
    ingredients =
    {
      {"electronic-circuit", 1},
      {"plastic-bar", 1},
      {"copper-cable", 1},
    },
    result = "advanced-circuit"
  },
  {
    type = "recipe",
    name = "processing-unit",
    category = "crafting-with-fluid",
    enabled = false,
    energy_required = 8,
    ingredients =
    {
      {"electronic-circuit", 1},
      {"advanced-circuit", 1},
      {type="fluid", name = "sulfuric-acid", amount = 0.1},
    },
    result = "processing-unit"
  }
)}

Code: Select all

data:extend({
   {
    type = "technology",
    name = "advanced-electronics-3",
    icon = "__base__/graphics/technology/advanced-electronics.png",
    effects =
    {
      {
        type = "unlock-recipe",
        recipe = "advanced-advanced-circuit"
      },
      {
        type = "unlock-recipe",
        recipe = "advanced-processing-unit"
      }
    },
    prerequisites = {"advanced-electronics-2"},
    unit =
    {
      count = 200,
      ingredients =
      {
        {"science-pack-1", 1},
        {"science-pack-2", 1}
      },
      time = 45
    },
    order = "a-d-b",
   }
)}
and this is my locale

Code: Select all

[item-name]
advanced-electronic-circuit = Electronic circuit
advanced-advanced-circuit = Advanced circuit
advanced-processing-unit = Processing-unit




[technology-name]
advanced-electronics-3 = Advanced-electronics-3



[entity-name]
advanced-electronic-circuit = Electronic circuit
advanced-advanced-circuit = Advanced-circuit
advanced-processing-unit = Processing-unit



[item-description]




[recipe-name]
advanced-electronic-circuit = Electronic-circuit
advanced-advanced-circuit = Advanced-circuit
advanced-processing-unit = Processing-unit

Re: Need help with my first mod

Posted: Sun Apr 17, 2016 9:12 pm
by bloc97
Are you overwriting some recipes? If you want to do that, its better to use control.lua instead of using data:extend...

Re: Need help with my first mod

Posted: Sun Apr 17, 2016 9:58 pm
by iCamper
Yes thats i want to do
how i have to configurate the control.lua ? :o

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 4:26 am
by bloc97
I don't have an example right now since I have never done this, but there are many tools available.

There's an example to modify the recipes in this thread, and for technologies, you should just need to change data.raw.recipes to data.raw.technology or something like that.
viewtopic.php?f=25&t=1221

Factorio API page:
http://lua-api.factorio.com/0.12.30/LuaTechnology.html

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 4:51 am
by iCamper
Ok
i tryed all what u say guys but the mod dont want to work
when i click on modifications (main menu)
i cant find my mod there ._.

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 4:55 am
by bloc97
Oh you can't even find your mod? Are you sure the folder is in /mods and it has a info.json file?

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 5:05 am
by iCamper
Yeah I have that

Code: Select all

{
"name": "Advanced_Item_Crafting_Costs",
"version": "0.1.1",
"title": "Advanced_Item_Crafting_Costs",
"author": "iCamper",
"contact": "",
"homepage": "",
"description": "This mod reduces costs of some items like the prosessing unit"
}
Thats why i am a bit confused ._.

If u want to have a look at the things i've tryed here is the dl link with my mod
http://www.file-upload.net/download-114 ... s.rar.html

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 5:34 am
by Arch666Angel
You need to have it in .zip format not in .rar format.

if you change recipes/items/etc via data.raw...it needs to be in the data phase, so best be put into data-updates.lua which loads second after data.lua or even data-final-fixes.lua which loads last in the data phase.

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 6:00 am
by iCamper
Ok
Thanks ;D ;D
but now it says JSON parser error: expected object name

Code: Select all

{
"name": "Advanced_Item_Costs",
"version": "0.1.1",
"title": "Advanced_Item_Costs",
"author": "iCamper",
"contact": "",
"homepage": "",
"description": "This mod reduces costs of some items like the prosessing unit",
}
You sayed it would be better to do it in another way ?
Im just a beginner in modding could you give me an example ? :)



but this mod is running
http://www.file-upload.net/download-114 ... 1.zip.html
buuuuut it didnt change the costs after all

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 8:18 am
by prg
iCamper wrote:but now it says JSON parser error: expected object name

Code: Select all

{
"name": "Advanced_Item_Costs",
"version": "0.1.1",
"title": "Advanced_Item_Costs",
"author": "iCamper",
"contact": "",
"homepage": "",
"description": "This mod reduces costs of some items like the prosessing unit",
}
That's not valid JSON, the last element in an object or array must not be followed by a comma. Also you might want to add a dependency on a certain version of the base game that the mod is known to work with, like "dependencies": ["base >= 0.12.30"].

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 9:19 am
by iCamper
Well thanks....
I watched the tutorials i found..... but i dont understand it I need more help ._.

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 2:37 pm
by bloc97
Fixed your code, there was multiple mistakes. Extract this in your mods folder.
Though I haven't tested your mod yet.

for example
data:extend({}) is correct, you wrote data:extend({)}, which is not.
And the info.json, all items in the list has to finish with a "," which you forgot multiple times.

And don't forget, your mods have to be each individually packed in a different .zip, otherwise the user has to extract them.

http://s000.tinyupload.com/index.php?fi ... 8925238557

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 8:20 pm
by iCamper
Thank you very much ^^
so now i have a last problem
i have another mod (5dim) and it changes this recipes too so how could i make it not load for this items ? :D

Re: Need help with my first mod

Posted: Mon Apr 18, 2016 8:35 pm
by iCamper
Nvm its running

Re: Need help with my first mod

Posted: Fri Apr 22, 2016 2:21 am
by iCamper
Ok i have one more question :D :D
How can i change it that i can put a productive chip in the assambling machine when i want to create advanced circuits and prossesing units ? :)