• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

[Solved] ds_list_shuffle argument 1 incorrect type (2) expecting a Number (YYGI32)

C

Christian Krupa

Guest
Hi all,

my first post here, stuck on a strange error that I can't google my way out of :)

randomize() // make random events truly random

deck = global.ingredient_deck; //assign the set deck to the variable deck
decksize = array_height_2d(deck); // get the size of the starting set deck
shuffle_deck=ds_list_create(); // create a list to hold the deck in order to shuffle it

// fill the list with values to represent the indexes in the set deck
for (i=0;i<decksize;i++){

shuffle_deck = i
show_debug_message(shuffle_deck);
}

// shuffle that list
ds_list_shuffle(shuffle_deck);




spice_bag = ds_stack_create(); // create a stack to load the shuffled values into

for (i=0;i<decksize;i++){

spice_bag = shuffle_deck;
}


I'm getting an error on the ds_list_shuffle function as follows

ds_list_shuffle argument 1 incorrect type (2) expecting a Number (YYGI32)
at gml_Object_obj_bag_CreateEvent_1 (line 15) - ds_list_shuffle(shuffle_deck);


The rest of the code seems to work and even transfers the ds_list into the ds_stack,

sorry if this is a silly newb thing,

thanks


Chris
 
H

Homunculus

Guest
By using shuffle_deck = i you are replacing the list with a numeric value, not inserting i into the list. It should be ds_list_add(shuffle_deck,i) . Same thing with the stack, but there you need to the the value out of the list too, no assign the list directly!

Look at how it all works in the manual
 
C

Christian Krupa

Guest
Thanks Catan, was just coming to this conclusion, I had been assuming I could handle lists and other ds as simple arrays, back to the manual!

cheers

Chris
 
Top