Problem Description
I have a menu option on my post battle screen for returning to the css to change characters without going back to the main menu again. Currently it crashes the game, from looking at the errors I believe it is returning to the css, but something about the transition is causing the crash. The godot editor flags lines of code in the css as being connected. I don’t see how the css script would be involved if I had failed to make it point towards the css.
What drew my attention was the following line of code being flagged in the Setup func in the CSS
devices = menuParams["Devices"]
I noticed menuParams was the common ingredient in every flagged piece of code by the debugger that wasn’t involved in telling the game to go to css, so the theory I have currently developed is that the engine gets confused about devices because css isn’t being entered directly from device selection. Assuming this is true the solution then is to find a way for it to ‘remember’ the devices in the transition from post battle to css, but I don’t know how to execute that idea.
For full context the following blocks of code are how I direct the transition to the css.
CMenu-PostBattle:
func GoToCSS():
queue_free()
Castagne.Menus.FindMenuCallback("BackToCSS").call_func(null)
and
CastagneMenus:
func MCB_BackToCSS(args):
if(args == null):
args = [null, null]
get_tree().get_root().add_child(InstanceMenu("CSS", args[0], args[1]))
The latter is a copy of the default back to main menu function with the keywords swapped out.
I’ve identified some of the default code that might hold the answer since it looks to me to be how the engine keeps params consistent going from css to the battle, but I don’t understand it well enough on my own to modify or mimic it to get the result I want.
CMenu-Main:
func _MatchCSSParamsCommon(devices, mode):
return {
"Devices": devices,
"CallbackBack": FindMenuCallback("BackToMainMenu"),
"CallbackBackParams": [null, _configData],
"CallbackAdvance": FindMenuCallback("StartMatchFromCSS"),
"CallbackAdvanceParams": {
"Mode": mode,
}
}
and
CMenu-CSS:
func Advance():
if(_menuParams.has("CallbackAdvance")):
var selectData = []
for ps in playerSlots:
selectData.push_back(ps.GetAdvanceData())
var cbParams = (_menuParams["CallbackAdvanceParams"] if _menuParams.has("CallbackAdvanceParams") else null)
_menuParams["CallbackAdvance"].call_func({
"SelectData": selectData,
"Stage":stageSelected,
"Music":musicSelected,
"CallbackParams": cbParams,
"Devices": devices,
"CSSParams": _menuParams,
"ConfigData": _configData,
})
queue_free()
Technical Info
Castagne Version: 0.58 (latest)
Host Engine: Godot3
Genre: 2D Fighter