Page 1 of 1

data.raw Question

Posted: Tue Dec 29, 2015 10:43 pm
by KTobias
How do you address an item that seems to be a couple levels deep in code?

For example. Say I want to change the Mining Axe damage amount from 8 to 10.

Code: Select all

    type = "mining-tool",
    name = "steel-axe",
    icon = "__base__/graphics/icons/steel-axe.png",
    flags = {"goes-to-main-inventory"},
    action =
    {
      type="direct",
      action_delivery =
      {
        type = "instant",
        target_effects =
        {
            type = "damage",
            damage = { amount = 8 , type = "physical"}
        }
      }
    },
    durability = 5000,
    subgroup = "tool",
    order = "a[mining]-b[steel-axe]",
    speed = 4,
    stack_size = 20
It's like 3 levels deep and it seems that no matter how I code it, it is wrong and doesn't work. I've tried quotation marks and different combinations of brackets but i've got to missing something.

Please someone help. :?:

Re: data.raw Question

Posted: Tue Dec 29, 2015 11:23 pm
by keyboardhack
data.raw gives us access to all the different prototype types there is in the game. To Limit it to a specific type you can write

Code: Select all

data.raw["mining-tool"]
To limit it to the steel-axe you write

Code: Select all

data.raw["mining-tool"]["steel-axe"]
now to get the table action you write

Code: Select all

data.raw["mining-tool"]["steel-axe"]["action"]
See the pattern? Do the same for action_delivery, target_effects, damage and amount

Code: Select all

data.raw["mining-tool"]["steel-axe"]["action"]["action_delivery"]["target_effects"]["damage"]["amount"]
You are now able to change the value of amount to 10 like this

Code: Select all

data.raw["mining-tool"]["steel-axe"]["action"]["action_delivery"]["target_effects"]["damage"]["amount"] = 10