The Daily Click ::. Forums ::. Klik Coding Help ::. Pause in-between Events?
 

Post Reply  Post Oekaki 
 

Posted By Message

Sephirenn

Possibly Insane

Registered
  15/01/2002
Points
  2343

360 OwnerPS3 OwnerWii OwnerI am an April FoolVIP MemberGOTW JUNE 2010 WINNER!
4th January, 2011 at 23:28:59 -

I have had this problem in MMF forever and my work-arounds are pretty lack-luster, so I thought I would ask the community. Here goes:

I want to use spacebar as the 'action' button. So, the character walks to a shop, presses 'spacebar' and a menu opens up. Then they look at it, and when finished, press 'spacebar' again to close the menu.

Here's the (apparently faulty) way I code it:

-----------------
'Hero' overlapping 'Shop' + User presses 'spacebar'
- Make menu objects visible
- Set Shop value A to 1.
- Pause 'Hero' Movement

If Shop Value A is 1 + User presses 'spacebar'
- Make menu objects invisible.
- Set Shop Value A to 0
- Un-pause 'Hero' movement
-----------------

When I do that, nothing appears at all. I am assuming that it counts the spacebar press in both events back to back, instead of running the first one and then leaving the second one alone until another spacebar press takes place.

Can anyone help? I've tried using a quick timer in between, but that is sloppy and doesn't work 100% of the time.

Thanks in advance!!!

 
*Sephirenn*

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
4th January, 2011 at 23:42:21 -

I believe your code should work if you just swap the order of the two events, but I'm not sure.
If not, try using a flag, and just toggle it when user presses spacebar.

 
n/a

Sephirenn

Possibly Insane

Registered
  15/01/2002
Points
  2343

360 OwnerPS3 OwnerWii OwnerI am an April FoolVIP MemberGOTW JUNE 2010 WINNER!
4th January, 2011 at 23:44:28 -

I think the flags should work. Thanks for the tip!

 
*Sephirenn*

Mark McCauley



Registered
  18/02/2009
Points
  291

Has Donated, Thank You!VIP Member
5th January, 2011 at 09:59:32 -

also.
setting a variable value of an active object on screen to contain a countdown number would help this.
for instance

-----CONDITION-------------------------------------------ACTION-----------------------------------------

-----------------------------------------Activeobject1(shop)------------menu-----------Player1----------


if hero on shop
+ space bar pressed
+ valueA(activeobject1)=0-----------set valueA to 3----------------reappear-------ignore-control--
+ menu is invisible
+ limit once per action



if valueA(activeobject1)>0----------subtract 1 from valueA-------------------------------------------
+ every 1 second

if hero on shop
+ space bar pressed
+ valueA(activeobject1)=0-----------set valueA to 3-------------make_invisible----restore-control--
+ menu is visible
+ limit once per action


this would stop the menu appearing and dissappearing so quick.



Edited by Mark McCauley

 
http://www.reddwarf.co.uk/forum/messages.cfm?threadid=44227736-C46F-AC56-02EBA05285818C14

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
5th January, 2011 at 14:46:23 -

You can use toggle flags for those kind of stuff aswell.

press spacebar - toggle flag 0

flag 0 on?
open shop, pause movement

flag 0 off?
close shop, continue movement

and you can limit to only one action per event. So it doesnt repeat actions if the flag doesnt change.

Ah, i m getting blind, just noticed sketchy already pointed toggling flags.

Edited by Don Luciano

 
Code me a sausage!

Mark McCauley



Registered
  18/02/2009
Points
  291

Has Donated, Thank You!VIP Member
5th January, 2011 at 16:30:17 -

I think by just toggling flags u can turn them off and on in one press
because the events occur in order unless something is different to the previous line

for instance
---------------------------
if key pressed
+(object) is invisible-
then
set (object)flag(0) on
set (object) visible

followed by

if key pressed
+ (object) is visible-
then
set (object)flag(0) off
set (object) invisible
--------------------------------------------
the first bit turns it on and straight away the next line would turn it back off,
doesnt matter which way round u do it unless you change a value of something on each line.

whereas

-----------------------------
if key pressed
+ (object) is invisible-
+ value A(object)=0
then
set (object)flag(0) on
set (object) visible
set value A(object) to 1

followed by

if key pressed
+ (object) is visible-
+ value A(object)=0
then
set (object)flag(0) off
set (object) invisible
set value A(object) to 1

followed by
If value A(object)>0
then
set value A to 0


-----------------------------------

because the valueA(object) was changed in the first instance the next line would be false cos a=1 so the programme would skip this event. then The last line sets A back to normal
you could even use another flag
whereas

clearer?

Edited by Mark McCauley

 
http://www.reddwarf.co.uk/forum/messages.cfm?threadid=44227736-C46F-AC56-02EBA05285818C14

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
5th January, 2011 at 18:02:38 -


Originally Posted by Mark McCauley
I think by just toggling flags u can turn them off and on in one press



You can't turn them off and on in one press when toggling.

because action is not
set flag 0 on
its
toggle flag 0

 
Code me a sausage!
   

Post Reply



 



Advertisement

Worth A Click