Where are the Lua/Force files located?

Place to get help with not working mods / modding interface.
kenji_03
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Apr 27, 2015 5:52 am
Contact:

Where are the Lua/Force files located?

Post by kenji_03 »

Specifically, I am trying to find where the code is for "https://forums.factorio.com/wiki/inde ... inprogress" so I can modify it in my mod.

I want to make a New Game Plus mod where the player can load up a "cargo plane" and have that plane spawn in a new map (or at least the contents of the plane). The problem is, I am new to C++ and coding in general, so I need to see an example in order to modify it -- hence why I need to find the getshiplandinginprogress code.
Kevin94
Inserter
Inserter
Posts: 46
Joined: Mon Dec 08, 2014 10:39 pm
Contact:

Re: Where are the Lua/Force files located?

Post by Kevin94 »

At the current time (and i don't think this will change in future) you can not mod the c++ part. The only available language for modding is lua.
But i dont think this code would help you as getshiplandinginprogress should only be a simple getter function for an internal gamestate. This is because shiplanding at its current form is only a count down, that gets startet when you place a rocket defense.

If you haven't heart yet: what you're trying to mod is very similar to the plans for the next releases (proper endgame content). See the Friday Facts of the last weeks for more details.

When you have played the campaigns you might have noticed, that you often have to gather resources for the next level. But in the next level, at a nother spot you always start with the same resources ans sience researched independent what you researched/gathered in the former level. What im trying to say: Your plan won't work, as it is not supported.
kenji_03
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Apr 27, 2015 5:52 am
Contact:

Re: Where are the Lua/Force files located?

Post by kenji_03 »

Thank you for your reply Kevin94. I know they are working on end-game content, but I don't want to wait 2 months for it. Since I clearly have the time, I don't see why I shouldn't make a mod for myself (and others) in the mean time to add to the life of the end-game.

The plan I had was to make a mod that added a small C++ variable to store the values of the items in an array, and to use that array to change the lua starting equipment.

So, you load up your "chest" with the 5 items you want to take with you. Those items get stored in an external array. A separate "FreeMode+" will exist, that will have lua code to allow for the player to start with the 5 items they wanted to carry over in their inventory.

So... it would look like this in the control.lua for the "FreeMode+"

Code: Select all

game.oninit(function()
  local character = game.player.character
  character.insert{name="iron-plate", count=8}
  character.insert{name="pistol", count=1}
  character.insert{name="basic-bullet-magazine", count=10}
  character.insert{name="burner-mining-drill", count = 1}
  character.insert{name="stone-furnace", count = 1}
  character.insert{name="carry-over-item[0]", count = carry-over-amount[0]}
  character.insert{name="carry-over-item[1]", count = carry-over-amount[1]}
  character.insert{name="carry-over-item[2]", count = carry-over-amount[2]}
  character.insert{name="carry-over-item[3]", count = carry-over-amount[3]}
  character.insert{name="carry-over-item[4]", count = carry-over-amount[4]}
  initattackdata()
  game.showmessagedialog(gt("msg-intro"))
end)
Since I think you're right that I cannot do that, I'm instead working on making it so there's a "FreeMode+" with a modified starting inventory. The problem is, I am still new to lua code and don't know how to prevent it from being available until certain conditions are met (such as filling that "cargo plain" chest with the required items). I'm mimicking the code from chapter 2 of the beta missions.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5266
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Where are the Lua/Force files located?

Post by Klonan »

You can give items any time of the day with lua commands in your own custom control.lua
something like this

Code: Select all


function give_items()

		game.player.insert({name = "coin" , count = 100})
		game.player.insert({name = "iron-plate" , count = 100})
		game.player.insert({name = "copper-plate" , count = 100})
		game.player.insert({name = "rocket-defense" , count = 100})

	end
Then set up some event, say, when the plane is full... just add 'give_items()' in the script and it will give them what you'd like.
kenji_03
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Apr 27, 2015 5:52 am
Contact:

Re: Where are the Lua/Force files located?

Post by kenji_03 »

Yepp, that's what I was thinking of doing. Thank you for the consistent and speedy replies by the way! :D

The problem I'm encountering presently has to do with getting my mod to load sprites (I ensured it was spelled exactly the same as the file path, as stated on the Modding FAQ, so I'm not sure why it isn't working. Maybe it has to do with needing to put the version number in the folder name, but at this point I've kind of just given up on custom graphics of any kind).

On the note of my original idea, it seems you can save text to a file using LUA code, the problem seems to be reading that information from the file after saving it. MakeFile. Any thoughts on how to retrieve that data from the file once it's outputted?

If I can do that, then it's a simple (if tedious) list of "if, than, else" or whatever the equivalent of C++ "case" is for lua to make the new game carry over whatever the player puts in that plane, and since MAKEFILE saves the data to an external file, I could let a person start the custom "New Game Plus" freemode map with whatever they previously had in their original "freeplay" game!
Kevin94
Inserter
Inserter
Posts: 46
Joined: Mon Dec 08, 2014 10:39 pm
Contact:

Re: Where are the Lua/Force files located?

Post by Kevin94 »

I also thought about using makefile. But at the current time there is no read counterpart (afair they removed it because of some security issues). You can write the data and then prompt the user to manually copy it in a text field like blueprint mod/Foreman do it.

Addressing your graphics Problem, You have to specify the path like so: __ModNameWithoutVersion__/PathWithinModFolder/file.png
Post Reply

Return to “Modding help”