Jump to content

Recommended Posts

https://gist.github.com/DrSmugleaf/af7849911d7e7f47aaf58a301e2ad1e5

The code on line 29 and 88-89 of data/characters/abigail.lua is only working when you load a world with an existing galaxysword or abigail's pan flute, respectively.

 

When the items are not in the world already, nothing changes:

Spoiler

TXOjgGQ.png

 

When they are, either inventory or ground, everything works, they are only craftable near the shadow manipulator and the recipe changes:

Spoiler

k2bCJc2.jpg

aiFAdO1.jpg

 

I have tried crafting the galaxy sword without creative mode when the recipes are bugged out and you can craft and use it just fine.

Every other change except those work, regardless of if the item is on the ground or inventory.

 

 

However everything works fine if the recipe changes are put inside the first balanceabigail function at line 7, line 27-29 like this: https://github.com/DrSmugleaf/Mod-Character-Rebalancing-2/blob/a0daf8b0d08050adbe3ca207db27619bf3392d91/data/characters/abigail.lua

Spoiler

DUY7lmG.jpg

UwbqJI8.jpg

 

 

what

help

Mod-Character-Rebalancing-2-broken.zip

Mod-Character-Rebalancing-2-working.zip

 

Edit: The character mod is here

Edited by DrSmugleaf

The function passed into AddPrefabPostInit is run when the object is spawned. If there are no objects being spawned (i.e. there is no such object in the saved world or it isn't being crafted) it won't run.

I think such changes are usually done directly in the modmain (with the balancing mod having lower priority than the mod that creates those recipes).

You can also try something like

AddSimPostInit(function()
	if GLOBAL.KnownModIndex:IsModEnabled("workshop-647062183") or GLOBAL.KnownModIndex:IsModTempEnabled("workshop-647062183") then
		AllRecipes["sdpan_flute"].ingredients = {Ingredient("cutreeds", 5), Ingredient("nightmarefuel", 4), Ingredient("rope", 1)}
		AllRecipes["sdpan_flute"].level = TECH.MAGIC_THREE
		AllRecipes["galaxysword"].level = TECH.MAGIC_THREE
	end
end)

which would run after all the mods are loaded, so mods' priorities don't matter.

53 minutes ago, Muche said:

The function passed into AddPrefabPostInit is run when the object is spawned. If there are no objects being spawned (i.e. there is no such object in the saved world or it isn't being crafted) it won't run.

I think such changes are usually done directly in the modmain (with the balancing mod having lower priority than the mod that creates those recipes).

You can also try something like


AddSimPostInit(function()
	if GLOBAL.KnownModIndex:IsModEnabled("workshop-647062183") or GLOBAL.KnownModIndex:IsModTempEnabled("workshop-647062183") then
		AllRecipes["sdpan_flute"].ingredients = {Ingredient("cutreeds", 5), Ingredient("nightmarefuel", 4), Ingredient("rope", 1)}
		AllRecipes["sdpan_flute"].level = TECH.MAGIC_THREE
		AllRecipes["galaxysword"].level = TECH.MAGIC_THREE
	end
end)

which would run after all the mods are loaded, so mods' priorities don't matter.

So with that in mind, does that mean the recipe changes wont run even if placed inside the first, character balancing function, if there is none of that character in the world at the time?

I guess it's not a big deal...unless the recipe is available to every character? Can't think of any other cases.

As for your suggestion, should I just do that everywhere? Would something like this in data/characters/init.lua work?

AddSimPostInit(function()
	if KnownModIndex:IsModEnabled("workshop-376244443") then
		use "data/characters/saber"
	end
	if KnownModIndex:IsModEnabled("workshop-647062183") then
		use "data/characters/abigail"
	end
end)

 

Should I do something completely different and change the structure of the files? (As now would be the time since there's only 2 characters and the mod isn't even published)

Edited by DrSmugleaf
2 hours ago, DrSmugleaf said:

So with that in mind, does that mean the recipe changes wont run even if placed inside the first, character balancing function, if there is none of that character in the world at the time?

That's correct.

 

2 hours ago, DrSmugleaf said:

As for your suggestion, should I just do that everywhere? Would something like this in data/characters/init.lua work?


AddSimPostInit(function()
	if KnownModIndex:IsModEnabled("workshop-376244443") then
		use "data/characters/saber"
	end
	if KnownModIndex:IsModEnabled("workshop-647062183") then
		use "data/characters/abigail"
	end
end)

Should I do something completely different and change the structure of the files? (As now would be the time since there's only 2 characters and the mod isn't even published)

No, that would not work. Functions passed to AddPrefabPostInits from all mods are collected before functions passed to AddSimPostInit or AddGamePostInit are run, so running them that late won't have any effect.

Structure of the files looks reasonable. As long as it works for you I don't think it needs to be changed.

9 hours ago, Muche said:

That's correct.

 

No, that would not work. Functions passed to AddPrefabPostInits from all mods are collected before functions passed to AddSimPostInit or AddGamePostInit are run, so running them that late won't have any effect.

Structure of the files looks reasonable. As long as it works for you I don't think it needs to be changed.

Another thing is, looking at modutil.lua KnownModIndex:IsModEnabled(modname) and KnownModIndex:IsModTempEnabled(modname) they look like they do the same thing to me, do they do something different? Should I use both and also KnownModIndex:IsModForceEnabled(modname)?

The full check (as done by KnownModIndex:GetModsToLoad) would be:

if (self:IsModEnabled(modname) or self:IsModForceEnabled(modname) or self:IsModTempEnabled(modname) ) and not self:IsModTempDisabled(modname) then

Enabled mod is a mod that is enabled by the client.
TempEnabled mod is a all_clients_require_mod=true mod that the server has enabled, thus the client has to enable it as well.
ForceEnabled mod is a mod that is specified as such in [mods/modsettings.lua[/i] (used mostly for debugging the mod so it stays enabled even after it crashes; I woudn't worry about this type at all).
TempDisabled mod is a client_only_mod=false mod that is enabled by the client, but not enabled by the server, thus the client has to disable it.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...