Character mod helper

by Pi-C

If your mod lets players use a character that looks differently, you'll have to decide whether you must overwrite the default character. This mod will help you with this decision, and make it really simple to overwrite the default or update the new prototypes in a safe way.

Internal
2 months ago
1.1 - 2.0
53.7K
Character

g [Fixed] Announcement at the launch of a game

2 years ago

Hi,
Each time I start my game, multi or solo, a message appears in the chat :

"You are using at least 2 character mods, but there is no active selector mod. Consider adding miniMAXIme:...."

I understand that a little publicity for your mods is reasonable, but maybe not at each launch ...
Especially since this message comes out even if miniMAXIme is active, in addition to or instead of RitnCharacters, itself noted in selector-mods.txt

May you please fix it ?

Many thanks

2 years ago

Hi!

Each time I start my game, multi or solo, a message appears in the chat :

What do you mean by "each time I start my game"? Is that "each time I create a new game" or "each time I load a saved game"? In single player mode, the function printing the message will be run from on_init (when a new game is created, or when the mod is added to an existing game) and on_configuration_changed (when you up- or downgrade Factorio; when you add, remove, or change mods; or when startup settings have changed). This is necessary: For example, if there was just one character mod when the game was saved, a selector mod wasn't necessary -- but if you add another character mod, you may wonder why your new character doesn't show up.

In multiplayer, the function is run each time a player joins the game. Normal players won't get a warning that no selector mod is available, that's just for admins. However, if a selector mod is missing, I must inform players about the new commands they can use to get a new character.

"You are using at least 2 character mods, but there is no active selector mod. Consider adding miniMAXIme:...."

I understand that a little publicity for your mods is reasonable

Actually, I've made this due to this request. Not perfect yet, ideally it should support other selector mods as well. However, the only other working selector mod I know of is Ritn Characters, which supports just five different characters out of the box. I think I should only recommend it if players have installed no other character mods except those supported by RC .(Gear Girl, Among us, IRobot, and Shrek).

Other selector mods can announce themselves to my helper mod, so the default character isn't overwritten. But the problem is that I wouldn't know which characters they support. (I know about Ritn Characters, so I can hardcode the list of characters supported by it. This isn't possible for mods I don't know, and it wouldn't even make sense for mods that don't have a hardcoded list of supported characters.)

but maybe not at each launch ...

I guess I could add a counter print the warning message just X times per player. However, I'd have to reset the counter when the configuration has changed.

Especially since this message comes out even if miniMAXIme is active

miniMAXIme is only a selector mod if active, it will only be regarded as a selector mod if the startup setting "Enable character selector" is active. As character selector mode is enabled by default, you probably turned off the setting at some point.

May you please fix it ?

I'll see what I can do. All of a sudden I'm working on four mods in parallel, which is a bit difficult to coordinate. :-D

2 years ago

Hi
My requests are not orders. However, I can't check the quality of machine translations. I'm sorry if I may have offended your sensibilities.

The announcement is made at each start, both on my multi-player game and on its local double. I'm administrator.

I have no idea about coding. I'm too lazy to look into that aspect of the game :)

I assume you check the other active mods in the game to raise your alert.
In my opinion, it lacks a control on the presence or not of the 2 complementary mods that you know, yours and that of Ritn.
Or it fails.
In my mind if none of these mods present: alert.If at least one of the two presents: no alert.

Again, I have no idea how complex the matter is, and my message is just the clumsy information of what seems to me to be an anomaly.

I blame you a lot for reinforcing my addiction to this game ;) ;)

2 years ago
(updated 2 years ago)

Sorry, I didn't understand why you would get a message each time even in single player. Now I've found that I didn't update a changed variable name when checking for selector mods. Could you try whether changing of line 56 of control.lua from

  for name, m_data in pairs(CMH.mod_list or {}) do

to

  for name, m_data in pairs(CMH.selector_mod_list or {}) do

fixes the issue?

2 years ago

In my opinion, it lacks a control on the presence or not of the 2 complementary mods that you know, yours and that of Ritn.
Or it fails.
In my mind if none of these mods present: alert.If at least one of the two presents: no alert.

It's not that simple: In my WIP version, I make sure that the mods are active in the required version is, and that a setting the mod may have to enable character selector mode (miniMAXIme has this) is in the expected state. RitnCharacters recently got a shortcut for opening the selector GUI during the game, and this shortcut depends on a setting. The warning the Character Mod Helper (CMH) issues is just about this: If there are several characters available, there should also be a mod that allows switching characters at runtime, so it doesn't consider RitnCharacters as active selector mod if the setting is off and will overwrite the default character. However, RitnCharacters allows to switch characters on starting a new game even if that setting is off -- but it will crash if you try to change to any character except the default character.

Another thing is that RitnCharacters currently supports just 4 custom characters. If there were more characters available, there wouldn't be a way to use them. Even worse: If none of these 4 characters was available, you could only use the default character even if there were 20 other characters! Therefore, will only count selector mods that support all characters that are available in the game as active selector mod.

Ideally, CMH should also work with other selector mods that I don't know or which may be written in the future, so my code should be general enough to handle as many situations as possible. It's back to the drawing board for now, this may take me some time to figure out. For the time being, it's unfortunate that you'll be stuck with the spam, but I think that's still better than getting a premature version that is bound to crash in some configurations.

2 years ago

Hi !
I ask Ritn to look at your last message. As much as you discuss it among specialists, without having a simple profiteer as an intermediary. ;)

2 years ago

Please try version 1.1.5!

2 years ago

Hi !
Ouch! Small incident at startup:

CharacterModHelper/common.lua:466: Wrong argument nil is not a valid character data!
stack traceback:
[C]: in function 'error'
CharacterModHelper/common.lua:466: in function 'arg_err'
CharacterModHelper/common.lua:540: in function 'assert'
CharacterModHelper/data-updates.lua:22: in main chunk

2 years ago

below is the server log

1.808 Loading mod CharacterModHelper 1.1.5 (data-updates.lua)
1.808 Script @CharacterModHelper/common.lua:237:


Entered file @CharacterModHelper/data-updates.lua


1.808 Script @CharacterModHelper/common.lua:237: Looking for known character mods that bypass us!
1.808 Script @CharacterModHelper/common.lua:237: GirlCharacter: {
characters = {
"GearGirl-skin"
}
}
1.808 Script @CharacterModHelper/common.lua:237: Found mod "GirlCharacter" (version 1.0.6)!
1.808 Script @CharacterModHelper/common.lua:237: Creating proxy for "GearGirl-skin".
1.808 Script @CharacterModHelper/common.lua:237:


Entered function get_loc_name(character "GearGirl-skin")
(@CharacterModHelper/common.lua: 566)


1.808 Script @CharacterModHelper/common.lua:237: char.localised_name: nil
1.808 Script @CharacterModHelper/common.lua:237: Is name of default character: {}
1.808 Script @CharacterModHelper/common.lua:237: Using character name!
1.808 Script @CharacterModHelper/common.lua:237:


Entered function create_data_proxy({new = "CMH_characters_GearGirl-skin", properties = {localised_name = "GearGirl-skin"}})
(@CharacterModHelper/common.lua: 747)


1.809 Script @CharacterModHelper/common.lua:237: Changed localised_name: GearGirl-skin
1.809 Script @CharacterModHelper/common.lua:237: Created flying-text "CMH_characters_GearGirl-skin".
1.809 Script @CharacterModHelper/common.lua:237:


Leaving function create_data_proxy()
(@CharacterModHelper/common.lua: 786)


1.809 Script @CharacterModHelper/common.lua:237: shrek: {
characters = {
"Shrek-skin"
}
}
1.809 Script @CharacterModHelper/common.lua:237: Found mod "shrek" (version 1.1.0)!
1.809 Script @CharacterModHelper/common.lua:237: Creating proxy for "Shrek-skin".
1.809 Script @CharacterModHelper/common.lua:237:


Entered function get_loc_name()
(@CharacterModHelper/common.lua: 566)


1.855 Error Util.cpp:83: Failed to load mod "CharacterModHelper": CharacterModHelper/common.lua:466: Wrong argument! nil is not a valid character data!
stack traceback:
[C]: in function 'error'
CharacterModHelper/common.lua:466: in function 'arg_err'
CharacterModHelper/common.lua:540: in function 'assert'
CharacterModHelper/common.lua:568: in function 'get_loc_name'
CharacterModHelper/data-updates.lua:22: in main chunk

2 years ago

Sorry, I don't see how the character couldn't exist, it should have been created by the time get_loc_name() is called. Anyway, I think it should work in version 1.1.6! :-)

2 years ago

Hi !

The alert at the start of the game has disappeared.

However, it was necessary to first launch the local copy to obtain an up-to-date mod-settings.dat file.
Once this new file is uploaded to the server, the multiplayer game started.
Unfortunately I didn't think to copy the logs :(

Thanks for your job.

2 years ago

The alert at the start of the game has disappeared.

Glad it's working now!

However, it was necessary to first launch the local copy to obtain an up-to-date mod-settings.dat file.
Once this new file is uploaded to the server, the multiplayer game started.

I've never run a headless server. Shouldn't it read the settings itself? After all, the server is what all joining players will sync with, so it should know all settings.

Thanks for your job.

You're welcome!

New response