Jump to content


Photo

How todisable mouse click with certain conditions?


  • Please log in to reply
9 replies to this topic

#1 cordakiki

cordakiki

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 16 May 2012 - 05:20 AM

I want to set that if score <30, the player cannot click into the room, how can I do that?

below is my code but not work.

I put the below script in the obj that access to a room that I want to player won't be able to come in that room until getting score>30

{
if (score < 30) {io_clear();}

}

Edited by cordakiki, 17 May 2012 - 01:53 AM.

  • 0

#2 Asurd

Asurd

    2

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

Posted 16 May 2012 - 05:48 AM

Please give a brief description of your problem:)
  • 0

#3 Mr. Munchkin

Mr. Munchkin

    GMC Member

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

Posted 16 May 2012 - 06:05 AM

I'm sorry, but I don't understand in the slightest. What exactly does "Is that trial version do not support globalvar."
1) You're giving too brief a description
2) You're not describing the problem at all.

If you tell us what's happening, I'll be happy to help :)
  • 0

#4 Yal

Yal

    Gun Princess

  • Global Moderators
  • 5865 posts
  • Version:GM8.1

Posted 16 May 2012 - 07:03 AM

All of your versions are support to globalvar. You've just used it in the wrong way. Learn how to use it, then you'll be fine.
  • 0

#5 cordakiki

cordakiki

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 16 May 2012 - 07:22 AM

Thank you so much for reply^ ^
I want the score to be seperate to calculate instead of using the predefined one 'score',

I have error saying that weekmark1 is undefined or cannot find something like that

below is my code in script1

{
globalvar weekmark1;
weekmark1 = 0;

var ind,val,num;
message_position(330,475);


for (num=0; num<10; num=num+1)
{
ind = floor(random(30));
val = get_string(question[ind],'');
if (val == answer[ind])
{
show_message('Correct!');
weekmark1 += 20;
//score += 10;
}
else
{show_message('That answer is WRONG!');
weekmark1 += 0;
//score += 0;}

}
message_position(-1,-1);
}


below I use an object to implement the script as well as draw the score

//globalvar weekmark1; draw_text(70,30, 'Your total score is');
draw_set_font(48);
draw_set_halign(fa_center);
draw_text(150,30,weekmark1);
//*Here I have tried to declare the weelmark1 as globalvar here again, or write global.weekmark1 or script1.weekmark1 or weekmark1
the program still cannot run, please helpTAT


Also, below I have problem on showing the message continuously after presiing OK cannot leave the program:
/*if (score == 100) {
show_message('Excellent!');
room_goto_previous(); }
if (score >= 80) && (score< 100){
show_message('Well done!');
room_goto_previous(); }
if (score > 50) && (score <80){
show_message('GOOD!');
room_goto_previous();}
else if (score!=0)
{show_message('Please Try again!');
room_goto_previous();}
*/


Edited by cordakiki, 16 May 2012 - 07:23 AM.

  • 0

#6 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2240 posts
  • Version:Mac

Posted 16 May 2012 - 12:51 PM

Thank you so much for reply^ ^
I want the score to be seperate to calculate instead of using the predefined one 'score',

I have error saying that weekmark1 is undefined or cannot find something like that

below is my code in script1


{
globalvar weekmark1;
weekmark1 = 0;

var ind,val,num;
message_position(330,475);


for (num=0; num<10; num=num+1)
{
ind = floor(random(30));
val = get_string(question[ind],'');
if (val == answer[ind])
{
show_message('Correct!');
weekmark1 += 20;
//score += 10;
}
else
{show_message('That answer is WRONG!');
weekmark1 += 0;
//score += 0;}

}
message_position(-1,-1);
}


below I use an object to implement the script as well as draw the score

//globalvar weekmark1; draw_text(70,30, 'Your total score is');
draw_set_font(48);
draw_set_halign(fa_center);
draw_text(150,30,weekmark1);
//*Here I have tried to declare the weelmark1 as globalvar here again, or write global.weekmark1 or script1.weekmark1 or weekmark1
the program still cannot run, please helpTAT


Also, below I have problem on showing the message continuously after presiing OK cannot leave the program:
/*if (score == 100) {
show_message('Excellent!');
room_goto_previous(); }
if (score >= 80) && (score< 100){
show_message('Well done!');
room_goto_previous(); }
if (score > 50) && (score <80){
show_message('GOOD!');
room_goto_previous();}
else if (score!=0)
{show_message('Please Try again!');
room_goto_previous();}
*/

First off, you realize that there's [code=auto:0] tags for posting code? It's weird seeing it in the quote box, lol.

Now to answer your question... you're doing it wrong. A global variable is set up by saying
global.weekmark1;
(not globalvar weekmark1;)

Edited by dannyjenn, 16 May 2012 - 12:52 PM.

  • 0

#7 Yal

Yal

    Gun Princess

  • Global Moderators
  • 5865 posts
  • Version:GM8.1

Posted 16 May 2012 - 01:00 PM

WRONG!

globalvar will make a variable global, and also strip you of the need to write "global" in front of it.



BTW, when is that darn script run? If it's not run in a CREATE event of the very object that tries to draw it (or in a earlier room), the variable will be referenced BEFORE it's inited and thus before it exists. (After each create event there is an additional Draw event, and Room Start events happen only after all create events are finished. Also the Game Start event happens after the Room Start events)
  • 0

#8 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 5234 posts
  • Version:GM8

Posted 16 May 2012 - 02:34 PM

Try to get in the habit of declaring global variables at the start of the game; since you won't be able to delete them anyway, it makes sense to have them readily available. In the Room Settings of the very first room of your game, declare all your global variables. You can use

globalvar variable1,variable2,variable3,...,variableN;

Then be sure to initialize them all. A variable, even those declared with globalvar, have no value until you initialize them. So you won't be able to say

globalvar greeting;
draw_text(x,y,greeting)

is an invalid code. However, you can use

globalvar greeting;
greeting="Hi!"
draw_text(x,y,greeting)


And remember at the start of a room, the Draw event is executed before the first step.

...Damn! Cute girl walked into my store. Nice body! :P
  • 0

#9 cordakiki

cordakiki

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 17 May 2012 - 12:20 AM

Thank you so much!

After seeing the posts above, I declare the globalvar in draw function and the problem is sloved. Really thanks a lot!
  • 0

#10 cordakiki

cordakiki

    GMC Member

  • New Member
  • 8 posts
  • Version:GM8

Posted 17 May 2012 - 04:14 AM

I want to set that if score <30, the player cannot click into the room, how can I do that?

below is my code but not work.

I put the below script in the obj that access to a room that I want to player won't be able to come in that room until getting score>30

{
if (score < 30) {io_clear();}

}

Is any things go wrong? please help><
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users