Page 1 of 1
How to use states.inc.php for new project?
Posted: 25 June 2026, 03:29
by Kayvon
Is it at all possible to continue using states.inc.php (or a json equivalent) rather than the new file-per-state system? I have no interest in creating an entire directory just for states, in splitting my functions across several files, etc.
It's worked in the past, but now it blows up on my when I try to start a game for a project I just created, even after deleting the states directory:
Unexpected error: Propagating error from gameserver 1 (method: createGame): Fatal error during electrify setup: setupNewGame is redirecting to inexisting state class Bga\Games\MyGameName\States\PlayerTurn (reference: GS1 25/06 03:59:22) (reference: GS0 25/06 03:59:22)
(I have no PlayerTurn state -- that's being pulled in somehow)
Re: How to use states.inc.php for new project?
Posted: 25 June 2026, 08:06
by firgon
Independant from states.inc.php... setupNewGame should now return the id of the next state. Maybe your problem is related to this behavior...
Re: How to use states.inc.php for new project?
Posted: 25 June 2026, 10:17
by thoun
It is. New states classes are more than just splitting the code in dedicated files, even if in itself it is a good improvement for code readability. I strongly encourage you to use them, and not produce "new legacy code"

Re: How to use states.inc.php for new project?
Posted: 25 June 2026, 13:49
by Kayvon
SetupNewGame allowed returning the state number from states.inc.php. It works in all other games.
thoun wrote: ↑25 June 2026, 10:17
New states classes are more than just splitting the code in dedicated files, even if in itself it is a good improvement for code readability.
Right. It's also splitting zombie code into a dozen files, which makes it so much harder to maintain. And splitting action functions, so now I can't have common action functions that work in multiple states. I can no longer have my state handlers or arg handlers colocated. Worst of all, there's no single place I can look to see the state flow of the game because it's spread across multiple files.
I totally get that this is an improvement for some people, but it's a giant step backwards in maintainability for me. Rather than improving readibility, it actually decreases it and introduces opportunities for bugs.
Re: How to use states.inc.php for new project?
Posted: 25 June 2026, 14:09
by GTSchemer
Kayvon wrote: ↑25 June 2026, 13:49
SetupNewGame allowed returning the state number from states.inc.php. It works in all other games.
thoun wrote: ↑25 June 2026, 10:17
New states classes are more than just splitting the code in dedicated files, even if in itself it is a good improvement for code readability.
Right. It's also splitting zombie code into a dozen files, which makes it so much harder to maintain. And splitting action functions, so now I can't have common action functions that work in multiple states. I can no longer have my state handlers or arg handlers colocated. Worst of all, there's no single place I can look to see the state flow of the game because it's spread across multiple files.
I totally get that this is an improvement for some people, but it's a giant step backwards in maintainability for me. Rather than improving readibility, it actually decreases it and introduces opportunities for bugs.
Just chiming in to agree with this, as another developer.
Thankfully the legacy states system is still supported for now.