I can't make my mod work.
-
- Inserter
- Posts: 23
- Joined: Mon Aug 11, 2014 1:34 pm
- Contact:
I can't make my mod work.
I've copied the "locale" and "prototype" folders from the game's "base" directory into a new folder ("vbmod") inside the game's "mods" directory and changed some of its .lua files (to modify chest capacity and item stack sizes). I've even created an info.json file and put it inside my "vbmod" folder. The "mod" is recognized and active in the game but to no effect at all. What else do I need to do?
Re: I can't make my mod work.
If you didn't copy the data.lua file then Factorio won't actually be loading the prototypes.
It loads the data.lua which then requires all of the files the mod author has created, technically all prototypes could be placed in data.lua, but they're almost always separated for organization reasons.
I'm not sure that the locales are actually needed...but they wouldn't be for the method below (unless you add new prototypes of course, in which case the base locales won't help except as a template)
The 'proper' way to change things would actually be to use something likefor example to change the wooden-chest's inventory size you'd use This is preferable since you only change the parts of the prototype that you need to change (instead of overwriting the entire prototype) and so is more compatible with other mods (and is a bit shorter...), it also means that if the base game is updated so that it needs another property to load then you don't have to go back and change anything (theoretically). But if you don't plan to release the mod and don't use any mods that would conflict with your overwrites then...it doesn't matter too much as long as you get it working
If that doesn't help you get your mod working I'd suggest uploading it and providing a link so that we (other modders) can look at it ourselves.
It loads the data.lua which then requires all of the files the mod author has created, technically all prototypes could be placed in data.lua, but they're almost always separated for organization reasons.
I'm not sure that the locales are actually needed...but they wouldn't be for the method below (unless you add new prototypes of course, in which case the base locales won't help except as a template)
The 'proper' way to change things would actually be to use something like
Code: Select all
data.raw["prototype_type"]["prototype_name"].property = newValue
Code: Select all
data.raw["container"]["wooden-chest"].inventory_size = 32
If that doesn't help you get your mod working I'd suggest uploading it and providing a link so that we (other modders) can look at it ourselves.
-
- Inserter
- Posts: 23
- Joined: Mon Aug 11, 2014 1:34 pm
- Contact:
Re: I can't make my mod work.
Thank you very much for the explanation! I think I'll be able to get it working now.
However, for example, how is my data.lua file going to look like if I want to, say, change the wooden chest and iron chest capacities to 50?
Will it look like this?
Is there a shorter/cleaner way of changing the same property of an array of items or something? I'm asking this because I saw this console command to research all of the technologies and I was wondering if I could do something similar to set the capacity of all of the game's containers.
However, for example, how is my data.lua file going to look like if I want to, say, change the wooden chest and iron chest capacities to 50?
Will it look like this?
Code: Select all
data.raw["container"]["wooden-chest"].inventory_size = 50
data.raw["container"]["iron-chest"].inventory_size = 50
Code: Select all
for _, container in pairs(game.player.force.technologies) do container.inventory_size = 50 end
data.raw["container"]["iron-chest"].inventory_size = 40
data.raw["container"]["wooden-chest"].inventory_size = 20
Re: I can't make my mod work.
yesVBMeireles wrote:Will it look like this?
yep, a simple for loop would work hereVBMeireles wrote:I could do something similar to set the capacity of all of the game's containers.
Code: Select all
for key, prototype in pairs(data.raw["containers"]) do
-- the 'key' variable isn't used in this example, so you'd typically see people use _ for it
if prototype.inventory_size < 50 then prototype.inventory_size = 50 end
-- if you just set it to 50 you could overwrite a larger value
end
-
- Inserter
- Posts: 23
- Joined: Mon Aug 11, 2014 1:34 pm
- Contact:
Re: I can't make my mod work.
Unfortunatelly it doesn't. LOL. That's so sad, though. I've graduated in Law (though I'm not a lawyer) but I've also done 2 years of Science of Computing (it's a 5-year graduation here in Brazil), used to program and stuff but no longer. I miss the good old days of messing with C and its derivatives. I'll definitely read some Lua in order to get into Factorio modding, though.FreeER wrote:lua doesn't have a continue statement, if that means anything to you, if not then ignore that fact