Page 1 of 1

How to override base entity?

Posted: Sun Apr 03, 2016 9:50 pm
by Targa
Hi all. I don't know my way around lua, but figured I might be able to at least modify some base values by copying the entity info and changing it in a mod. While the couple of mods I made loaded fine (no errors), they also haven't changed anything in-game. I was hoping someone can point me in the right direction.

For example:

Code: Select all

  {
    type = "straight-rail",
    name = "straight-rail",
    icon = "__base__/graphics/icons/straight-rail.png",
    flags = {"placeable-neutral", "player-creation", "building-direction-8-way"},
    minable = {mining_time = 1, result = "straight-rail"},
    max_health = 100,
    corpse = "straight-rail-remnants",
    collision_box = {{-0.7, -0.8}, {0.7, 0.8}},
    selection_box = {{-0.7, -0.8}, {0.7, 0.8}},
    rail_category = "regular",
    pictures = railpictures(),
  },
  {
    type = "curved-rail",
    name = "curved-rail",
    icon = "__base__/graphics/icons/curved-rail.png",
    flags = {"placeable-neutral", "player-creation", "building-direction-8-way"},
    minable = {mining_time = 1, result = "curved-rail"},
    max_health = 200,
    corpse = "curved-rail-remnants",
    collision_box = {{-0.75, -0.55}, {0.75, 1.6}},
    secondary_collision_box = {{-0.65, -2.43}, {0.65, 2.43}},
    selection_box = {{-1.7, -0.8}, {1.7, 0.8}},
    rail_category = "regular",
    pictures = railpictures(),
  },
This is the entry for rail tracks (straight and curved) in the base game's entities.lua file. In my mod's entities.lua, I copy/pasted that and added "data:extend(" at the front and a closing parenthesis at the end. I changed the "mining time" to 0.2, but it has no effect in-game. My mod doesn't have a "control.lua", since I couldn't figure out what to put in there, lol. Any help or info in making simple mods to override base values would be appreciated!

Re: How to override base entity?

Posted: Sun Apr 03, 2016 10:05 pm
by DaveMcW
Creating and editing entities are very different.

You want something like this:

Code: Select all

data.raw["straight-rail"]["straight-rail"].minable.mining_time = 0.2
The first word in quotes is the type, the second word is the name.

Re: How to override base entity?

Posted: Mon Apr 04, 2016 1:09 am
by Targa
Thanks for that! :D

Re: How to override base entity?

Posted: Mon Apr 04, 2016 2:34 am
by Targa
One other thing. Does anyone know where I can find the Radar entity? I've searched through all the files in Data\Base\Prototypes but can't find it. I either missed it, or it's hidden away somewhere...

Re: How to override base entity?

Posted: Mon Apr 04, 2016 2:39 am
by daniel34
Targa wrote:One other thing. Does anyone know where I can find the Radar entity? I've searched through all the files in Data\Base\Prototypes but can't find it. I either missed it, or it's hidden away somewhere...
data\base\prototypes\entity\demo-entities.lua in line 1960

Re: How to override base entity?

Posted: Mon Apr 04, 2016 2:49 am
by Targa
Thanks! I didn't think of looking thru the demo files...