1

Game: My game is a simple game that takes a list of words from a txt file and puts them onto a grid. Then the words are shuffled (there are 9 words displayed on a 3*3 grid and one is replaced by the spare word not used), then the user has to guess what the word that has been replaced was and what the word that replaced it was too. If the user is correct they then move onto a harder level which is a 4*4 grid.

Issue: I have been trying to verify inputs from a user by checking the words in the list by the position of the word that's been shuffled, so I am trying to check which word is in the tenth position of the list as that is the word that has been replaced.

Code Scripts: "Global_Variables" -

> globalvar WordCount; globalvar WordColumn; globalvar WordRow;
> globalvar WordList; globalvar GridList; globalvar LineGap; globalvar
> WildCard; globalvar BoxSize; globalvar BoxIndent; globalvar BoxHeader;
> globalvar TimerIndent;

"Readfile" -

> filop = file_text_open_read(working_directory + "Words.txt");
> wordgridlist = ds_list_create(); gridcreate = ds_list_create();
> while(!file_text_eof(filop)){
>     line = string_upper(file_text_readln(filop));
>     ds_list_add(wordgridlist, line);
>     } file_text_close(filop);    wordgridlistshuffled =         
> ds_list_shuffle(wordgridlist)   "Output" - draw_set_colour(c_red)
> draw_set_font(Text_Font) Text_Grid = 0 for (X=0; X<3; X+=1){
>     for  (Y=0; Y<3; Y+=1){
>         draw_text((X*710)+250,    
> (Y*244)+300,ds_list_find_value(wordgridlist,Text_Grid));
>         Text_Grid +=1
>         
>         }
>     }

"Word_Question" -

> WordChangedEasy = get_string("What word changed?", "");
> WordChangedEasyAnswer = ds_list_shuffle(10); WordReplacedEasy =
> get_string("What word has been replaced?", "");

1 Answers1

1

I've sourced this from the GameMaker: User Manual.

ds_list_find_value

Finds the value held at a given position in the list. Syntax: ds_list_find_value(id, pos);

id: The id of the list to use.

pos: The position to look at, where 0 corresponds to the very beginning of the list and the final position is ds_list_size(id)-1.

You should use ds_list_find_value(wordgridlist,9) to find the tenth value.

J. Malcolm
  • 62
  • 1
  • 5