Couple of Questions And Seeking Recommendations

Place to get help with not working mods / modding interface.
Post Reply
Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Couple of Questions And Seeking Recommendations

Post by Suf »

Hi

First Question:I've made an assembling machine type entity with idle_animation and animations both have the same animation count and everything
but when the entity start working it disappears, any idea why?

Second Question :I was trying to make starting items for the players,but that worked only in map editing mode,so how to make it affects any mode?

Third Question:This out of curiosity more than actual question ;i'm planning to add brand new belts and enemies,but i've not seen many mods that do that
it just re-tinting them,why is that?

Seeking recommendations from those who made mods :what is the best way to optimize mod structure(if that affects loading),is there something i should add in mod folder to ease mod compatibility?

Thanks in Advance.

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

Re: Couple of Questions And Seeking Recommendations

Post by Deadlock989 »

1. Post your code. Don't make people guess what you've done.

2. See viewtopic.php?p=531991#p531991 .

3. Making new sprites and animations from scratch is time-consuming even if you have any talent for it; with belts and units ("enemies"), you picked two of the most difficult entities in the game. Belts are incredibly unforgiving and have a bizarrely distorted perspective compared to almost everything else. Units ideally would have several different animations for different states (moving, idling, attacking etc.) so you'd need to be good with rigging as well as design. You could easily spend a week on the former and more on the latter if you wanted.

4. I don't fully understand your last request but I think the answer is "no".
Image

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Couple of Questions And Seeking Recommendations

Post by Suf »

Deadlock989 wrote:
Wed Apr 21, 2021 10:39 pm
1. Post your code. Don't make people guess what you've done.

2. See viewtopic.php?p=531991#p531991 .

3. Making new sprites and animations from scratch is time-consuming even if you have any talent for it; with belts and units ("enemies"), you picked two of the most difficult entities in the game. Belts are incredibly unforgiving and have a bizarrely distorted perspective compared to almost everything else. Units ideally would have several different animations for different states (moving, idling, attacking etc.) so you'd need to be good with rigging as well as design. You could easily spend a week on the former and more on the latter if you wanted.

4. I don't fully understand your last request but I think the answer is "no".
So i put that code in the control.lua and now there's no items at all in other mode than map editing mode

Code: Select all

script.on_init(onModInit)


function initPlayer(player)
	if player.character == nil then return end
	if global == nil then
		global = {}
	end
	if global.donePlayers == nil then
		global.donePlayers = {}
	end
	if global.donePlayers[player] ~= nil then return end
	global.donePlayers[player] = true

	player.get_inventory(defines.inventory.character_main).clear()
	player.get_inventory(defines.inventory.character_armor).clear()
	player.get_inventory(defines.inventory.character_guns).clear()
	player.get_inventory(defines.inventory.character_ammo).clear()

	local items = {

		
		{"item", 1},
        {"item", 1},
		{"item", 1},
		{"item", 1},
		{"item", 1},
	}
	for _, v in pairs(items) do
		player.insert{name = v[1], count = v[2]}
	end




end

function onPlayerJoined(event)
	local player = game.players[event.player_index]
	initPlayer(player)
end

script.on_event({defines.events.on_player_joined_game, defines.events.on_player_created}, onPlayerJoined)

function onModInit()
	if remote.interfaces["freeplay"] then
		remote.call("freeplay", "set_skip_intro", false)
		remote.call("freeplay", "set_disable_crashsite", false)
		remote.call("freeplay", "set_respawn_items", {"item", 1,"item", 1,"item", 1,"item", 1,"item", 1})
		remote.call("freeplay", "set_created_items", {"item", 1,"item", 1,"item", 1,"item", 1,"item", 1})
	end
		--for _, v in pairs(items) do
		--player.insert{name = v[1], count = v[2]}
	--end
end

script.on_init(onModInit)
and yeah items are duplicate now,but if i remove the one above it gives me an error and if i remove the bottom ones it will be the default "vanilla only items in other mode than map editing"

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

Re: Couple of Questions And Seeking Recommendations

Post by Deadlock989 »

Follow the link I gave and then scroll down a few posts to jamiechi1's answer. The table of items is given as key/value pairs where the key is the item name and the value is the number of items to be given, e.g.

Code: Select all

{
	["iron-plate"] = 100,
	["copper-plate"] = 200,
}
Image

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Couple of Questions And Seeking Recommendations

Post by eradicator »

My tutorial also talks about the freeplay starting items interface. If you use set_* without get_* you overwrite items added by other mods.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Couple of Questions And Seeking Recommendations

Post by Suf »

Deadlock989 wrote:
Thu Apr 22, 2021 10:12 am
Follow the link I gave and then scroll down a few posts to jamiechi1's answer. The table of items is given as key/value pairs where the key is the item name and the value is the number of items to be given, e.g.

Code: Select all

{
	["iron-plate"] = 100,
	["copper-plate"] = 200,
}
i've used another code and it worked in every mode ,but apparently there's no console command to remove a starting item from the player?https://wiki.factorio.com/Console because now i have vanilla items in additional of custom items and using this

Code: Select all

player.get_inventory(defines.inventory.character_ammo).clear()
and the rest of clear commands just removes everything including the custom items.

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Couple of Questions And Seeking Recommendations

Post by Suf »

Ok problem solved ; for anyone who wants to code this the "noobish" way here's the code:

Code: Select all

script.on_init(function()
	if not remote.interfaces["freeplay"] then return end
	local created_items = remote.call("freeplay", "get_created_items")
	created_items["item"] = 1 --to add it as starting item
	created_items["burner-mining-drill"] = nil--remove vanilla items like this
	created_items["pistol"] = nil
	created_items["firearm-magazine"] = nil
	created_items["stone-furnace"] = nil
	created_items["wood"] = nil
	created_items["iron-plate"] = nil
	remote.call("freeplay", "set_created_items", created_items)
end)

Post Reply

Return to “Modding help”