Game Maker Studio arguments question:

edited in Questions and Answers
Hi guys

Just a pretty simple question (I think simple) - is there an upper bound to the number of arguments passed to a script? I got this script:

//argument0: list to add to
//argument1~ : items to add

var n;
for (n = 1; n < argument_count; n += 1)
    {
    ds_list_add(argument0,argument[n]);
    }


And I call it like this, and it works:

data_populate(global.deck_1, "Dudes",1,1,2,2,2,3,3,3,5,5,5,9,9,9);


but if I call it like this, it throws me an error: (Wrong number of arguments to function or script)

data_populate(global.deck_1, "Dudes",1,1,2,2,2,3,3,3,5,5,5,9,9,9,1,2,3,4);


The difference is that the second one has more arguments passed through... So... why? As I wrote the script myself, it shouldn't have a number of arguments defined, so unless there's a limit to arguments passed... Well, I don't know.


Thanks in advance :)

Comments

  • edited
    The way Game Maker is built it can only do a maximum of 16 arguments (if I am not mistaken).

    However there is nothing stopping you giving a list (array) through rather than millions of separate values? (if I am not mistaken)
  • edited
    Lol so I could make an array, give it a bunch of values, and then pass the array through to the ds_list? :)

    Using a list was supposed to make the rest of the manipulation simple (I wanted to use functions like shuffle, insert, etc without having to write them myself)

    So the same argument logic would apply to arrays too, cos I'd still what to do the assignment like in the above way... So I should just break the assignment into multiple calls of the script, right? Sounds easy enough...

    Thanks for the insight :) I couldn't find that info about 16 arguments, where did you see that from?
  • edited
    Trial and error and various forum threads of complaint (and a long time ago I tried to have a many argument function that didnt turn out well! :P)

    The thing is you could have the same code essentially, but making a list first to pass it to a script:
    arr[0] = 1
    arr[1] = 1
    arr[2] = 2
    arr[3] = 2
    arr[4] = 2
    arr[5] = 3
    arr[6] = 3
    arr[7] = 3
    arr[8] = 5
    arr[9] = 5
    arr[10] = 5
    arr[11] = 6
    arr[12] = 9
    arr[13] = 9
    arr[14] = 9
    arr[16] = 1
    arr[17] = 2
    arr[18] = 3
    arr[19] = 4
    
    data_populate(global.deck_1,"Dudes",arr,19);

    and:
    //argument0: list to add to
    //argument1 : array
    //argument2 : array count
    
    var n;
    for (n = 1; n < argument2; n += 1)
    {
        ds_list_add(argument0,argument1[n]);
    }
  • edited
    Wait, what's hard about using ds_list_add? Surely you could just copy-paste the lines and edit the number at the end?

    Why not save the list in a file if you need it to be easily editable and read it into your list at runtime?

    Also, GM used to go up to 10 arguments per script max in older versions. I'd assume that 16 is a pretty logical limit, if you need way more arguments, you probably need to change your angle anyway ;)
  • edited
    For me, editing a column of values is less intuitive... I'm laying out my variables in the editor so that it makes sense to me, so for example:

    data_populate(global.card_master_name,      "Dude", "Guy",  "Soldier",  "Defender", "Berserker", "Bishop",   "Knight",   "Siege Machine",    "Brute");
    data_populate(global.card_master_power,     1,      1,     2,          1,          3,           2,          3,          2,                  4);
    data_populate(global.card_master_toughness, 1,      1,     1,          2,          1,           3,          2,          6,                  2);


    Yes it doesn't have to be that way, but until I learn how to import excel spreadsheets, I'm gonna try do it this way for my own sanity :P And fortunately the extra spaces doesn't break anything in GMS. Yay for small mercies :)

    Now I've figured out how to do this with my method too - I just have to do them with less than 16 arguments at a time, and still with ds_list_add so it all just adds :)

    Thanks guys haha yeah now, is there an easy way to import excel spreadsheets? :P
  • edited
    @Tuism: http://gmc.yoyogames.com/index.php?showtopic=558306 turned up in a search.

    But yeah, export your excel stuff to CSV and then it's easy. Read up on the following functions: file_text_open_read(), file_text_read_string() and string_copy()/string_pos() :)

    I do have to wonder why you're not simply using GM's built-in inheritance to define objects that inherit from a Card object, then you set these different variables in their create events...
  • Thanks, I'll look that up :D to be honest I use google and skim. File handling still confuses the crap out of me cos there are like a million loops. Still noob with those. And most things :p oh and I saw some stuff that worried me about file handling - a few things (can't remember which exactly and I'm sitting in bed ready to doze) had "windows only function", which means they wont work for web player and iOS and whatever else!?

    And I haven't used the inheritance thing before, but The code I posted above is creating a master list of stats I can pull from from instances of card objects, like a library.

    Then when I make instances, I just give them one point of reference (the number corresponding to the order of the list, or the unique name), then it pulls the corresponding stats front the master list at creation of instance.

    Will look into inheritance when I build instances :) (I go pretty slow right now, until I can be sure I understand what I'm doing :p)
  • edited
    "GameMaker: Studio on Steam"?

    Is this cool or not, I can't tell. I think I'm going to port Thief to Studio and upload it for the comp.
  • Haha that's ok, if you can be bothered to transfer everything to the steam version of the same thing, go for it. The only difference are "achievements" that you can get... for stuff like having games crash 50 times, or getting 10 errors or somesuch silly things :)
  • edited
    Well, I swapped to GM:S through steam to solve updating issues, havent had any so far. Also, it meant I didnt have to fiddle with Yoyogames support to install on my PC, so win-win for me.
  • Yeah, that's def the major draw for me too... Is there a way that I can move my existing license to the Steam version?
  • edited
    @dislekcia use the resend licence on the GM website and they will mail you a licence with a steam key.

    Edit for clarity.

    On this page http://www.yoyogames.com/my_licences enter your email into the recover licences. They will send you an email with the regular licence, as well as a Steam key.
    Thanked by 1edg3
  • Updating issues is a real win, actually. I've gotten used to doing it all myself through a download manager, but yeah eventually automating it through Steam would be good.

    Plus I get to chase the "100 compile errors" achievement. Woohoo :)
  • edited
    What does "Unlimited Resources" mean for GameMaker: Studio Standard compared to free?

    Nevermind found it:
    Limitations
    Rooms 5
    Sprites 20
    Sounds 10
    Objects 15
    Backgrounds 5
    Timelines 5
    Scripts 10
    Fonts 5
    Paths 10
    Included files 5

    Does anyone know if GameMaker: Studio has better collections yet or do we still have to use ds_list, ds_grid and ds_map?
  • edited
    they've had stacks and queue's for a while and priority lists since 8, but no I haven't seen any new collections
    will confirm for you though.
    edit:
    checked the help file now (and grabbed an achievement) and yes its just those six.
  • edited
    @aodendaal: Still ds_list and ds_grid stuff, but I've been thinking of making an extension to give all the types from .NET
  • And does anyone know if ds_list and them are available in Free now? (Used to be professional only).

    I see particles seem to be available in Free now, I wonder if blending and draw_sprite_ext is as well
  • @aodendaal blending is pro only. Also I didn't realize that particles are in free now. I need to dl the free and see if there is anything that is pro-only for particles.
Sign In or Register to comment.