GithubHelp home page GithubHelp logo

Changing another object's state in a leave event still cause the object to run the now-previous state's step event about snowstate HOT 3 CLOSED

sohomsahaun avatar sohomsahaun commented on May 31, 2024
Changing another object's state in a leave event still cause the object to run the now-previous state's step event

from snowstate.

Comments (3)

sohomsahaun avatar sohomsahaun commented on May 31, 2024
  1. What version of SnowState are you on?
  2. You are saying fsm.get_current_state() in the "combat" state is showing "idle"?
  3. "the squad variable provided in the obj_unit is undefined" - how is it provided?

from snowstate.

Paughton avatar Paughton commented on May 31, 2024
  1. I am using the latest version of SnowState.
  2. Yes, the string "idle" is copied to my clipboard before the error is displayed. The combat state for the obj_unit runs fine and doesn't produce any errors, until the squad object is destroyed.
  3. The squad variable is provided when the object is created.

Here is how I create the unit object:

var player_squad = instance_create_layer(352, 288, "Map_Instances", obj_squad);
var player_squad_footman1 = instance_create_layer(0, 0, "Combat_Instances", obj_unit, {
	properties: footman_properties,
	squad: player_squad,
	col: 0,
	row: 1
});
player_squad.units[0][1] = player_squad_footman1;

Here was the error I was getting:

___________________________________________
############################################################################################
ERROR in
action number 1
of  Step Event0
for object obj_unit:

Unable to find instance for object index 100007
 at gml_Script_anon____struct___29_gml_Object_obj_unit_Create_0_468____struct___29_gml_Object_obj_unit_Create_0 (line 34) -               if (squad.owner_index != obj_game.unit_turns[obj_game.current_unit_turn_index].squad.owner_index) {
############################################################################################
gml_Script_anon____struct___29_gml_Object_obj_unit_Create_0_468____struct___29_gml_Object_obj_unit_Create_0 (line 34)
gml_Script_anon_SnowState_gml_GlobalScript_SnowState_9581_SnowState_gml_GlobalScript_SnowState (line 342) -               if (_args == undefined) return _func();
gml_Script_anon_SnowState_gml_GlobalScript_SnowState_9017_SnowState_gml_GlobalScript_SnowState (line 333) -               with (__owner) _pyramid(_func, _args);
gml_Script_anon_anon_SnowState_gml_GlobalScript_SnowState_4460_SnowState_gml_GlobalScript_SnowState_4576_anon_SnowState_gml_GlobalScript_SnowState_4460_SnowState_gml_GlobalScript_SnowState (line 162) -                      exec(event, undefined, _args);
gml_Object_obj_unit_Step_0 (line 3) - fsm.step();

One interesting thing to note was the error was started by fsm.step(); even though the instance was previously destroyed, and to my knowledge that shouldn't happen? The GML manual states:

Also, although the destroy event is performed, the instance is not immediately removed from the game, and it will continue to perform the code contained in the current event. Only when the current event is over will it be removed from the game.

from snowstate.

sohomsahaun avatar sohomsahaun commented on May 31, 2024

From the given info, I'm unsure what the error is. But it doesn't look like a SnowState issue.
If you require GML assistance, I suggest asking in the GameMaker Discord server. We might need to see more of the codebase.
If you think it's a SnowState issue, please create a small project demonstrating the issue and send it to me.
Closing the issue for now.

from snowstate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.