Jump to content


Photo

How Do I Ask A Question In Code


  • Please log in to reply
6 replies to this topic

#1 meziathol

meziathol

    GMC Member

  • New Member
  • 505 posts

Posted 26 May 2008 - 05:03 PM

I AM USING GAME MAKER 7 :rolleyes:

What i want to happen:

When the player collides with a stool, if he press's Z he will be asked if he wants to buy a heart.
If he says yes then the computer will check to see if he has more than 24 rubys (the currency in my game)
If the player does, than his heart container increases by 50. If not you are told that you do not have enough rubys.

I am using this code:

COLISION EVENT WITH obj_player:
message_background(box_old_man)
message_button(text_button)

if keyboard_check(ord('Z')) {show_question("Would you like to buy a hearts? they refill half your container and cost 25 ruby's."){if global.money<24{health=50} if global.money>24{show_message("sorry, but you do not have enough rubys.")}}
}

But nothing is working. (i do not get the question or anything, could someone fix the code?
  • 0

#2 Diptoman

Diptoman

    GMC Member

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

Posted 26 May 2008 - 05:05 PM

I haven't read the full code, but firstly, you need to use an if before the show_question function....
  • 0

#3 JJProductions

JJProductions

    Agamma Corpus

  • New Member
  • 2211 posts

Posted 26 May 2008 - 05:06 PM

Simple. The question should be assigned to a variable.

if keyboard_check(ord("Z"))
{
question=show_question("Would you like to..... blah blah")
if question = 1
{
	 if global.money>=25
	 health = 50
	 else show_message("Sorry, you do not have enough rubies.")
}
}

Cheers.
  • 0

#4 Fredo

Fredo

    GMC Member

  • New Member
  • 428 posts

Posted 26 May 2008 - 05:06 PM

I'm not positive, but I think you do this for questions:
if show_question('whatever') = 1
{
//do this
}
else
{
//do this
}

  • 0

#5 meziathol

meziathol

    GMC Member

  • New Member
  • 505 posts

Posted 26 May 2008 - 05:07 PM

Simple. The question should be assigned to a variable.

if keyboard_check(ord("Z"))
{
question=show_question("Would you like to..... blah blah")
if question = 1
{
	 if global.money>=25
	 health = 50
	 else show_message("Sorry, you do not have enough rubies.")
}
}

Cheers.


EDIT:
That works, but instead of increasing my health by 50 it lowers/raises it to 50.#
How can i have it so it increases the health by 50?

(so if i had 1 hp then i would have 51 one hp an so on)

Edited by meziathol, 26 May 2008 - 05:15 PM.

  • 0

#6 Diptoman

Diptoman

    GMC Member

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

Posted 27 May 2008 - 11:44 AM

In the health part of that code:
health+=50;
Just make it relative!
And anyway, you didn't have to assign a variable to the show_question....Fredo's method should work too....
  • 0

#7 batlord

batlord

    GMC Member

  • GMC Member
  • 166 posts

Posted 27 May 2008 - 12:14 PM

If (something)
{
//note
var-varbile
}
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users