Game Maker Studio arguments question:
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:
And I call it like this, and it works:
but if I call it like this, it throws me an error: (Wrong number of arguments to function or script)
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 :)
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
However there is nothing stopping you giving a list (array) through rather than millions of separate values? (if I am not mistaken)
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?
The thing is you could have the same code essentially, but making a list first to pass it to a script:
and:
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 ;)
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
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...
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)
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.
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.
Plus I get to chase the "100 compile errors" achievement. Woohoo :)
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?
will confirm for you though.
edit:
checked the help file now (and grabbed an achievement) and yes its just those six.
I see particles seem to be available in Free now, I wonder if blending and draw_sprite_ext is as well