Source language: Translate to:

How to create an action determined by the order of mouse cli

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

How to create an action determined by the order of mouse cli

Postby seanie » Fri Sep 07, 2012 8:19 am

Hello fellow NeoBookers,

I'm trying to create a vocabulary memory game for my students. To give you an idea of what I'm attempting to do, it's something like this:

http://www.2flashgames.com/2fgkjn134kjl ... /f-651.swf

I can make the objects, but I don't know how to make something happen if two objects are clicked on consecutively.

In other words, if students click on two LIKE objects, then they both disappear. I know how to make the objects 'disappear':-) What I don't know is how to write the command for If Object X is clicked immediately after clicking Object Y, then both Object X and Y disappear.

I hope I have explained myself clearly. If so, then I'd be grateful for any assistance.

Thanks for reading!

S
seanie
 
Posts: 47
Joined: Tue Jul 31, 2007 9:33 am

Postby smokinbanger » Fri Sep 07, 2012 9:07 am

To get started try something like:
Code: Select all
If "[Object1]" "<>" "Clicked"
   SetVar "[Obeject1]" "Clicked"
Else
    SetVar "[Object1]" ""
    .Allows the user to unclick an object
EndIf

IfEx "[Object1] = Clicked AND [Object2] = Clicked AND [Object4] <> Clicked AND [Object5] <> Clicked"
   HideObject "Object1" "None" "0"
   HideObject "Object2" "None" "0"
EndIf

That's one method, build on it from there. You may also consider using a clicked effect like shading the object;
Code: Select all
If "[Object5]" "=" "Clicked"
   SetObjectFill "Object5" "Silver" "Solid" "False"
EndIf

Another suggestion might be to use a separate array for each set of matching object to make it easier.
smokinbanger
 
Posts: 198
Joined: Mon Jan 16, 2012 9:53 am
Location: United States

Postby Gaev » Fri Sep 07, 2012 9:22 am

seanie:

looks like you are trying to make games similar to ones I made years ago ... check out ...

http://www.scriptedlogic.com/IdenticoFreeSet1.htm ... Identico ... a pure memory game where user has to remember the locations of identical images

http://www.scriptedlogic.com/IdenticoFreeSet1.htm ... FiGORI ... where the user has to remember the locations of 'related images'

In both games, the user can choose to play with 9 sets of 2 images or 6 sets of 3 images.

Both are available for (free) download ... sorry, the source code is not included.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: How to create an action determined by the order of mouse

Postby dpayer » Fri Sep 07, 2012 2:12 pm

seanie wrote:Hello fellow NeoBookers,


I can make the objects, but I don't know how to make something happen if two objects are clicked on consecutively.
S


Another idea. Each object has a name. You can set a variable with that name (using the variable [self[) when the object is clicked and then connect the strings and look for your combination.

Example: Button1, Button2, Button3, Button4, Button5. You want to look for the Button3 then Button5 order.

Each button has an action for when it is clicked (as do many other objects). In that section of the action editor, place code similar to this:

Code: Select all
SetVar "[LastClicked]" "[Self]"
.add this name to the name of the last object clicked
SetVar "[ClickOrder]" "[ClickOrder][LastClicked]"
SearchStr "Button3Button5" "[Clickorder]" "[FoundRightOrder]" ""
If "[FoundRightOrder]" ">" "0"
   GoSub "Whateveryouwantdonenow"
Else
   .clean up the ClickOrder variable so it doesn't get too long
   SetVar "[ClickOrder]" "[LastClicked]"
Endif     



David P.
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby seanie » Fri Sep 07, 2012 8:14 pm

Smokinbanger, Gaev, and David,

Thank you so very much! I'll be trying out your much appreciated suggestions this weekend.

S
seanie
 
Posts: 47
Joined: Tue Jul 31, 2007 9:33 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron