• 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!

Legacy GM Multiple choice game, Paths/choices not working

C

Callum Brooks

Guest
Hello I am fairly new to using GML and i'm using Gamemaker 1.4 to make a text adventure game with multiple choices and I have run into an issue that I cant seem to fix. Essentially when I play through the game if I make one choice it will take me down the path of the later choice, sorry for the bad explanation but here is my code.

Create Event:
Code:
//Vars
cur_story = 0;
char = 0;
text_speed = 1;
choices = 2;

if (room==room_0){

story[0] = "You awake in a mysterious dungeon, chained to the wall and surrounded by skeletons, You notice your chains are loose and you manage to break free from them, you see a key and a door";
choice[0, 0] = "Take Key";
choice[0, 1] = "Kick Down Door";
path[0, 0] = 1;
path[0, 1] = 12;

story[1] = "You pick up the key and unlock the dungeons door and you see that you are in a cave, you venture down the dark cave but your path suddenly ends, you look down and see water flowing with a very thin row of rocks above it";
choice[1, 0] = "Jump in and Swim";
choice[1, 1] = "Shimey across rocks";
path[0, 1] = 2;
path[1, 1] = 11;

story[2] = "You jump in a try to swim while you are swimming you start to feel a sharp biting on your leg and the amount of bites keeps increasing, The water was infested with Piranhas that ate you alive";
choice[2, 0] = "Restart";
choice[2, 1] = "Quit";
path[2, 0] = -1;
path[2, 1] = -2;

story[11] = "You try to shimmey across the rocks but you fall and your head hits the rocks on the way down, breaking your neck, you die instantly";
choice[11, 0] = "Restart";
choice[11, 1] = "Quit";
path[11, 0] = -1;
path[11, 1] = -2;

story[12] = "You attempt to kick down the door with very little success, you start to hear scrapping coming from the other side of the door and then it suddenly swings open and a huge dark creature with long claws stares at you before attacking and killing you";
choice[12, 0] = "Restart";
choice[12, 1] = "Quit";
path[12, 0] = -1;
path[12, 1] = -2;
}
Step Event:
Code:
//Input
var input = -1;

for(var i=0; i<choices; i++){
if (keyboard_check_pressed(ord(string(i+1)))){
input = i;
break;
}
}

//set story

var str_len = string_length(story[cur_story]);
if (input!= -1 && char>= str_len){

//move to next story
cur_story = path[cur_story, input];
char = 0;

//Restart
if (cur_story==-1){
cur_story = 0;

//Quit
if (cur_story==-2){
if (room_exists(room_next(room))) room_goto_next();
else room_restart();
}
}
}
Draw Event:
Code:
//properties

var margin = 32;
var width = room_width-margin*2;

var choice_pos = room_height*0.7;

//Draw Story

var text_draw = string_copy(story[cur_story], 1, char);
draw_text_ext(margin, margin, text_draw, -1, width);

//Draw Choices
var str_len = string_length(story[cur_story]);
if (char>=str_len){
var prev_height = 0;
for(var i=0; i<choices; i++){
//text
var text = "("+string(i+1)+") " + choice[cur_story, i];
draw_text_ext(margin, choice_pos + prev_height, text, -1, width);
//Choices Height
prev_height += string_height_ext(text, -1, width)+8;
}
}
else{
char += text_speed;
}

Thank you so much for the help
 

FrostyCat

Redemption Seeker
You have a typo on the second-last line of this section (should be 1, 0):
Code:
story[1] = "You pick up the key and unlock the dungeons door and you see that you are in a cave, you venture down the dark cave but your path suddenly ends, you look down and see water flowing with a very thin row of rocks above it";
choice[1, 0] = "Jump in and Swim";
choice[1, 1] = "Shimey across rocks";
path[0, 1] = 2;
path[1, 1] = 11;
Your restart/quit code is also invalid. Indent it properly and you'll immediately see the problem (should be if (cur_story == -1) { ... } else if (cur_story == -2) { ... }, not if (cur_story == -1) { if (cur_story == -2) { ... } }).
Code:
//Restart
if (cur_story==-1){
cur_story = 0;

//Quit
if (cur_story==-2){
if (room_exists(room_next(room))) room_goto_next();
else room_restart();
}
}
 
Top