Help me update an old private mod to 1.1

Looking for a mod? Have a review on a mod you'd like to share?
Post Reply
Peter34
Smart Inserter
Smart Inserter
Posts: 1096
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Help me update an old private mod to 1.1

Post by Peter34 »

I made an old mod for my own use, for 0.16 or 0.17, and despite being very simple it worked well.

Now it no longer works, and I'm not sure what to do. I've tried removing the dependencies on other mods (Agent Orange (which I've "hack-updated" to 1.1 for my own use), as well as Klonan's Torches mod), but that didn't make the mod work, so the issue is clearly something else.

This is the entirety of the control.lua file, which did work 2-3 years ago:

Code: Select all

script.on_event(defines.events.on_player_created, function(event)
		local player = game.players[event.player_index]
		player.insert{name="solid-fuel", count=4}
		player.insert{name="cliff-explosives", count=10}
		player.insert{name="wooden-chest", count=2}
		player.insert{name="burner-mining-drill", count=2}
		player.insert{name="stone-furnace", count=2}
end)
What do I update it to, to make it work in 1.1?

Pi-C
Filter Inserter
Filter Inserter
Posts: 974
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Help me update an old private mod to 1.1

Post by Pi-C »

I think you should also listen to on_cutscene_cancelled. (Since Factorio 1.0, a player will be created without an attached character when a new game is started; the character will be added once the cutscene has been cancelled or finished of its own.)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2862
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Help me update an old private mod to 1.1

Post by darkfrei »

Peter34 wrote:
Thu Jan 14, 2021 6:10 am

What do I update it to, to make it work in 1.1?
https://wiki.factorio.com/Console#Add_i ... _inventory

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2325
Joined: Fri Nov 06, 2015 7:41 pm

Re: Help me update an old private mod to 1.1

Post by Deadlock989 »

OP hasn't given any info about what it is that's not working - an error message would have helped people help you. But Pi-C has probably guessed correctly, that the player is no longer guaranteed to have a character at the start of new games and therefore has no inventory to insert anything into. Assuming you want to play regular "freeplay" scenario Factorio, the default scenario for Factorio games, it has its own remote interface handler for defining starting and respawn inventories for all players. That same scenario also generates the "crash" cutscene and the cancelling of said cutscene so that is all handled for you as well.

Code: Select all

	if remote.interfaces["freeplay"] then
		remote.call("freeplay", "set_skip_intro", true/false)
		remote.call("freeplay", "set_disable_crashsite", true/false)
		remote.call("freeplay", "set_respawn_items", {list_of_items})
		remote.call("freeplay", "set_created_items", {list_of_items})
	end
These should be called from within the on_init() handler. The lists of items are key/value pairs where the key is the item name and the value is the amount. If you want no items, use an empty list {}.

Post Reply

Return to “Questions, reviews and ratings”

Who is online

Users browsing this forum: No registered users