Page 1 of 1

Invalid or missing substitution argument for log message: undefined: i is undefined

Posted: 02 October 2024, 21:49
by miquel_puig
Context:

My states:

Code: Select all

ST_PLAYER_TURN => [
        "name" => "playerTurn",
        "description" => clienttranslate('${actplayer} must choose an action'),
        "descriptionmyturn" => clienttranslate('${you} must choose an action'),
        "type" => "activeplayer",
        "args" => "argPlayerTurn",
        "possibleactions" => [
            "actSurfTurf", 
            "actExchange",
            "actYellowCard"
        ],
        "transitions" => [ACT_SURF_TURF => ST_CHECK_CAN_PUT_DOWN_SET, ACT_EXCHANGE => ST_CHECK_CAN_PUT_DOWN_SET, ACT_YELLOW_CARD => ST_CHECK_CAN_PUT_DOWN_SET]
    ],

    ST_CHECK_CAN_PUT_DOWN_SET => [
        "name" => "checkCanPutDownSet",
        "description" => '',
        "type" => "game",
        "action" => "stCheckCanPutDownSet",
        "updateGameProgression" => false,
        "transitions" => [ACT_ALLOW_PUT_DOWN_SET => ST_PUT_DOWN_SET, ACT_CANNOT_PUT_DOWN_SET => ST_NEXT_PLAYER]
    ],

    ST_PUT_DOWN_SET => [
        "name" => "putDownSet",
        "description" => clienttranslate('${actplayer} can put down a set'),
        "descriptionMyTurn" => clienttranslate('${you} can put down a set'),
        "type" => "activeplayer",
        "args" => "argPutDownSet",
        "possibleactions" => [
            "actPutDownSet",
            "actPass"
        ],
        "transitions" => [ACT_PUT_DOWN_SET => ST_NEXT_PLAYER, ACT_PASS => ST_NEXT_PLAYER]
    ],

    ST_NEXT_PLAYER => [
        "name" => "nextPlayer",
        "description" => '',
        "type" => "game",
        "action" => "stNextPlayer",
        "updateGameProgression" => true,
        "transitions" => [ACT_END_GAME => ST_END_GAME, ACT_NEXT_PLAYER => ST_PLAYER_TURN]
    ],
Whenver I transition to the ST_PUT_DOWN_SET state, the game crashes *only for the active player*. Other players show, as expected, "${actplayer} can put down a set", but on the active player I get:

Code: Select all

Invalid or missing substitution argument for log message: undefined: i is undefined
and

Code: Select all

During notification gameStateChange
t is undefined
I was searching a bit and this seems to be related to the arg method not returning an array, but that is not the case:

Code: Select all

public function argPutDownSet(): array
    {
        $this->debug("AAABBB");
        return [];
    }
(the debug is just me testing that the method is actually called, and it is)

Now I have seen that the args is optional if not needed and removed it from the state, but the error persists.

To me this state should be fairly similar to the ST_PLAYER_TURN, which works fine...
I'm a bit lost to what is the actual problem here, could someone point out the probably obvious mistake I'm making? ^^'

Re: Invalid or missing substitution argument for log message: undefined: i is undefined

Posted: 02 October 2024, 21:57
by RicardoRix
Seems like a few different things are happening:
Both errors say something about missing variables during notifications:
look for something like notifyAllPlayers() or notifyPlayer() make sure it's defined ok.

Code: Select all

	$rounds = 2;
	$this->notifyAllPlayers( 'log', clienttranslate('ROUND ${round}'), [ 'round' => Srounds]); 
	

Re: Invalid or missing substitution argument for log message: undefined: i is undefined

Posted: 03 October 2024, 14:59
by imralav
I am assuming that you properly set active player before transitioning to this state?
I don't think RicardoRix's suggestion is valid, considering that you get error on gameStateChange notification, which we don't invoke on our own, it's framework thing.

I would suggest to strip down this ST_PUT_DOWN_SET state to it's bare minimum, removing things one by one until it works. Then you'll get better idea at what is causing the problem. I don't see anything suspicious just by looking at it.

Re: Invalid or missing substitution argument for log message: undefined: i is undefined

Posted: 03 October 2024, 19:08
by miquel_puig
Thanks both for your responses! Turns out it was indeed a very basic mistake, I had set "descriptionMyTurn" instead of "descriptionmyturn" (all lowecase) for the failing state. After I changed it, it now seems to work :lol:

Re: Invalid or missing substitution argument for log message: undefined: i is undefined

Posted: 03 October 2024, 21:12
by imralav
miquel_puig wrote: 03 October 2024, 19:08 Thanks both for your responses! Turns out it was indeed a very basic mistake, I had set "descriptionMyTurn" instead of "descriptionmyturn" (all lowecase) for the failing state. After I changed it, it now seems to work :lol:
Oh man, I didn't even know that BGA Framework is so picky, but it makes sense, it's better to be strict like that. I just wish error messages were pointing to the true reason more clearly.