[UI] bug into the OPTIONS / gameplay Tab when used from main menu

Hit @BitVenom,

I’ve detected a bug into the ot_gameplay.lua tab, specifically concerning the SetTacticalDotScale() function.

It’s working correctly when the Gameplay tab is open directly ingame, but if opened from the main menu Options, then it will send an error (and thus preventing any additionnal custom slider command added to this screen to work, because the full scope is certainly considered as incorrect):

parameter: attempt to call global `SetTacticalDotScale' (a nil value)
stack traceback:
   1:  main of string "SetTacticalDotScale(1.0  );" at line 1
   2:  function `UI_ShowScreen' [C]
   3:  main of string "UI_ShowScreen("FEGameOptions", eTransition)" at line 1 

I suppose that the SetTacticalDotScale function is not declared in this scope.

Edit : just to clarify, it’s not something I added, it’s a vanilla HwRM bug

2 Likes

What are these tabs you’re talking about?

[edit]

Never mind sorry.

Hi @BitVenom,

just reviving this old “bug” thread as it’s still present in the current version of the game.

Found a solution:
ui\newui\ingameoptions.lua
Change ot_gameplay.lua to ot_gameplay_ingame.lua

ui\newui\optionstabs\ot_gameplay.lua
make a copy called ot_gameplay_ingame.lua
In the original delete the following code: ,[[SetTacticalDotScale(%spos);]]
This code is only useful when in a game. It just instantly updates the visible tactical dot scale when the slider moves.

This solution will use a different lua file for the main menu than in game (fegameoptions.lua calls ot_gameplay.lua and ingameoptions.lua calls ot_gameplay_ingame.lua). This eliminates the main menu bug, while maintaining the in-game functionality of changing the dot scale as soon as the the slider moves.

The Bad News
After fixing the bug, I tried adding a slider to the main menu options like this one:

Unfortunately, you’ll get the following error:

 parameter: attempt to call global `MainUI_ScarEvent' (a nil value)
stack traceback:
   1:  main of string "
..." at line 6 

Seems MainUI_ScarEvent only works in a game, not in the main menu. @Dwarfinator got any ideas, or is this a dead end?

2 Likes

why not change the code from [[SetTacticalDotScale(%spos);]] to [[if (SetTacticalDotScale) then SetTacticalDotScale(%spos) end]]
That way, SetTacticalDotScale will only be called if it exists.

[Edit]
I’m pretty sure MainUI_ScarEvent isn’t a part of the FrontEnd UI Scope. Also, I know that the IO functions (write() for example) are defiantly not part of the FrontEnd UI Scope.

3 Likes

That’s slick :slight_smile: Tested and working.

I guess adding sliders to the main menu options is a no-go then.

Edit: A solution has been identified here!

Yeah, I think that the main bug is that the main menu doesn’t have access to the same scopes than the ingame one. And that’s not something we can go around ourself unfortunately :frowning:

2 Likes