How to override base entity?

Place to get help with not working mods / modding interface.
Post Reply
Targa
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 11, 2016 8:42 pm
Contact:

How to override base entity?

Post 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!

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3077
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to override base entity?

Post 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.

Targa
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 11, 2016 8:42 pm
Contact:

Re: How to override base entity?

Post by Targa »

Thanks for that! :D

Targa
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 11, 2016 8:42 pm
Contact:

Re: How to override base entity?

Post 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...

daniel34
Global Moderator
Global Moderator
Posts: 2757
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: How to override base entity?

Post 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

Targa
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 11, 2016 8:42 pm
Contact:

Re: How to override base entity?

Post by Targa »

Thanks! I didn't think of looking thru the demo files...

Post Reply

Return to “Modding help”

Who is online

Users browsing this forum: No registered users