New item values don't seem to apply ingame?

Place to get help with not working mods / modding interface.
Post Reply
Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

New item values don't seem to apply ingame?

Post by Molay » Sun Jul 19, 2015 12:32 pm

Hello,

I dabbled into modding for the first time. I use the Marathon Mod as a blueprint for what I call "HarderEnergy" mod, which only aims to reduce energy values of wood, coal and solid fuel, as well as reduce production from solar panels and capacity of accumulators.

It's a very short mod, and I don't know why it doesn't recognize the new values. Does someone know what I did wrong?

Code: Select all

-- Rebalanced MJ value
-- wood 4MJ -> 2MJ, other wooden objects scaled accordingly
-- coal 8MJ -> 4MJ
-- solid fuel 25MJ -> 16MJ
--
-- Rebalanced solar power
-- Solar panel 60KW -> 10KW
-- Accumulator Storage 5MJ -> 3MJ
-- Accumulator flow 300KW -> 150KW


data:extend(
{
-- Fuels
  {
    type = "item",
    name = "raw-wood",
    icon = "__base__/graphics/icons/raw-wood.png",
    flags = {"goes-to-main-inventory"},
    fuel_value = "2MJ",
    subgroup = "raw-material",
    order = "a[raw-wood]",
    stack_size = 50
  },  
  {
    type = "item",
    name = "wood",
    icon = "__base__/graphics/icons/wood.png",
    flags = {"goes-to-main-inventory"},
    fuel_value = "1MJ",
    subgroup = "raw-material",
    order = "a[wood]",
    stack_size = 50
  },
  {
    type = "item",
    name = "wooden-chest",
    icon = "__base__/graphics/icons/wooden-chest.png",
    flags = {"goes-to-quickbar"},
    fuel_value = "2MJ",
    subgroup = "storage",
    order = "a[items]-a[wooden-chest]",
    place_result = "wooden-chest",
    stack_size = 50
  },
  {
    type = "item",
    name = "small-electric-pole",
    icon = "__base__/graphics/icons/small-electric-pole.png",
    flags = {"goes-to-quickbar"},
    subgroup = "energy-pipe-distribution",
    order = "a[energy]-a[small-electric-pole]",
    place_result = "small-electric-pole",
    fuel_value = "2MJ",
    stack_size = 50
  },
  {
    type = "item",
    name = "coal",
    icon = "__base__/graphics/icons/coal.png",
    dark_background_icon = "__base__/graphics/icons/coal-dark-background.png",
    flags = {"goes-to-main-inventory"},
    fuel_value = "4MJ",
    subgroup = "raw-material",
    order = "b[coal]",
    stack_size = 50
  },
  {
    type = "item",
    name = "solid-fuel",
    icon = "__base__/graphics/icons/solid-fuel.png",
    flags = {"goes-to-main-inventory"},
    fuel_value = "16MJ",
    subgroup = "raw-resource",
    order = "c[solid-fuel]",
    stack_size = 50
  },  
-- Solar
  {
    type = "solar-panel",
    name = "solar-panel",
    icon = "__base__/graphics/icons/solar-panel.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {hardness = 0.2, mining_time = 0.5, result = "solar-panel"},
    max_health = 100,
    corpse = "big-remnants",
    collision_box = {{-1.4, -1.4}, {1.4, 1.4}},
    selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
    energy_source =
    {
      type = "electric",
      usage_priority = "solar"
    },
    picture =
    {
      filename = "__base__/graphics/entity/solar-panel/solar-panel.png",
      priority = "high",
      width = 104,
      height = 96
    },
    production = "10kW"
  },
  -- Accumulator
  {
    type = "accumulator",
    name = "basic-accumulator",
    icon = "__base__/graphics/icons/basic-accumulator.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {hardness = 0.2, mining_time = 0.5, result = "basic-accumulator"},
    max_health = 150,
    corpse = "medium-remnants",
    collision_box = {{-0.9, -0.9}, {0.9, 0.9}},
    selection_box = {{-1, -1}, {1, 1}},
    energy_source =
    {
      type = "electric",
      buffer_capacity = "3MJ",
      usage_priority = "terciary",
      input_flow_limit = "150kW",
      output_flow_limit = "150kW"
    },
    picture =
    {
      filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png",
      priority = "extra-high",
      width = 124,
      height = 103,
      shift = {0.7, -0.2}
    },
    charge_animation =
    {
      filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator-charge-animation.png",
      width = 138,
      height = 135,
      line_length = 8,
      frame_count = 24,
      shift = {0.482, -0.638},
      animation_speed = 0.5
    },
    charge_cooldown = 30,
    charge_light = {intensity = 0.3, size = 7},
    discharge_animation =
    {
      filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator-discharge-animation.png",
      width = 147,
      height = 128,
      line_length = 8,
      frame_count = 24,
      shift = {0.395, -0.525},
      animation_speed = 0.5
    },
    discharge_cooldown = 60,
    discharge_light = {intensity = 0.7, size = 7},
    vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
    working_sound =
    {
      sound =
      {
        filename = "__base__/sound/accumulator-working.ogg",
        volume = 1
      },
      idle_sound = {
        filename = "__base__/sound/accumulator-idle.ogg",
        volume = 0.4
      },
      max_sounds_per_type = 5
    },
  },
}
)
Thanks for your help,
Molay
Attachments
HarderEnergy_1.0.0.rar
(3.28 KiB) Downloaded 96 times

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: New item values don't seem to apply ingame?

Post by oLaudix » Sun Jul 19, 2015 2:56 pm

Is it totally new mod that wasn't in the savegame before or did you play with it and changed values recently? If the latter you need to remove the mod, load the game and save it without the mod, install the mod and only then the new values are shown. Its like this because mods values are saved inside the save game.
Image

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Sun Jul 19, 2015 2:59 pm

I started up a new game every time to test the mod. So no old-savegame schenanigans :/
I wonder if I formatted it wrong somehow? I really can't spot what's wrong here. But it does seem to properly load the map, as it tells me when hovering over a piece of wood, coal etc that it's from the mod "Harder Energy". So it seems to use my items, but it doesn't seem to apply the new energy values of my items?

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 10:36 am

I've been looking it for another 3 hours or so, I'm not quite sure what could be wrong. Can someone please have a look over it? It's a really small mod. It's just one file basically that alters 6 items and 2 buildings. I'd love to get it to work, but there just seems nothing wrong with it. Ingame it refers to, say, coal as being from the mod, but it still doesn't use the fuel value from my mod. I don't understand how that could be?

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 12:18 pm

So I narrowed it down to 3 items. Can someone please look at it and tell me what's wrong with it? It's really short. Please.

Code: Select all

data:extend({
{
	type = "item",
	name = "raw-wood",
	icon = "__base__/graphics/icons/raw-wood.png",
	flags = {"goes-to-main-inventory"},
	fuel_value = "2MJ",
	subgroup = "raw-material",
	order = "a[raw-wood]",
	stack_size = 50
},  
{
	type = "item",
	name = "coal",
	icon = "__base__/graphics/icons/coal.png",
	dark_background_icon = "__base__/graphics/icons/coal-dark-background.png",
	flags = {"goes-to-main-inventory"},
	fuel_value = "4MJ",
	subgroup = "raw-material",
	order = "b[coal]",
	stack_size = 50
},
{
	type = "item",
	name = "solid-fuel",
	icon = "__base__/graphics/icons/solid-fuel.png",
	flags = {"goes-to-main-inventory"},
	fuel_value = "16MJ",
	subgroup = "raw-resource",
	order = "c[solid-fuel]",
	stack_size = 50
},
}) 
Ingame the fuel values are all default. I don't believe to be setting them wrong, since the Marathon mod does it the exact same way, and it works for marathon?

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: New item values don't seem to apply ingame?

Post by oLaudix » Mon Jul 20, 2015 12:48 pm

If you want to change an existing item you go like:

Code: Select all

data.raw.item["raw-wood"].fuel_value = "2MJ"
What you did is you added new item to the game but its same name as the one already existing. I'm confused why didnt it throw and error in the first place.
Image

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 2:48 pm

I'm really confused. Thank you for your help, but this does not seem to work either. If I do not include my "created clones of items" your command causes an error when loading up the game. If I do include it, then your command seems to pass (maybe because it can't find the item otherwise?). Either way, the command does not seem to set the fuel value accordingly.

If you were to make this mod, where would you put that line of code? In data.lua right? You would not have made any prototypes? I just can't get it to work, I tried lots of things... I must be really stupid for not being able to edit one property of a single item O.o

johanwanderer
Fast Inserter
Fast Inserter
Posts: 157
Joined: Fri Jun 26, 2015 11:13 pm

Re: New item values don't seem to apply ingame?

Post by johanwanderer » Mon Jul 20, 2015 4:13 pm

It may be:

Code: Select all

data.raw["item"]["raw-wood"].fuel_value = "2MJ";
Here is a (possibly outdated) list of raw data item: https://forums.factorio.com/wiki/inde ... e=Data.raw

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 5:23 pm

Thank you, but I had also tried this already. That's the way the marathon mod had it. It doesn't seem to work :( I'll just give up. Thanks though for your help everyone.

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: New item values don't seem to apply ingame?

Post by oLaudix » Mon Jul 20, 2015 5:23 pm

Molay wrote:I'm really confused. Thank you for your help, but this does not seem to work either. If I do not include my "created clones of items" your command causes an error when loading up the game. If I do include it, then your command seems to pass (maybe because it can't find the item otherwise?). Either way, the command does not seem to set the fuel value accordingly.

If you were to make this mod, where would you put that line of code? In data.lua right? You would not have made any prototypes? I just can't get it to work, I tried lots of things... I must be really stupid for not being able to edit one property of a single item O.o
It works for me. Make sure you put it in data.lua not control.lua

http://i.imgur.com/ZVA0LCI.png
Image

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 5:43 pm

Here's the message I get:
errormsg.png
errormsg.png (155.49 KiB) Viewed 1996 times
I'll attach you the folder. I do it just as you told me. But it doesn't work for some reason.
I'm not even doing anything fancy. Just the one line to set wood cost. Not even that passes for me...
Attachments
HarderEnergy_0.9.0.rar
(3.19 KiB) Downloaded 130 times

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: New item values don't seem to apply ingame?

Post by oLaudix » Mon Jul 20, 2015 5:55 pm

You are missing dependancies in info.json. It doesnt read from base mod hence item is nil. Change "dependencies": [] to "dependencies": ["base >= 0.12.0"]

EDIT1: Now that i think of it thats the reason why you didnt get error for making another raw-wood prototype etc.
Image

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 6:07 pm

Ohhh yes! That makes sense. Thank you very much, it's working for all the fuels now! You're a life-saver^^

For the solar panel production I tried:
data.raw.item["solar-panel"].production = "10kW";
but this one doesn't seem to work. Anyways I think I can figure this one out now^^ Thank you so much!

edit:
doesn't work either with
data.raw.solar-panel["solar-panel"].production = "10kW";
(found both entries for solar panel on the wiki, under item and solar-panel).
Mhh... interesting one this one.

edit2:
data.raw.entities["solar-panel"].production = "10kW";
doesn't work either.
Last edited by Molay on Mon Jul 20, 2015 6:57 pm, edited 1 time in total.

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 6:54 pm

Okay, well I can't seem to find any other ways to change the solar panel settings. If anyone has done this before, how did you do it?

Edit:
Found a way to do it. Create lua file called entities.lua in prototypes folder,
add code:

Code: Select all

data:extend({
{
	type = "solar-panel",
	name = "solar-panel",
	icon = "__base__/graphics/icons/solar-panel.png",
	flags = {"placeable-neutral", "player-creation"},
	minable = {hardness = 0.2, mining_time = 0.5, result = "solar-panel"},
	max_health = 100,
	corpse = "big-remnants",
	collision_box = {{-1.4, -1.4}, {1.4, 1.4}},
	selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
	energy_source =
	{
	  type = "electric",
	  usage_priority = "solar"
	},
	picture =
	{
	  filename = "__base__/graphics/entity/solar-panel/solar-panel.png",
	  priority = "high",
	  width = 104,
	  height = 96
	},
	production = "10kW"
}
})
and then add:
require("prototypes.entities")
to data.lua

My guess is, since I now import all the base items, I do properly replace them with same-named items from my mod. While before I created my mod items but the vanilla values would somehow overwrite the values? I'm not sure. But it works now!

yeganer
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Mon Jul 06, 2015 12:07 pm
Contact:

Re: New item values don't seem to apply ingame?

Post by yeganer » Mon Jul 20, 2015 8:05 pm

the syntax is:

Code: Select all

data.raw["solar-panel"]["solar-panel"].production = "10kW"
You want to change the entity, not the item. The item is the thing in your inventory. It does basically nothing.
The entity is the thing that's placed in the world and there you have to change the production

In general you want to use data.raw to modify the base entities instead of creating new ones because you'll never know what happens if there are dublicates.

and another note, you should do this stuff in data-updates.lua since this garantees that all prototypes were added to the data table.

Molay
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Thu May 01, 2014 8:01 am
Contact:

Re: New item values don't seem to apply ingame?

Post by Molay » Mon Jul 20, 2015 8:26 pm

Ahh yes thank you. This is a much cleaner solution. I also didn't know about data-updates.lua. Thanks a lot!
Guess my first mod is done with massive help from other people^^ Great community!

yeganer
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Mon Jul 06, 2015 12:07 pm
Contact:

Re: New item values don't seem to apply ingame?

Post by yeganer » Tue Jul 21, 2015 6:32 am

You're welcome.
There is also data-final-fixes.lua which is run last. But i haven't seen it used yet.

Post Reply

Return to “Modding help”

Who is online

Users browsing this forum: No registered users