Jump to content


Photo

changing 'quotes' ? when in certain condition


  • Please log in to reply
12 replies to this topic

#1 iphoneiv

iphoneiv

    GMC Member

  • GMC Member
  • 27 posts
  • Version:GM8

Posted 26 February 2012 - 04:29 PM

trying to make a game like harvest moon.
in the game, well, it's kind of hard to explain.
this is what i want help with:
whenever the player talks to another character, the other character says a clump of text depending on the situation
for example(in the HM game):
- whenever it is raining, and the player talks to another character, the other character saids, "oh no, it's starting to pour, i have to get inside"
- another example is, when the player first meets the other character and talks to them, the other character says an intro, like, "hello, you must be jake, i've heard about you from my sister. my name is bla". then, they character never says that again because, y'know, the character was introducing herself
get it? depending on the situation, they say certain things. (btw, there are lots of character in the game, just incase ppl need to know)

i was going to put up the info i have on the text and such, but i just found out that the folder which my file was in doesn't work....so now i have to wait for my dad to come back home and fix it, which is around 6 days from now?... TnT (or maybe it'll somehow fix itself earlier. who knows)

but if anyone can help me get an idea of how to do this, or some pointers/hints for now, that would be great!
ty!

if you dont understand, just ask. i'll gladly explain more thoroughly
* oh, and also, if you put an idea(that includes scripting and such), an explanation would be great(of course you dont have to)
i just want to learn about GML more, so an explanation would help
  • 0

#2 RangerX

RangerX

    GMC Member

  • GMC Member
  • 996 posts
  • Version:GM8.1

Posted 26 February 2012 - 04:59 PM

You need to think this way: What are the condition I need met in order for my character to say X stuff.

When it's raining, why don't you have a boolean variable named like "Raining" put to true?
Therefore it would be possible to do something like this:

if(Raining==true)
then{ "character says whatever" }

It's just as easy to know if it's the first time you talk to that character. Have a boolean variable like "FirstTalk" set to true. After your talk to that character once, turn the "FirstTalk" variable to "false".
You get me? ;)
  • 0

#3 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5586 posts
  • Version:GM:Studio

Posted 26 February 2012 - 05:00 PM

for the introduction you could give each character a number:

pete create event
nr = 10;

and in your persistent controll object you could have, meaning it will follow you between room changes (or you could use global variables)

ctrl_obj create event
intro[100]=0; // this will make intro[0] to intro[100] filled with the default value 0
weather = 0; // a variable that tells what weather it is

now then .. talking with pete:
if ctrl_obj.intro[nr]=false{ // if not meet before
   show_message("Hi I'm Pete") // well, I would make a textbox object instead and send it the text to display
   ctrl_obj.intro[nr]=true; // change it so you have meet
   break; // end the code here so it doesn't show any other messages
}

if weather=0{ // if the variable is this then show this text
  show_message("Oh what a sunny day")
}else if weather=3{ // if it was something else then check if it is this instead
  show_message("Can't it stop snowing")
}else show_message("Wonder when we will get some real weather") // if noone of the above then just display this one

  • 0

#4 iphoneiv

iphoneiv

    GMC Member

  • GMC Member
  • 27 posts
  • Version:GM8

Posted 26 February 2012 - 06:16 PM

You need to think this way: What are the condition I need met in order for my character to say X stuff.

When it's raining, why don't you have a boolean variable named like "Raining" put to true?
Therefore it would be possible to do something like this:

if(Raining==true)
then{ "character says whatever" }

It's just as easy to know if it's the first time you talk to that character. Have a boolean variable like "FirstTalk" set to true. After your talk to that character once, turn the "FirstTalk" variable to "false".
You get me? ;)


>awesome :)
just one question.
would the firstTalk be in the create event of the character you would be talking to? or maybe the create of the player?
- if it is, i have this small problem with that, but i dun really know how to explain, so i have to show you the script....which i can't access, sorry :<

but thanks for the explanation anyways, really helped XD
  • 0

#5 RangerX

RangerX

    GMC Member

  • GMC Member
  • 996 posts
  • Version:GM8.1

Posted 26 February 2012 - 06:28 PM

Every character you're talking to could have a "FirstTalk=true" in their create event. Every character you want their first discussion to be unique.
  • 0

#6 iphoneiv

iphoneiv

    GMC Member

  • GMC Member
  • 27 posts
  • Version:GM8

Posted 26 February 2012 - 06:41 PM

for the introduction you could give each character a number:

pete create event

nr = 10;

and in your persistent controll object you could have, meaning it will follow you between room changes (or you could use global variables)

ctrl_obj create event
intro[100]=0; // this will make intro[0] to intro[100] filled with the default value 0
weather = 0; // a variable that tells what weather it is

now then .. talking with pete:
if ctrl_obj.intro[nr]=false{ // if not meet before
   show_message("Hi I'm Pete") // well, I would make a textbox object instead and send it the text to display
   ctrl_obj.intro[nr]=true; // change it so you have meet
   break; // end the code here so it doesn't show any other messages
}

if weather=0{ // if the variable is this then show this text
  show_message("Oh what a sunny day")
}else if weather=3{ // if it was something else then check if it is this instead
  show_message("Can't it stop snowing")
}else show_message("Wonder when we will get some real weather") // if noone of the above then just display this one




> nice! i love the explanation ^u^

actually, i do have a textbox object. but i'm not really sure how to make the textbox display the message since i want the character to say it when i press z.
- so, if i remember correctly, the press z event of the character had :
if global.pause=false && scr_checknear() //scr_checknear, well, i'm sure you can guess but it checks if the character is near
{
face_char
create_textbox()
}
-not sure if i missed anything in that o_o

and the create event of the character:
str[0] = "blabla"
str[1] = ""

will it work if i did in the create event:
if weather=0{
str[0] = ("Oh what a sunny day")??
...or maybe i'm just asking sumtin stupid? :P


and also, another question; is it possible to make a clump of messages? like:
if weather=0{
str[0]="Oh what a sunny day"
str[1]="i like bananas"
str[3]="")
}

and another question (srry for all the question :C)
is it also possible to make the character's profile (the pic that shows the chracter on top of the text)
change depending on the string being played?
for exmaple, if the character says "i like bananas" the character's profile will change to 'happy'-the pic of him happy-
if he says "it raining", his profile will change to 'sad'

thx for the help, i really appreciate it!
  • 0

#7 RangerX

RangerX

    GMC Member

  • GMC Member
  • 996 posts
  • Version:GM8.1

Posted 26 February 2012 - 06:59 PM

You would then need variables again that would decide if X text string is sad, happy, etc.
You would therefore check wich string is actually displayed right now and then change the image of the character accordingly.
  • 0

#8 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5586 posts
  • Version:GM:Studio

Posted 26 February 2012 - 07:25 PM

you could make it so that the textbox is created and then you trigger the user event 0 that set the text in the textbox

in the top line of the code box (above the type field) make it apply to the textbox object
str[0] = "blabla"
str[1] = ""

spr[0]=face_normal_spr

if weather=0{
str[0]="Oh what a sunny day"
str[1]="i like bananas"
str[2]=""

spr[0]=face_normal_spr
spr[1]=face_happy_spr
}

the good thing about having this is that if variables changes, then it will send a diffrent text to the textbox, would come in handy to skip the first conversation after it have been triggered

I do not know the code you are using to draw them, but the text should use some variable like:
draw_text(x,y,str[line])
//so you add the sprite pretty mutch the same way
draw_sprite(spr[linw],image_index,x,y)

so after making the chatbox, with(character_in_front)event_user(0)
  • 0

#9 iphoneiv

iphoneiv

    GMC Member

  • GMC Member
  • 27 posts
  • Version:GM8

Posted 26 February 2012 - 07:44 PM

you could make it so that the textbox is created and then you trigger the user event 0 that set the text in the textbox

in the top line of the code box (above the type field) make it apply to the textbox object

str[0] = "blabla"
str[1] = ""

spr[0]=face_normal_spr

if weather=0{
str[0]="Oh what a sunny day"
str[1]="i like bananas"
str[2]=""

spr[0]=face_normal_spr
spr[1]=face_happy_spr
}

the good thing about having this is that if variables changes, then it will send a diffrent text to the textbox, would come in handy to skip the first conversation after it have been triggered

I do not know the code you are using to draw them, but the text should use some variable like:
draw_text(x,y,str[line])
//so you add the sprite pretty mutch the same way
draw_sprite(spr[linw],image_index,x,y)

so after making the chatbox, with(character_in_front)event_user(0)




>i see, i never even thought of that :o
i hope i'll be able to think up of solutions like you.
and thanks! i was thinking about how to do this for like a week! tytyty ^w^
  • 0

#10 iphoneiv

iphoneiv

    GMC Member

  • GMC Member
  • 27 posts
  • Version:GM8

Posted 26 February 2012 - 07:53 PM

You would then need variables again that would decide if X text string is sad, happy, etc.
You would therefore check wich string is actually displayed right now and then change the image of the character accordingly.


is there a way to check what string is being displayed?
the only ones i know of where they check if something exists is:
instance_exists()
or
variable_local_exists()
something of the sort (well, thats only for if something exists, not if that something is being displayed :unsure: )

thanks for the quick reply+help :)
  • 0

#11 RangerX

RangerX

    GMC Member

  • GMC Member
  • 996 posts
  • Version:GM8.1

Posted 27 February 2012 - 01:54 AM

Well, my solution might not be as straigthforward as I first though. You'd need to create a little function actually to make it work fine. Never mind it then. :/
  • 0

#12 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5586 posts
  • Version:GM:Studio

Posted 27 February 2012 - 02:44 AM

is there a way to check what string is being displayed?
the only ones i know of where they check if something exists is:
instance_exists()
or
variable_local_exists()
something of the sort (well, thats only for if something exists, not if that something is being displayed :unsure: )

thanks for the quick reply+help :)

well, accually, you could make it so that the first (or 2 first) characters in the string tells what icon he shall use .. if that sounds better .. string_copy(str[line],1,2) and make it so that the text displays without the 2 first characters string_copy(str[line],3,string_length(str[line])-2)
  • 0

#13 iphoneiv

iphoneiv

    GMC Member

  • GMC Member
  • 27 posts
  • Version:GM8

Posted 27 February 2012 - 02:50 AM

good new , my file is working so i can put my scripts in for more info:
script:
create_textbox:

var __ti;

__ti = instance_create(view_xview[0],view_yview[0]+112,o_textbox)

for (n=0; n<19; n+=1)
{
__ti.text[n] = str[n];

if is_real(str[n+1])
{
__ti.maxn = n;
break;
}
if str[n+1]=""
{
__ti.maxn = n;
break;
}
}


o_npc_1:
create:
npc_type = "face up"

str[0] = "bla."
str[1] = ""

pressZ:
if global.pause = false and scr_checknear(o_player)
{
scr_facechar(o_player)
create_textbox()
}

o_textbox:
alarm 0:
for (n=0; n<=maxn; n+=1)
{

if string_count(" ",text[n])>0
text[n] = string_replace_all(text[n]," "," ")

if string_count("\n",text[n])>0
text[n] = string_replace_all(text[n],"\n","#")

if string_count("\S",text[n])>0
{
text[n] = string_replace_all(text[n],"\S","")
type[n] = 1
}

if string_count("\r",text[n])>0
{
text[n] = string_replace_all(text[n],"\r","")
color[n] = c_red
}
if string_count("\b",text[n])>0
{
text[n] = string_replace_all(text[n],"\b","")
color[n] = c_blue
}
if string_count("\g",text[n])>0
{
text[n] = string_replace_all(text[n],"\g","")
color[n] = c_green
}
if string_count("\p",text[n])>0
{
text[n] = string_replace_all(text[n],"\p","")
color[n] = c_purple
}
if string_count("\m",text[n])>0
{
music[n] = real(string_copy(text[n],string_pos("\m",text[n])+2,1))
//show_message(string(music[n]))
text[n] = string_replace_all(text[n],"\m0","")
if n = 0
sound_play(music[n])
}
}
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users