sfall-team / sfall

sfall - Engine modifications for Fallout 2
https://sfall-team.github.io/sfall/
GNU General Public License v3.0
346 stars 40 forks source link

Identifiers of global scripts. #375

Closed FakelsHub closed 3 years ago

FakelsHub commented 3 years ago

I was thinking maybe for global scripts to make unique identifiers. There are situations when there are two identical scripts, but with different names, the use of indifiers will not allow the second script to be executed with the same indifier. (or two scripts from the same mod but doing different things.)

Example ID: "NPC_ARMOR_MOD”

NovaRain commented 3 years ago

I was thinking maybe for global scripts to make unique identifiers. There are situations when there are two identical scripts, but with different names, the use of indifiers will not allow the second script to be executed with the same indifier. (or two scripts from the same mod but doing different things.)

Example ID: "NPC_ARMOR_MOD”

I suppose the idea only works if both global scripts are using the unique identifier? If another script doesn't use an ID (because obviously it requires editing existing ones), sfall will still run both as it should. Just curious, do you have a real example of the said issue that happened on other guys (which gave you the idea)?

Lexx2k commented 3 years ago

Is this because of the renamed gl_partyarmor in ettu? I could just rename it back to gl_npc_armor - hated how the naming convention clashes with gl_partycontrol.

wipe2238 commented 3 years ago

will not allow the second script to be executed

When/If that's going to be implemented, maybe info about clashing scripts could use something much more visible (up to "more annoying") than single line in sfall.log? While modders know their global scripts, players rarely have any clue, so they need something what would slap them in the face (read: it will be shown on game screen in big red letters).

Error message could show up in dialogbox with single OK button which closes game after clicking. If player comes crying to mod author, everything will be more obvious to them. No need to waste time debugging because player "forgot to mention" that he installed some other mods...

FakelsHub commented 3 years ago

Yes, everything is easier than it seems.

if (game_loaded) then 
   if (check_script_id("UNIQUE_NAME") == true) return;
   ...
else 
....
FakelsHub commented 3 years ago

Just curious, do you have a real example of the said issue that happened on other guys (which gave you the idea)?

Previously, there was a problem of executing two inventory filter scripts with different names at the same time. Now there is also a problem with the highlight mod when there are 2 scripts original and from Burn.

Lexx2k commented 3 years ago

If you just not execute the script, players will likely not know why a script / feature isn't working. Needs at least a printed message somewhere, imo. But I guess that's up to the script author.

NovaRain commented 3 years ago

Just curious, do you have a real example of the said issue that happened on other guys (which gave you the idea)?

Previously, there was a problem of executing two inventory filter scripts with different names at the same time.

I suppose in this case the two scripts are identical but just with different names? (duplication)

Now there is also a problem with the highlight mod when there are 2 scripts original and from Burn.

It would be what I said in my first reply: if another script doesn't use a unique ID (either the author didn't use it, or player installed an older one from other sources), sfall still runs both, and the unique ID doesn't have any help.

wipe2238 commented 3 years ago

Give option to disallow global scripts which don't set own id and problem with old scripts goes away. Yes, it breaks backward compatibility, but it would be mod authors choice, not something coming from sfall, so i think it's fine.

if( global_scripts_without_id > 0 ) then
begin
   message_box("Go away dude");
   signal_end_game;
end
FakelsHub commented 3 years ago

Give option to disallow global scripts

too radical)

Lexx2k commented 3 years ago

Couldn't this identifier thing be done with simply using sfall global variables? Like, before running the script, check if sfall gvar X is true, if not, set it to true and run the script.

Of course all other mentioned issues still persist (what if someone just changes the gvar), but it wouldn't require a specific new feature.

burner1024 commented 3 years ago

If there are 2 scripts with the same name coming from different authors, it takes cooperation between them to work it out anyway. I don't see what benefits would an identifier provide.

wipe2238 commented 3 years ago

using sfall global variables

Yeah. No. They require exactly 8 chars, and going back to cryptic DOS naming scheme isn't improvement at all.

I don't see what benefits would an identifier provide.

If scripts would conflict so hard they would crash game on start/load, neither of them would be able to display any kind of warning; assuming any of them would even try to in the first place. Sfall, on other hand, could detect duplicated names before any of them is even executed (ofc, it depends how/where IDs would be stored), and can inform player/modder what is wrong instead.

Any kind of "haha your code sux, here's why" is better than current crash dialog box which tells basically nothing to anyone except two people at top of this page.

burner1024 commented 3 years ago

If scripts would conflict so hard they would crash game on start/load, neither of them would be able to display any kind of warning; assuming any of them would even try to in the first place.

Are we talking theoretical scenarios now? And I think that scripts being able to crash the game means an engine bug by itself (unless UnsafeScripting is involved). And scripts might as well clash/crash without having identical names and/or contents.

I agree that clarity is important. However, the described problem seems to be a little contrived to me, and its scope is somehow creeping during the discussion. Maybe just log all found global scripts, along with their override order?

(I don't have any particular issue with ids or displaying error messages, I just think as proposed this will be a marginal improvement in very rare cases at best)

FakelsHub commented 3 years ago

Convert to Discussion