GithubHelp home page GithubHelp logo

HTML5 support is broken about snowstate HOT 3 CLOSED

IsaacTCB avatar IsaacTCB commented on May 30, 2024
HTML5 support is broken

from snowstate.

Comments (3)

sohomsahaun avatar sohomsahaun commented on May 30, 2024 2

This is a bug in GM's HTML5, where variable_struct_get_names returns weird values. The solution is to ignore keys starting with ___struct___, like:

/// @param {struct} state_struct
/// @return {struct} Struct filled with all possible events
__create_events_struct = function(_struct) {
	var _events = {};
	var _arr, _i, _event, _defEvent;
			
	_arr = variable_struct_get_names(_struct);
	_i = 0; repeat(array_length(_arr)) {
		_event = _arr[_i];
		if (string_pos("___struct___", _event) != 1) {
			__assert_event_name_valid(_event);
			__assert_event_available(_event);
			_events[$ _event] = {
				exists: SNOWSTATE_EVENT.DEFINED,
				func: method(__owner, _struct[$ _event])
			};
		}
		++_i;
	}
		
	_arr = variable_struct_get_names(__defaultEvents);
	_i = 0; repeat(array_length(_arr)) {
		_event = _arr[_i];
		if (string_pos("___struct___", _event) != 1) {
			_defEvent = __defaultEvents[$ _event];
			if (!variable_struct_exists(_struct, _event)) {
				_events[$ _event] = {
					exists: _defEvent.exists,
					func: method(__owner, _defEvent.func)
				};
			}
		}
		++_i;
	}
		
	return _events;
};

from snowstate.

theinfamousmrmeow avatar theinfamousmrmeow commented on May 30, 2024

Hey there! Also bumped up against this issue. Is the proposed solution to replace __create_events_struct with the version above?

from snowstate.

sohomsahaun avatar sohomsahaun commented on May 30, 2024

Here is a version of SnowState.gml we use for HTML5. If you search for ___struct___ in the script, you can see the changes.

SnowState.txt

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.