Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hello Your Spriteness,

I came back to you after extensively using Truestate (not Plus) and I have some question regarding the system.

1/ Why is it that when using `truestate_create_state` the function will trigger `truestate_set_default` ? On top of that `truestate_set_default`will execute the srcipt but, as I'm in the Create Event, I don't want any state's script to be executed.

There's case where it doesn't work. For exemple :

//playerSpawner Manager object
inst = instance_create_layer(x,y,"layer", obj_Player)
inst.PlayerID = 1 //or whatever value
//Player Object - player_state_init function
camera = instance_create_layer(x,y,"layer", obj_Camera)
camera.viewport = PlayerID

GMS will tell me that PlayerID is not set when it will try to assign `PlayerID` to the Camera's `viewport` variable. It's because `player_state_init` is fired when `truestate_create_state` is called in the Create Event of my new created obj_Player.

But I want `player_state_init` to be fired only when I switch to the Init state.

2/Related to 1/, I think `truestate_set_default` should be split in to distinct function : 

  • truestate_set_default : where the systeme will rollback to if no state are found
  • truestate_set_start : which will be the starting state of the object.

The starting state is usually not the one you want to be the default. For exemple, I would want to launch an "intro" state, like my character walking in screen, but I don't want this state to be the default one during gameplay.

So is it me who get it wrong ? is this a bug or a "flaw" in the system and how can I work around that without doing the Alarm trick ?

Thank you :D

Good question!

Yes so having it this way solves some issues, but as you've discovered, can cause some others depending on what you are doing in your state new block.

It actually used to work the way you described, with the set default being a separate function.

There are a lot of ways to work around this, but the way you suggested would be totally okay.  You have all the scripts, if you feel it should work differently from the way it does, go ahead and change it!  Rip the set default out of the create script and split it out to its own function.  And you can prevent the setting of the default from running the state new if you'd like and see if that simplifies things for you (though you may find it causes more problems)