GMStruct - Struct generation for GameMaker studio

Discussion in 'Game Design, Development And Publishing' started by GMWolf, Jul 2, 2017.

  1. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    GMStruct
    Struct generation for GameMaker Studio
    Early alpha build

    download on itch.io
    Source on GitHub

    Blog post 1: GMStruct - extending GML with code generators
    Blog post 2: GMStruct Inheritance and Types

    I need testers!
    The project is still in very early development, and there is sure to be a lot of bugs present!
    If you make use of this in a project, or tinker around with it, Please leave feedback both on stability and features! Thanks!

    What is a Structure?
    Simply put, a structure is a collection of named values (called attributes), under a single name.
    An example would be wanting to store information on a car. You would want to store a model, colour, age.
    Structures allow you to bundle these named values into a single variable, from which you could later retrieve the age, colour, etc.

    What is GMStruct?
    GMStruct is a language and a tool to introduce Structures to GameMaker studio 2.
    The language (gms) allows you to define structures and their attributes in a clear and practical manner.
    The tool translates that definition language into usable GML code.

    How does it work?
    The GMS language is fairly simple and quick to learn. After writing you GMS in your editor of choice, The tool can be used to generate the GML into any directory. This will generate a number of gml files, ready to be draged into your projects scripts folder.
    These will include scripts to instanciate structures, Get and Set values, as well as checking structure types.

    The GMS languages.
    The basic syntax for a structure is a folows:

    Code:
    structure foo {
        name,
        age
    }
    This will define a structures name foo, with attributes name and age.

    A structure can inherit attributes from another. This means that it will have all the same attributes as its parent structure, as well as the one it defines.
    This is done with the following syntax:
    Code:
    structure bar : foo {
        colour
    }
    
    This defines a structure named bar, with foo for parent, and a the attribute colour.
    This structure will therefore have the attributes name, age and colour.
    The type of the bar structure will also be of both type foo, and bar, allowing you to call 'foo' functions on a bar structure.

    You can set default values for attributes, removing the need to initialise them when instantiating the structure:
    Code:
    structure tile {
        xPos,
        yPos,
        colour = c_green
    }
    This will define a structure as before. But the colour attribute has the default value 'c_green'.
    Using generated source
    The generated code is also very straight forward to use. For every structure, there will be a instantiation script, and a single script for each of its attribute to get or set its value.
    The generated scripts will also include functions to get the type of a given attribute, or test the type of a structure.

    consider the following source:
    Code:
    structure foo {
         size,
         age
    }
    
    structure bar : foo {
        colour
    }
    The generated code would be able to be used in the following manner:
    Code:
    var a_foo = new_foo(42, 3);
    //This creates a new foo structure, with size 42 and age 3. it is assigned to the variable a_foo
    var size = foo_size(a_foo);
    //This retrieves the size attribute of the foo structure stored in the variable a_foo.
    foo_size(a_foo, 12);
     //This sets the the size attribute of a_foo to 12. Notice that the setter script isthe same as the getter, but with one more argument.
    
    var b = new_bar(12, 3, c_green);
    //this create a new bar structure with size 12, age 3 and colour c_green.
    
    var size   = bar_size(b);
    var size2 = foo_size(b);
    //The above are two equally valid ways of retrieving the size of a bar structure, as a bar structure is also a foo structure.
    
    if is_foo(b) {
       //do something
    }
    //This will check if the structure in b is of type foo. This will return true as b is of type bar, which is also foo.
    
    var t = get_type(a_foo);
    //The above will find the type of structure a_foo (which is foo).
    
    if is_a(b, structs.foo) {
       //do something
    }
    
    //Another way of checking type. The output of get_type can be used as the type to check against.
    
    Note, is_a is not a simply checking if the types matches, as it will take inheritance into account as well.
    What's Next?
    There is still a lot that can be done. Introducing name spaces, functions and so on to make GMStruct as versatile as possible. THe ultimate goal is to be able to develop intire subsystems in GMStruct to be seamlessly imported in GMStudio 2.

    For this, I will need the help of the community. Helping with testing at first, but eventually introducing new features, UI, plugins and so on.
    This is why i have made the project source open to anyone on github (link above), so that anyone can experiment with the system.

    Functions: this is a tricky one. Require static analysis and everything. But progress is being made steadily! (Technically they work, but you can't access other struct attributes etc yet. Working on it)
     
    Last edited: Aug 20, 2017
  2. Storyteller

    Storyteller Member

    Joined:
    Jul 19, 2016
    Posts:
    251
    why use this instead of a ds_map?
     
    SnotWaffle Studios likes this.
  3. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Much faster. And more memory efficient.
    Safer too as the attribute names can be checked at compile time. (Maps with strings would be 'unsafe' in the sense thatb you could misspell your attribute name and nothing would complain).

    More powerful as you can check the type of your structs, with inheritance (incredibly useful for polymorphism).
    Maps will not allow you to do that directly.

    Garbage collected: you don't need to explicitly free your structures, GameMaler will handle the memory for you.

    Correctness: it's more 'correct' to use a Struct than a map in many cases. Not important to everyone but it is to me.

    Eventually will include many more features like type checking, polymorphic functions (making them closer to classes (but not quite)) which is an increasingly powerful tool.

    The advantages are much clearer if you are used to languages that have structs or even classes.
     
    rIKmAN and Genetix like this.
  4. Storyteller

    Storyteller Member

    Joined:
    Jul 19, 2016
    Posts:
    251
    I have, I was asking the question so you would explain everything you just said.
     
    Yal and GMWolf like this.
  5. gloomytoad

    gloomytoad Member

    Joined:
    Jun 10, 2017
    Posts:
    24
    Yes!! I will be checking out the open source! Awesome. But watch, GM is going to introduce lightweight objects or some type of Struct system tomorrow.... That stuff always happens to me.
     
    Kuro and GMWolf like this.
  6. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Haha yeah. It's always that way xD
     
  7. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    UPDATE TIME!

    NameSpaces are now a thing!
    simply wrap your structs in namespaces to add a prefix to them:
    Code:
    struct foo {
        name,
        colour
    }
    
    namespace net {
        struct foo {
            size,
            age
        }
     
        struct bar {
            x, y
        }
    }
    
    This will generate structures named foo, net_foo and net_bar.
    This also allows a . notation. so you could have 'gmwolf.tiles' as a namesace, and it will be name gmwolf_tiles in GML.
    Nesting namespaces is also possible. But this needs some further testing.
    This allows you to ensure your structs wont interfere with already defined structs in the future.
    At the moments this is not too useful. But as soon as the runtime catches up, and functions are a thing, this will prove very powerful.
    Because all the code is generated (And will eventually be generated per project, rather than per struct file), There will be a run time script to choose what namespace to use, eliminating the need for the prefixes in GML.
    This will introduce some overhead, but it should be minimal.

    The update should be live on itch.io. And github pretty much always has the latest version.

    CALL TO ARMS!
    I really need some testing feedback from you guys. Especially as I start adding more features, there will be an endless number of cases to test. So your help is greatly appreciated.
    I'm also planning a major UI overhaul (Hard to call the UI a UI in right now). So keep an eye out for that!
    As always, If you would like to contribute: Hit me up, or make a branch of the project on github!
     
    Last edited: Jul 6, 2017
    Kuro likes this.
  8. Kuro

    Kuro Guest

    He's the hero GML deserves.
     
    Kaemalux, Simon Gust and GMWolf like this.
  9. Kaemalux

    Kaemalux Guest

    I am a newbie but such initiatives amaze me! Great job mate!
     
    GMWolf likes this.
  10. Sammi3

    Sammi3 Member

    Joined:
    Jun 20, 2016
    Posts:
    163
    global._struct_flag is never initialised or added to when a new struct is made. Also, this is incompatible with GMS 1.4 as when you create an array you create it in a method unsupported by GMS 1.4. Every new function it generates requires an argument0. I don't see why its asking for one since all my values are defaulted.
    Lastly, when I try to default an attribute to -1, the gml it returns gets the default value as 1.

    I like the project though it's not ready to integrate with a project yet.
     
  11. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    It actually gets initialized using gml_pragma("global",...). This parts is all good.
    The flags are global information to store the inheritance tree. Its a simple flag system to quickly check if a type is a subtype of another.
    Yes i'm aware. It should not be too difficult to add an option to generate 1.x compatible scripts. But if i do add support, i will have to drop support for it eventually as i integrate this closer with the gms2 file structure.
    However when that time comes, anyone could put the work in to continue supporting 1.x
    That is most definitely a bug! I will have to investigate! thanks for reporting it!
    Yeah, I know why that is: I forgot to include +/- in the lexicon. should be an easy fix.

    Definitely not ready for a proper project! This is a pretty big endeavour for me, and so I really appreciate the feedback! thanks!
     
  12. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    I am not able to reproduce this issue.
    Could you post a sample where this happens?
    thanks.

    [Update!]
    Small update: Types have now been added with runtime checking. Still needs testing before I publish the build, but the update is already on github.
     
    Last edited: Jul 19, 2017
  13. Wraithious

    Wraithious Member

    Joined:
    Jun 24, 2016
    Posts:
    1,166
    is_a.gml
    Code:
    ///Generated by GMStruct
    
    ///@param struct the struct to check
    ///@param type the type to check
    
    if (!is_array(argument0) || array_length_1d(argument0) == 0)
         return false;
    var i = argument0[0];
    var f = global._struct_flag[i];
    return f[argument1 div 32] & 1<<(argument1 % 32);
    get_type.gml
    Code:
    ///Generated by GMStruct
    
    ///@param struct the struct to find the type of
    
    return argument0[0]
    _structs.gml
    Code:
    ///Generated by GMStruct
    ///@desc
    
    gml_pragma("global", "_structs()");
    enum structs {
    }
    
    //Make use of the chromasomes and their genes
    stress=0;hp=maxhp;
    if(challenged[1]=0){for(var j=0;j<defaultGeneLength;j+=1){ar2[j]=Individual(3,2,bestone,j,rand);}}else{//get genes to use as chromosome1
    if(challenged[1]=1){var fbest=Population(2,2,myPop,0,rand-1);for(var j=0;j<defaultGeneLength;j+=1){ar2[j]=Individual(3,2,fbest,j,rand-1);}}}
    for(var k=0;k<defaultGeneLength;k+=1){ar3[k]=Individual(3,2,bestone,k,rand);stress += ar3[k]*0.00001;}//get genes to use as chromosome2
    //Body attributes
    var chosen=(ar2[40]+ar2[41]+ar2[42]+ar2[43]);if chosen<0 chosen=0;
    var subchosen=(ar3[28]+ar3[29]+ar3[30]+ar3[31])-1;if subchosen<0 subchosen=0;
    locamotion[0]=ar2[36];locamotion[1]=ar2[37];locamotion[2]=ar2[38];locamotion[3]=ar2[39];if ar2[36]+ar2[37]+ar2[38]+ar2[39]=0 locamotion[2]=1;//borrows, swims, terrestrial, flys
    var covchosen=(ar3[20]+ar3[21]+ar3[22]+ar3[23])-1;if covchosen<0 covchosen=0;
    var colchosen=(ar2[0]+ar2[1]+ar2[2]+ar2[3])*0.25;
    var widthchosen=1;
    var sizechosen=ar2[4]+ar2[5]+ar2[6]+ar2[7];
    if(sizechosen=0){sizechosen =0.25+random(0.15);widthchosen =0.25+random(0.15);sizex=widthchosen;tskx=widthchosen;sizey=sizechosen;tsky=sizechosen;}//4 genes chromosome1 genes 4-7
    if(sizechosen=1){sizechosen =0.4+random(0.4);widthchosen =0.4+random(0.4);sizex=widthchosen;tskx=widthchosen;sizey=sizechosen;tsky=sizechosen;}
    if(sizechosen=2){sizechosen =0.8+random(0.4);widthchosen =0.8+random(0.4);sizex=widthchosen;tskx=widthchosen;sizey=sizechosen;tsky=sizechosen;}
    if(sizechosen=3){sizechosen =1.2+random(0.4);widthchosen =0.8+random(0.4);sizex=widthchosen;tskx=widthchosen;sizey=sizechosen;tsky=sizechosen;}
    if(sizechosen=4){sizechosen =1.6+random(0.4);widthchosen =0.8+random(0.4);sizex=widthchosen;tskx=widthchosen;sizey=sizechosen;tsky=sizechosen;}
    var speedchosen=ar2[8]+ar2[9]+ar2[10]+ar2[11];
    if(speedchosen=0){gov=1+random(2.2);maxgov=gov;}
    if(speedchosen=1){gov=3.2+random(3.2);maxgov=gov;}
    if(speedchosen=2){gov=6.4+random(3.2);maxgov=gov;}
    if(speedchosen=3){gov=9.6+random(3.2);maxgov=gov;}
    if(speedchosen=4){gov=12.8+random(3.2);maxgov=gov;}
    sprite_index=ar1[covchosen];//4 genes chromosome2 genes 20-23 - Clothing
    if ar2[3]=0 image_alpha= 0.5+random(0.5);if ar2[3]=1 image_alpha=1;//1 gene chromosome1 gene 3
    sat1=(round(random(1000))*0.001)*colchosen;//4 genes chromosome1 genes 0-3
    if(mutated=1)
    {sis=4*chosen;image_single=4*chosen;//4 genes chromosome1 genes 40-43 - Body type
    if chosen=0 global.texts2="evolved to Quadraped!";
    if chosen=1 global.texts2="evolved to Intelligent quadraped!";
    if chosen=2 global.texts2="evolved to Intelligent biped!";
    if chosen=3 && subchosen=0 global.texts2="evolved to Alien!";
    if chosen=3 && subchosen=1 global.texts2="evolved to Intelligent Alien!";
    if chosen=3 && subchosen=2 global.texts2="evolved to Supra inteligent Alien!";
    if chosen=3 && subchosen=3 global.texts2="evolved to Pure energy lifeform!";
    }
    if mutated=0 global.texts2="not undergone any major changes";
    speakIT(global.orgname+" has "+global.texts2);
    if(instance_exists(menu)){menu.alarm[2]=150;}
    speed=1;comp=1;alarm[2]=2;
    if(instance_exists(kin)){with(kin){instance_destroy();}}
    global.ic=0;repeat(myPop){with(instance_create(round(random(864)),round(random(610)),kin)){myinst=global.ic;global.ic+=1;dGeneL2=Organism.defaultGeneLength;}}
    This is really cool, and I hear you about the heavy use of arrays, my Chromosome z project heavily relies on 1d 2d and 3d arrays, and accessing all parts of them at various times which is difficult, time consuming and sometimes problematic, with your system I could easily define an organism that has a number of chromosomes that have a number of genes in it, and it would be great at things like finding the fittest individual in the population, evolving/mutating/crossing over the entire population and such, I only use gms 1 early access tho so I can't use it yet to test it, or is there a way? I exported my metabolism script (as a .gml) and opened it by selecting "all files" and it did generate 3 scripts, so I'm messing with them now haha
     
    Last edited: Jul 25, 2017
    GMWolf likes this.
  14. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Blog!!!
    I started a blog and my first entry is on the basics of GMStruct.
    Check it out! http://www.fbridault.net/

    I will be posting detailed updates on the blog from now on, with just short updates on here.



    I may not have mentioned it, but the struct files should have the .gms extension.

    As for using in GMS1.x, I think you just have to change the new_* scripts, and have the array be created index by index.
    I may add some quick support for it tomorrow or something, but don't expect it to be stable or well maintained. I'm focusing on GMS2 mainly.
     
    Wraithious likes this.
  15. Wraithious

    Wraithious Member

    Joined:
    Jun 24, 2016
    Posts:
    1,166
    yea I hear you, gms1x is going away soon so at some point I will have to give in haha in the meantime I will definitely keep playing with this, nice work! I edited my last post so you could see what I initially got. Nice blog too I checked it out earlier
     
  16. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Ah ok.
    Well, those are the three 'basic' scripts that get generated.
    You have to give a gmstruct file to gmstruct. A gml file will not work (it wont parse it).
    Try some of the examples i showed here / on the blog instead.
     
  17. Wraithious

    Wraithious Member

    Joined:
    Jun 24, 2016
    Posts:
    1,166
    Ok cool, do you know a way I can convert my scripts to gms2? could I use notepad++ and change the file extension or something similar?
     
  18. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    The extension for gms2 and gms1 is the same.
    But you seem confused:
    The tool takes in a language i call GMS, and generates GML.
    The code you must provide is not GML, but GMS (the language i describe above).
    The tool then converts it to GML, ready to be used in a project.
    The trouble is that the generated code only works in GMS2.
    If you want to use it in GMS1.x, you have to change the generated code. Namely, the generated new_* scripts, such that the arrays are not deffined inline, but are defined the regular 1.x way.
     
    Wraithious likes this.
  19. Wraithious

    Wraithious Member

    Joined:
    Jun 24, 2016
    Posts:
    1,166
    ahh yes I see, I've been reading up on your blog some more, I'll try making something in those scripts and see what I get not gonna try to use them in gms1 but I want to learn how they work and see what the output looks like, thanks!
     
    GMWolf likes this.
  20. Wraithious

    Wraithious Member

    Joined:
    Jun 24, 2016
    Posts:
    1,166
    ok, so just to see if I'm on track now, I made up an example on how I would want to use your system to define, create, and access components in a population, does this seem correct to you?
    //define
    Code:
    struct Organism {
    real age,
    string species,
    real individual,
    real chromosome,
    real chromosome2,
    string gene,
    string gene2,
    }
    
    //create
    Code:
    var Hennalyn;
    global.sequence1="";
    global.sequence2="";
    var gene=0;
    var gene2=0;
    var type = choose("fin","feather","fur","mamal");
    for(i=0;i<population;i+=1;) {
            for (var n = 0; n < defaultGeneLength; n+=1;) {
            gene = round(random(1));
                global.sequence1=string_insert(string(gene),global.sequence1,n+1);
            gene2 = round(random(1));
                global.sequence2=string_insert(string(gene2),global.sequence2,n+1);
            }
            Hennalyn[i] = new_Organism(i, type, i, 0, 1, global.sequence1, global.sequence2);
        }
    
    //access
    Code:
    if(mutate=1) {
    global.sequence1="";
    var gene=0;
    for (var n = 0; n < defaultGeneLength; n+=1;) {
            gene = round(random(1));
                global.sequence1=string_insert(string(gene),global.sequence1,n+1);
            }
    Organism_Hennalyn[43]_gene(Hennalyn[43], global.sequence1);
    }
     
    Last edited: Jul 25, 2017
  21. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Seems correct at first glance.
    Just as a note, i forgot to upload the version with types to itch.io. So the current version may act a little wierd with types.
    I will fix that today.
     
    Wraithious likes this.
  22. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    So, can I create a struct with a array? Predefined size will do just fine!

    Code:
    struct point {
      real x, real y
      }
    
    struct polygon {
      point vertex[8],
      color
      }
    
    If so, how?

    More questions to follow!
     
  23. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Tyoed Arrays are unfortunately not yet supported. (But soon!).
    You could just not give the attribute a type (or give it the array type) and assign an array to it though. That should work.
    (The trouble with arrays is creating a generic type system)

    The point struct should work just fine though.
     
  24. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    Jesus, 6 mintue response time! Every time I run into you on the forums you continue to impress. Also from this I learned that you and GMWolf are the same, love your tutorials!

    I will kludge something and keep an eye on this in the mean time.
     
  25. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Haha I'm pretty much always on the GMC when I'm not sleeping!

    Let me know how it goes. I would really appreciate the feedback!
     
  26. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    Feature Request: Comments
    I type them as I go because I have to walk away from my PC a lot.

    ANTLR v4.7
    Code:
    COMMENT : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
            | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
            ;
    
     
  27. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Yep that's probably a good idea! Completely slipped my mind!
    Since its such a simple feature (thanks for the code btw) I'll probably implement it before thhe next version!
     
  28. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    More feature requests
    Save/Load functionality. (good luck!)
    by-ref and by-val copy to a new struct
    A system/process for updating when a developer rebuilds their structs.... (really big good luck!)

    Thank you! And good nite.
     
  29. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Save/load of structs? I have actully been thinking of implementing both a serialize, amd a json encode system for structs (that would be auto gened).

    Structs are handled by ref by default. Perhaps adding a cpy() method would be nice? (Just makes a new copy of the struct).

    Im thinking of making the app hook into your GM project to be ble to do that painlessly. A simple UI where you choose the project, and then add a number of files. You could then modify the files in the program, or modify them externally.
    There would be a genert, or update button to compile and push the changes to the project.
     
    GeminiEngine likes this.
  30. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
  31. Edmanbosch

    Edmanbosch Member

    Joined:
    Jan 6, 2017
    Posts:
    180
    Seems like a pretty cool tool, although it's annoying how I have to re-import all the .gml files every time I make a change, and then reorganize them into all my sections on import.
     
  32. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    I have something planned for that.
    I wanted to get functions out of the way first. But it's so much work i think I'll get to working on a better UI first :)
     
    Edmanbosch likes this.
  33. Edmanbosch

    Edmanbosch Member

    Joined:
    Jan 6, 2017
    Posts:
    180
    Cool. I think it would also be nice if you made some kind of text editor with syntax highlighting and auto-complete for GMStruct.
     
  34. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    What ill do first is make a UI that will auto import scripts into a project.
    But for the editor, Its probably better if users stick to using something like notepad ++
     
  35. Edmanbosch

    Edmanbosch Member

    Joined:
    Jan 6, 2017
    Posts:
    180
    Alright, then what about adding it as an extra language for existing editors like Notepad++ or VS Code?
     
  36. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Yeah. That's my plan right now.
     
    Edmanbosch likes this.
  37. Edmanbosch

    Edmanbosch Member

    Joined:
    Jan 6, 2017
    Posts:
    180
    Great, can't wait to see what else you do with this neat tool.
     
    GMWolf likes this.
  38. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    any closer to arrays?
    Code:
    struct point {
      real x, real y
      }
    
    struct polygon {
      point vertex[8],
      color
      }
    
    I have been hand writing something up, but tools are cooler!
     
  39. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Arrays should already work, like any other variable.
    They just are not generic (yet).

    So something lime this:

    Code:
    struct polygon {
        array points,
        color
     }
    
    Code:
    ///in GML
    polygon_points(p, [vertex1, vertex2...]);
    
    var points = polygon_points(p);
    
    Perhaps with array types, I should add a function to access a particular element?
     
  40. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    How are booleans declared?

    This example GMStruct code does not work.
    Code:
    struct foo {
      boolean thing
    }
    
    And how do I access it inCLI mode? I figured just open up Command Prompt and run it through there but I got no error message.[/code]
     
    Last edited: Sep 5, 2017
  41. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Thanks for the report. Will have to investigate! If get cli to work, ehat error message do you get? Dos it wok if you change boolean to real?
    Are there any other structs defined in the same file?


    And i dont remember of the top of my head, but you have to supply the .gms file to read, and a directory to write to.
    Ill write up a small example tomorow.
     
    GeminiEngine likes this.
  42. GeminiEngine

    GeminiEngine Member

    Joined:
    Jun 9, 2017
    Posts:
    23
    Everything I have tried works, even inheritance. Except when I add in a bool, it breaks.
     
  43. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Ok thanks very much for the info.
    I think i know where to look!

    Edit: I am so stupid I simply forgot to add it to a switch.
    Will fix it as soon as I get home, and upload the patch to itch.io.
     
    Last edited: Sep 6, 2017
  44. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    Booleans should now work fine.
    Also added CLI options back in (I broken them a while back..).

    Usage is:
    Code:
    java -jar GMStructGUI.jar -cli <source> <dest>
    
    where <source> is the source GMS file, and <dest> is the destination directory for generated GML0
    if you do not include -cli, then the normal gui will open.
     
    GeminiEngine likes this.
  45. xDGameStudios

    xDGameStudios Member

    Joined:
    Sep 15, 2016
    Posts:
    579
    Is this project still alive ;) it has a lot of potential! Good work!!
     
  46. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,390
    I have had to put the project on hold, because of university.
    I decided to make it open source so people could contribute ideas and code, but that doesn't seem to be happening :\

    But if you do find bugs/etc I will go in and fix them. it just new features that I am putting on hold for now.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice