Log in
Search
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: https://gameml.forumotion.com/GameML-File-Sharing-h3.htmPlease add only games.Make your computer talk:
2 posters
:: Game Making :: Game Maker Help :: Code Database
Page 1 of 1
Make your computer talk:
This script will make your computer "say" whatever you want it to. There are two scripts for this: comp_talk() and comp_talk_ext().
Just push "Open" when you click on the link to the script to open in the browser.
comp_talk(str) This function has one argument: "str". The "str" is the string of text that you want the computer to say.
comp_talk_ext(str,fname,talk) This function has two new arguments ("fname" and "talk"). The "fname" is the path in which you want the .vbs file (the file that makes your computer talk) to be created in. You dont need an extension for this. Example: "C:\Documents and Settings\All Users\Desktop\FILENAME". If you want the user to pick where the file is saved at you can use the get_save_filename() funciton. The "talk" argument will allow the computer to "talk". It should either be true or false. [true = talk; false = dont talk]. (The .vbs file is still created for later reference.)
Just push "Open" when you click on the link to the script to open in the browser.
comp_talk(str) This function has one argument: "str". The "str" is the string of text that you want the computer to say.
/*
** Usage: comp_talk(str)
**
** Argument: str - The words you want your computer to say.
**
** Returns: 1 if successfull. 0 if unsuccessfull.
**
** Details: This script creates a VBS file that will make your computer talk
** in the local game folder and will then execute it.
**
** Creator/Contact: Vivi_IX Email: bradford_d@ymail.com
*/
//Initialize Variables
talk_text = argument0;
fname = temp_directory+"\comp_talk";
ext = ".vbs";
//This sets up the codes for the .vbs file
vbscode1_1 = string('strText = (" ');
vbscode1_2 = string(' ")');
vbscode2=string('Set objvoice = CreateObject("SAPI.SpVoice")');
vbscode3=string("ObjVoice.Speak strText");
//Write code and text to .vbs file
file = file_text_open_write(fname+ext);
file_text_write_string(file,vbscode1_1+talk_text+vbscode1_2);
file_text_writeln(file);
file_text_write_string(file,vbscode2);
file_text_writeln(file);
file_text_write_string(file,vbscode3);
file_text_close(file);
if file_exists(fname+ext) = true
{execute_shell(fname+ext,"");
return(1);}
else
{return(0);}
comp_talk_ext(str,fname,talk) This function has two new arguments ("fname" and "talk"). The "fname" is the path in which you want the .vbs file (the file that makes your computer talk) to be created in. You dont need an extension for this. Example: "C:\Documents and Settings\All Users\Desktop\FILENAME". If you want the user to pick where the file is saved at you can use the get_save_filename() funciton. The "talk" argument will allow the computer to "talk". It should either be true or false. [true = talk; false = dont talk]. (The .vbs file is still created for later reference.)
/*
** Usage:
** comp_talk_ext(str,fname,talk)
**
** Arguments(3):
** str: ------------ The text you want your computer to speak.
**
** fname: ---------- The filname and path you want the file to have.
** Example: C:\Folder\Filename or leave blank to create
** the file in the folder of the game.
**
** talk: ----------- Whether or not to actually make the coputer talk.
** True = Do talk. False = Don't talk.
**
** Returns:
** The filepath of the .vbs file created. You may use this to later reference
** the .vbs file (such as to delete, copy, execute, etc....)
**
** Details:
** This script creates a VBS file based on what you want you computer to say,
** and then executes that file in order to make the computer talk.
** (this file will NOT be automatically deleted)
**
** Creator/Contact: Vivi_IX Email: bradford_d@ymail.com
*/
//Initialize Variables
talk_text = argument0;
fname = argument1;
talk = argument2;
ext = string(".vbs");
//This sets up the codes for the .vbs file
vbscode1_1 = string('strText = (" ');
vbscode1_2 = string(' ")');
vbscode2=string('Set objvoice = CreateObject("SAPI.SpVoice")');
vbscode3=string("ObjVoice.Speak strText");
//Write code and text to .vbs file
file2 = file_text_open_write(string(fname)+string(ext));
file_text_write_string(file2,vbscode1_1+talk_text+vbscode1_2);
file_text_writeln(file2);
file_text_write_string(file2,string(vbscode2));
file_text_writeln(file2);
file_text_write_string(file2,string(vbscode3));
file_text_close(file2);
if talk = true
{execute_shell(fname+ext,"");}
return(string(fname+ext))
Last edited by Vivi_IX on Sun Aug 09, 2009 11:24 pm; edited 11 times in total
Re: Make your computer talk:
Can you put the pieces of code in code format?
It would make it less confusing.
- Code:
Like This
It would make it less confusing.
Re: Make your computer talk:
I dont like using that. Sometimes it unformats my text. To see it all at once, just click on the link to the script and select "Open" instead of saving it.
[Edit]: well I put it in a spoiler for you(the hide wasn't working). I just dont like this forum's [code]. The line aren't supossed to be limited.
[Edit]: well I put it in a spoiler for you(the hide wasn't working). I just dont like this forum's [code]. The line aren't supossed to be limited.
Re: Make your computer talk:
Problem solved. I made my own "code" box. I also swiched my file hoster becuase the other one would only let you download a file if I had signed in that day. [I still need to find a direct file hoster for "Instant Play"]
Similar topics
» Let's make this clear
» Hmm... Noticed some rep drops.
» Alex Quest (Re-make)
» I can make you a music loop.
» Make your own S&A game! (Seek and Advance)
» Hmm... Noticed some rep drops.
» Alex Quest (Re-make)
» I can make you a music loop.
» Make your own S&A game! (Seek and Advance)
:: Game Making :: Game Maker Help :: Code Database
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum