Page 1 of 1
[solved] [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 6:33 am
by AlFara
as stated in the title, i'm looking for a way to modify the slot size of an armor module;
more precisely, the exoskeleton shall be overwritten to change it's grid size from 2x4 to 6x6
folder state:
base->folder->prototypes->item->equipment.lua (protptypes->equipment folder doesn't work either)
equipment.lua (with a bit of overkill):
Code: Select all
data.raw.equipment["exoskeleton-equipment"].shape.width = 6,
data.raw.equipment["exoskeleton-equipment"].shape.height = 6,
data.raw.item["exoskeleton-equipment"].shape.width = 6,
data.raw.item["exoskeleton-equipment"].shape.height = 6
base exoskeleton is found in the game files at
Factorio->data->base->prototypes->equipment->equipment.lua
and looks like:
Code: Select all
{
type = "movement-bonus-equipment",
name = "exoskeleton-equipment",
sprite =
{
filename = "__base__/graphics/equipment/exoskeleton-equipment.png",
width = 64,
height = 128,
priority = "medium"
},
shape =
{
width = 2,
height = 4,
type = "full"
},
energy_source =
{
type = "electric",
usage_priority = "secondary-input"
},
energy_consumption = "200kW",
movement_bonus = 0.3,
categories = {"armor"}
}
for testing purposes, i even threw my files into an existing (and working) mod (just to make sure) and it's not working either.
anyone got an idea why it's not working?
Re: [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 7:03 am
by darkfrei
AlFara wrote: Tue May 28, 2019 6:33 am
as stated in the title, i'm looking for a way to modify the slot size of an armor module;
more precisely, the exoskeleton shall be overwritten to change it's grid size from 2x4 to 6x6
folder state:
base->folder->prototypes->item->equipment.lua (protptypes->equipment folder doesn't work either)
equipment.lua (with a bit of overkill):
Code: Select all
data.raw.equipment["exoskeleton-equipment"].shape.width = 6,
data.raw.equipment["exoskeleton-equipment"].shape.height = 6,
data.raw.item["exoskeleton-equipment"].shape.width = 6,
data.raw.item["exoskeleton-equipment"].shape.height = 6
Please find the mod for modding
viewtopic.php?f=135&t=45107
You can find all prototypes without your mod, then set up some parameters and insert in your mod just as
prototype.shape = {width=6, height=6}
Note that you need to place it in your armor again, migration makes no change. Add some log ('my code works') to be sure that your code was read. You must save the file to
data.lua as
UTF-8 without BOM.
Re: [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 7:14 am
by eduran
Setting the shape for the item does not do anything. Only the equipment prototype has a shape property:
Code: Select all
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape.width = 6
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape.height = 6
The fact that your code did not throw a "trying-to-index-nil-value" error tells me it did not even run. Since you did not put it into data.lua directly, did you actually require it there?
Re: [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 7:18 am
by eradicator
darkfrei wrote: Tue May 28, 2019 7:03 am
You must save the file to
data.lua as
UTF-8 without BOM.
UTF8 files
with BOM work just fine. And for anything but info.json the engine should throw an error if it doesn't like the encoding.
AlFara wrote: Tue May 28, 2019 6:33 am
base->folder->prototypes->item->equipment.lua (protptypes->equipment folder doesn't work either)
equipment.lua (with a bit of overkill):
Are you just replicating the base game folder structure in a mod? The structure is irrelevant. Only require() is important.
Re: [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 2:28 pm
by AlFara
darkfrei's mod put out the following lines:
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape.width = 2
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape.height = 4
putting the modified versions (which look like eduran posted) into the data.lua worked just fine
thanks@all
"Only require() is important"
okay, got it.
@eduran: as i've mentioned, i even took another mod and put the files in there for testing purposes (was one of bobs). the mod started like regular, did not throw an error and it didn't change the grid size at all. if i put the wrong lines into the data lua, it throws an error as you already said.
"did you actually require it there" i took one of bobs mods, checked where he changed stuff from exoskeletons and tried to do a similar thing to get it running.
Re: [solved] [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 2:39 pm
by eduran
Only data.lua / data-updates.lua / data-final-fixes.lua run automatically during the data stage. To run any other file (like your equipment.lua), you need to tell Factorio's Lua engine to run it. That is done with
Code: Select all
-- in data.lua
-- assuming you have equipment.lua in /my_mod_x.y.z/prototypes/
require "prototypes.equipment" -- no .lua at the end
Just copying your file into an existing mod does not run that file. By adding the code directly to data.lua you don't need require().
Re: [solved] [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 2:59 pm
by eradicator
eduran wrote: Tue May 28, 2019 2:39 pm
Code: Select all
require "prototypes.equipment" -- no .lua at the end
Just a correction for the future reader: require() is a just a function, and has a somewhat variable argument structure. The "." is just a
possible directory donator. You could just as well do
Code: Select all
require("__my-mod-name__/path/to/my/file.lua")
@OP:
Btw if you look at /factorio/data/base/data.lua you'll see that the base mod does huge blocks of require() too, no magic there.
Re: [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 3:19 pm
by darkfrei
AlFara wrote: Tue May 28, 2019 2:28 pm
darkfrei's mod put out the following lines:
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape.width = 2
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape.height = 4
It's the same as
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape={width = 2, height = 4}
Re: [solved] [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 3:58 pm
by eduran
darkfrei wrote: Tue May 28, 2019 3:19 pm
It's the same as
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape={width = 2, height = 4}
Yes, in this case. But your version will set all other properties stored in 'shape' to nil, while mine leaves them intact. It is safer to just overwrite the properties you want to change instead of replacing the entire table.
Re: [solved] [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 5:11 pm
by AlFara
thanks for the tutorial on require and data.lua, i didn't use that before in any way. I'll probably stick to data.lua for now unless i need to add a lot of stuff.
about the "...shape={width = 2, height = 4}" stuff, is there a way to write it in one line while overwriting the listed elements only? e.g. with a flag or sth.
Re: [solved] [0.17.43] basegame item edit - change armor grid module slot size
Posted: Tue May 28, 2019 5:18 pm
by Deadlock989
AlFara wrote: Tue May 28, 2019 5:11 pm
about the "...shape={width = 2, height = 4}" stuff, is there a way to write it in one line while overwriting the listed elements only? e.g. with a flag or sth.
Code: Select all
data.raw["movement-bonus-equipment"]["exoskeleton-equipment"].shape = {width = 2, height = 4, type = "full"}
The EquipmentShape prototype doesn't have any other parameters that are actually used by the game so this covers all the bases.
https://wiki.factorio.com/Types/EquipmentShape