Page 1 of 1

Changing the cursor by right clicking (Scripting)

PostPosted: Thu May 15, 2008 2:08 pm
by Lyberodoggy
After hours of trying to create a custom inventory, I put that aside to present another trick.

Before half an hour, I accidentaly discovered the function of AM that lets you assign another function to the right click instead of bringing up the menu.

At that time I had the idea of creating a code to change the cursor every time the player wants to examine something (for example see Runaway).

So, here is the way to do so.
1. Go to variables, create a variant variable called mode
2. Create a blank frame named mode. Create a text and a hotspot in it. In the text write Action. Make the Hotspot appear as a hand and import the magnifier from the icons to the directory of the hotspot apearance's pictures.
3. Go to Project properties -> Advanced and select the checkbox at the bottom. Paste this code in it:


Code: Select all
If mode="Action" Then
mode="Search"
Action.ChangeDefaultCursor "magnifier.ico"
icontouse="magnifier.ico"
Else
mode="Action"
Action.ChangeDefaultCursor ""
Action.GoToFrame Action.GetCurrentFrameName
IcontoUse="Action2.ico"
End If
Text(Action.GetMergedTextIndex).Caption=mode
Action.LoadAPicture Hotspot(Action.GetMergedHotspotIndex), IconToUse

4. At the other two checkboxes, write this code:
Code: Select all
mode="Action"

5. Go to your project's frames. Merge them with the frame named mode.
Then create hotspots and make them perform their actions with scripting like this:

Code: Select all
If mode="Action" Then
Action.GoToFrame "Solid01"
Else
Action.message "What a nice door!"
End If

Or create another variable and make it 0 if mode="Action" or 1 if mode= "Search", then create different hotspots for the two modes and make them visible or not depending on the variable.


Hope you will use this.

PostPosted: Thu May 15, 2008 3:40 pm
by Mystery
Thanks, sounds interesting! :D

(Btw, I've been working on a custom inventory, too - no presentable results yet, just a beginning :lol: )

PostPosted: Thu May 15, 2008 4:46 pm
by Candle
looks cool, i tried it out .
How will you do the menu so you can quit the game with the right click?

PostPosted: Thu May 15, 2008 5:50 pm
by Lyberodoggy
Just merge another frame with a text and a hotspot and make it so that it takes you to a custom menu with save/load/exit game features.

PostPosted: Thu May 15, 2008 8:35 pm
by Chromegloss55
Great, can I include it in my 100 Visual Basic Techniques? I will give you full credit... :D
_________________
Dominican Republic Forum

PostPosted: Fri May 16, 2008 9:06 am
by Lyberodoggy
Of course!

PostPosted: Mon May 19, 2008 2:12 pm
by Chromegloss55
Okay, it's technique 33, but since I'm only releasing 1 - 30 in the next update, we'll have to wait in order to see it there...
_________________
Lukumi Forum

PostPosted: Mon May 19, 2008 3:46 pm
by Lyberodoggy
Waiting :D

More than 2 cursors

PostPosted: Sun May 25, 2008 11:09 pm
by Ostp
Thanks! This is great!

How would I go about using this technique to incorporate more than two cursor icons (Look, Use, Talk)? I'm not well-versed in VBS, and the attempts I've made to figure out how to do this have failed, so any help would be appreciated.

Thanks.

PostPosted: Mon May 26, 2008 7:06 pm
by Lyberodoggy
Hello Ostp, welcome to the Forums...
there's a nice plugin to do what you want called Simple Menu, you should definitely try it.

To use this method with other features too you need to configure the code given accordingly. Example:

Code: Select all
If mode="Action" Then
mode="Search"
Action.ChangeDefaultCursor "magnifier.ico"
icontouse="magnifier.ico"
Else if mode="Search" then
mode="Something Else"
Action.ChangeDefaultCursor "anothericon.ico"
icontouse="anothericon.ico"
else
mode="Action"
Action.ChangeDefaultCursor ""
Action.GoToFrame Action.GetCurrentFrameName
IcontoUse="Action2.ico"
End If
End if 'double end here
Text(Action.GetMergedTextIndex).Caption=mode
Action.LoadAPicture Hotspot(Action.GetMergedHotspotIndex), IconToUse