struct

  1. O

    SOLVED struct order out of whack and stepping through commented lines

    I'm still fairly new to structs, but I'm coming across a couple things that are frustrating and confusing, and I'm wondering where I'm doing something wrong. Primary problem: My struct is not ordered in the same order I created it, reducing readability during verification/debugging. Secondary...
  2. N

    GMS 2.3+ Trouble with saving ds_lists and arrays to a struct based (json) saving system

    So I have done a video explaining things but the most important things are in the post itself. In the video I show the content of the json file though Hi, I have multiple problems using a save and loading system using json. My Saving code looks like this function SaveTest(){ if...
  3. Joe_La_Bricole

    Asign funtions in structs

    Hello ! I would like to declare a function in a script and then assign this funtion to a variable in a struct to call that function. Is that possible and if yes how ? Here is a little example : function message() { show_debug_message("this is a message"); } function struct_with_message()...
  4. W

    Can I add a constructor function to a extension?

    Basically title. I am new to coding extensions and am having trouble with adding a function to an extension which is a constructor. The only thing close to this I have found on the matter is this thread...
  5. S

    GMS 2.3+ Trying to get a struct to a variable from a .txt or .json file

    Hey all, I want to use a txt or json file containing a struct with all the dialogue for the game (so I could swap in translations etc) but with all my attempts at searching how to do this correctly I still haven't managed to. If I have a .txt or .json file containing: { "teststring": "this is a...
  6. samspade

    GMS 2.3+ Struct Based State Machines

    I'm working on creating a struct based state machine system. My primary goals are for it to be: Simple to use Handle entering and exiting a state separately from running a state Use structs be flexible and expandable My current set up seems to be working well, but I haven't tried to do this...
  7. Slyddar

    Menus with Submenus #3 - Mouse Support

    GM Version: Studio 2.3+ Target Platform: Windows Download: n/a Links: video below Summary: Following on from my previous 2 menu tutorials, here's a new tutorial showing how to use structs and constructors to add mouse support to your menu/submenu. It allows you to easily navigate, and change...
  8. ConstaChymic

    GMS 2.3+ Can you delete a struct in one of its own functions?

    I've tried something like this: static free = function () { delete self; } However this always makes GM freak the hell out and fail to compile with the error Cannot set a constant ("@@This@@") to a value, even though I feel like it should work? Unless I'm being a moron and self doesn't work...
  9. gnysek

    GMS 2.3+ Saving and loading structs with constructor to/from string?

    With 2.3+, there's easy option to save/load struct, using json_stringify() and json_parse(). That however saves only normal struct, not those created using new keyword from constructor functions (they will be converted to normal struct too), so I can't later use instanceof on them. I was...
  10. P

    Converting Javascript array to GML

    Hi, I'm going to try to convert an existing Javascript game to GM2, so far it looks pretty straight forward to convert but just wanted to ask anyone with experience about how I can use structs to replace a huge literal array I have. At the moment it looks like this: var array=[...
  11. Hieran_Del8

    GMS 2.3+ [Solved] Can extensions written in GML return GML struct's?

    Let's say I have a struct defined in GML as: function special_compiler(expression) constructor { compilerError = undefined; ... static run = function(params) {...} static compile = function(expression) {...} if (!is_undefined(expression) && expression != "")...
  12. Hieran_Del8

    GML [Solved] Will two struct's that reference each other ever be garbage collected?

    I'm designing a tree data structure, but started realizing each node kept a reference to adjacent nodes. function tree_node() constructor { parent = undefined; nextSibling = undefined; previousSibling = undefined; children = []; static append = function(node) {...
  13. Moon Goat

    SOLVED Can't seem to get a constructor to work

    I'm trying my hand at using constructor functions, but I can't seem to get them to work. I have a single constructor function that looks like this: /// @function thing(_x, _y); /// @param {real} _x Creation point x /// @param {real} _y Creation point y thing = function( _x...
  14. Hieran_Del8

    GML [Solved] Is there a way to refer to the 'this' of a struct?

    EDIT: My apologies, I posted in the wrong forum. I Meant this for "Programming". I'm creating a tree structure, and wanted to set the leaf nodes to point to their parent, using something akin to the this keyword. As of now, I had written: function _tree_node(_data) constructor { parent =...
  15. Kezarus

    SOLVED Is delete operator really required?

    I'm cofused about the documentation of Structs. On the segment that reads: "When a struct is no longer required it can be removed from memory using the delete operator, which flags the struct as being able to be garbage collected. This is not strictly required as the garbage collector may do...
  16. samspade

    GMS 2.3+ Bug or not with struct inheritance?

    I think there is a problem with method variable constructors and inheritance, but I'm not sure if this is a bug, intended behavior, or I've made a mistake in my code. The following will work whether it is put in a script asset or an object (so long as you respect scope if its in an object)...
  17. samspade

    GMS 2.3+ Intended or Undocumented Behavior?

    The manual says that: "Structs created [with a constructor] will also support single level inheritance, ie: you can create a struct using a function that inherits the data from another constructor function." This would seem to imply that a struct cannot inherit from a struct that inherits from...
  18. samspade

    GMS 2.3+ Various Types of Alarms and Other Things

    GM Version: All (except for System Alarms, which is 2.3 only) Target Platform: All Download: Struct Alarms Github Repo Links: YouTube Playlist Summary: A GML tutorial series on various ways to implement alarms in GMS 2.3 from using built-in alarms to creating alarms with structs, a discussion...
  19. gkri

    GMS 2.3+ How to change the struct values of a sequence, dynamically at runtime?

    I tried to access the struct of a premade sequence from asset browser. I wanted to change the keyframe of a specific channel of a track. To be more specific I wanted to change the mouth of a character from neutral to smile. After some looping and show_debug_message in create event, I found the...
  20. samspade

    GMS 2.3+ Is there any reason to create setters/getters with structs?

    Just a question for people's opinions. Given that we can't make private struct variables, is there any reason to create setters/getters? For example, say you have the following struct: function alarm_struct(_default_timer, _func) constructor { timer = 0; active = false...
Top