talkbox experiments

Posted by mikemacdee on May 12, 2012, 3:02 a.m.

this blog will show what an inept programmer i really am, so i apologize in advance. i'm hoping some of you might have helpful suggestions; if you do, please leave a comment or send me a PM!

this week i added the talkbox element to my contest entry: it's reminiscent of Shadow of the Beast in that you strike up conversation with an npc, type a keyword to ask about, press enter and get the npc's reply (if it has one). i thought this would be more involving and a helluva lot more interesting than the original plan: giving the player an extremely limited list of conversation topics (reply A, reply B, or reply C).

now, i use GM7, and i'm mostly a drag-and-drop programmer, but i know a few advanced tricks and i actually consult the help file BEFORE asking help on the internet. but the way i accomplish certain effects in a game tends to be on the convoluted side, maybe because i'm a bad programmer, or maybe because i just prefer things the hard way. i dunno.

anyway, i'm wondering if other game maker users have successfully made text adventure games. if they have, i'd love to know how to tackle the following two issues:

1) an easier way to group keywords together

the talkbox draws keyboard_string as you type, and when you press enter it goes down a list of valid keywords and checks them against keyboard_string. for example, the player wants to know where to get healing when he's hurt, so he types "healing"; and if the npc knows where the hospital is, he/she gives a valid reply ("there's a hospital on the north side of town!")

but the player might also type heal, healer, cleric, church, rest, or any number of things. the way the game is currently set up, i'd have to make an entry for every single one of those.

if keyboard_string = "heal", set reply to "x";

if keyboard_string = "healer", set reply to "x";

if keyboard_string = "cleric", set reply to "x";

etc, etc…

i've used functions like "choose" before in GM, and i was sure that there'd be something similar that would check everything on a list rather than picking one at random, but i haven't found it.

2) an easier way to implement an "i don't know" reply from an npc

i want the npc to give an "i don't know" reply when keyboard_string doesn't equal ANY keywords on the built-in list, and my current method for accomplishing this is…well, cumbersome. because after checking whether keyboard_string equals x for every valid keyword, i then have to make one looonnng "if not" argument for every valid keyword that ends with "set reply to 'i don't understand'". there HAS to be a better way to do it…

at least being unemployed has ONE benefit when you design indie games as a hobby: you sure get a lot of work done.

——–

apart from the above issues, the project's been shaping nicely and it's really captured my interest. that's what these contests are all about, right?

i just realized i've been developing games for more than ten years. i realized this while going through my old RPG Maker 2000 projects this week. why do i keep doing this to myself…?

i also do a webcomic, and i also have arthritic elbows….so hopefully i'll be able to finish this thing by the deadline while still working on the comic.

EDIT: screenshot

Comments

Toast 12 years ago

It's not really more complicated, it just doesn't help because the whole point is reducing the amount of repetition. The '{reply="x"}' bit is repeated, as '"x"' is the same for each case.

Iasper 12 years ago

Maybe he just used X as filler and wanted to give each case its own text.

Toast 12 years ago

Nope, his problem is grouping all the keywords which mean the same thing. "Heal", "healer" and "cleric" all have similar meanings.

colseed 12 years ago

You could also just not have a break for every case

switch(keyboard_string)
{
case "heal": 
case "healer": 
case "cleric": 
     reply="you should go over there";
     break;
case "blah": 
case "derp": 
     reply = "asdf";
     break;
default: 
     reply="x"; 
     break;
}

works in non-game maker things anyway

Toast 12 years ago

Apart from languages which don't allow switch statements with strings.

Juju 12 years ago

Thanks colseed, that's pretty damn useful.

mikemacdee 12 years ago

wow, didn't expect to get many replies on this. thanks, guys – i'll experiment with this stuff a bit and see how it turns out. that'll help me decide whether to stick with this idea or scrap it in favor of a more traditional dialogue thing.

@JuurianChi: yeah, he kinda does. or an 8-bit elton john.

fenyxofshadows 12 years ago

1) Switch statements

switch keyboard_string
   {
   case cleric:
   case healer:
   case healing:
   case heal:
     //do cleric stuff
     break;
   case warrior:
   case fight:
   case sword:
     //do warrior stuff
     break;
   default:
     //do stuff for anything that isn't explicitly mentioned
     break;
   }

2) This is what the default case is for in the switch statement :)

Yep, not using break for every statement works in GM :D.

Juju 12 years ago

Thanks for repeating colseed.

sirxemic 12 years ago

IIRC you can also do:

switch(keyboard_string)
{
case "heal": 
case "healer": 
case "cleric": 
     reply="you should go over there";
     break;
case "blah": 
case "derp": 
     reply = "asdf";
     break;
default: 
     reply="x"; 
     break;
}