Cargo Ships


Adds massive cargo ships to the game, that function similarly to trains. Also adds deep sea oil, oil platforms, tanker ships, train bridges and other water based content.

Content
7 days ago
0.16 - 2.0
214K
Transportation Logistics Trains Mining Fluids Power

i Mod Compatibility with my mod

3 years ago

I've been trying to add compatibility with your mod to make oil infinite again in the ocean version only, however each attempt I've done has resulted in crashes. I am not a coder so I'm only guessing at what to do and I just can't figure it out. Here is each attempt I've done in data final fixes to my mod.

if game.active_mods["cargo-ships"] && settings.global["infinite-offshore-oil"].value == true then
data.raw["resource"]["deep_oil"].infinite = true
end

Apparently && isn't the and this feature for LUA so...

if game.active_mods["cargo-ships"] then
if settings.global["infinite-offshore-oil"].value == true then
data.raw["resource"]["deep_oil"].infinite = true
end
end

Game doesn't like it when I use game.active_mods so....

if data.raw["resource"]["deep_oil"] then
if settings.global["infinite-offshore-oil"].value == true then
data.raw["resource"]["deep_oil"].infinite = true
end
end

Something's wrong with global now so fuck it. I give up.

I may try moving my mod changes to data final fixes so that yours can copy oil before mine changes its infinite status before hand. But perhaps you can give advice on how to use game.active_mods or how to factor an "and" statement into an if else.

My mod; https://mods.factorio.com/mod/VasNoInfinite

3 years ago

Just to note, I fixed this situation for the time being, by making my mod edit oil after yours. I moved all the functions to data-final-fixes.

3 years ago

You should read about the Data life cycle! For the issue with game.active_mods, jump to section 6.

Basically, control.lua will be parsed when a saved game is loaded or a new game is started. This happens in the on_load stage, where you register event handlers. The game hasn't started yet at that point, so neither the global variable game nor your mod's table global are available yet. However, you do have access to the global variable script -- and you can get the list of active mods via script.active_mods.

About the issue with "&&": Just use "and" instead! Oh, and don't forget to test if the setting really exists before you try to index it! The first version of your mod would look like this:

if script.active_mods["cargo-ships"] and settings.global["infinite-offshore-oil"] and settings.global["infinite-offshore-oil"].value == true then
  data.raw["resource"]["deep_oil"].infinite = true
end

Hope that helps! :-)

3 years ago

Yea, I'm not a coder, so I don't understand much about the API. I can only do basic stuff such as if else statements. Its why my alt starts mod is completely broken.

New response