Changing blocks to different colors

This forum is meant for people to share their knowledge by writing their own tutorials for Adventure Maker.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Changing blocks to different colors

Postby laserman » Fri Mar 21, 2008 6:38 pm

Here's a tall order, but if anyone can help, it would be much appreciated. I have uploaded an image in case anyone can accomplish this. The image is very rough but serves the purpose I believe.

I have 3 rows of 4 squares each.
I want to be able to click on a square and have an option box pop up to ask the user to enter a number from 1 - 9. After the user enters the number (and presses Enter or clicks on OK), according to the number they entered, the block selected will turn a predetermined color associated with that number and stay that way when saved and loaded.

Is this clear enough? If not, let me know and I will try and explain it differently. Thanks for any considerations.
Attachments
blox.jpg
blox.jpg (6.08 KiB) Viewed 7959 times
laserman
Member
 
Posts: 16
Joined: Fri Mar 21, 2008 6:06 pm

Postby Lyberodoggy » Fri Mar 21, 2008 7:04 pm

Hello and welcome to the Forums!


Okay, here's what you 've got to do:
create a hotspot over each block.
Write this piece of code in advanced:
Code: Select all
color=InputBox("input a number between 1 and 9")
Select Case color
 case 1
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "green.jpg"
 case 2
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "red.jpg"
 case 3
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "purple.jpg"
 case 4
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "yellow.jpg"
 case 5
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "black.jpg"
 case 6
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "white.jpg"
 case 7
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "gray.jpg"
 case 8
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "maroon.jpg"
 case 9
 Action.LoadAPicture Hotspot(Action.GetHotspotNumber), "olive.jpg"
End Select

Where you must replace green.jpg etc with the name of 9 pictures representing the 9 colors you need to display.


Hope this helped... If you need any explanations, feel free to ask...

EDIT: Fixed that bug... it should work now...
Last edited by Lyberodoggy on Sat Mar 22, 2008 9:57 am, edited 2 times in total.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby laserman » Sat Mar 22, 2008 5:09 am

Thanks for the quick reply.
I did that, but I got this message:

Error executing script.
The scripting engine returned the following error message
Expected "End"

I'm not sure what it's looking for. Also, where do I paste the code? I see 2 places. Is it the hotspot properties box, or the one under the menu? I did it in the hotspot properties box.
Thanks again.
laserman
Member
 
Posts: 16
Joined: Fri Mar 21, 2008 6:06 pm

Postby Lyberodoggy » Sat Mar 22, 2008 9:05 am

My mistake... I got the whole code wrong...

You can find the debugged version in my previous post, I edited it...


Sorry I should have tested it...
Ah, I must mention the "else case" wouldnt work so I deleted it. If you want to check whether the input number is between 1 and 9 to continue, add these lines
here goes the first line of the original code, then write this one:
Code: Select all
If 1<=color<=9 then

here goes the rest of the rest of the original code, then write:
end if

I 'm not sure if this is going to work, but the rest works...
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby laserman » Sat Mar 22, 2008 2:43 pm

That was beautiful. thanks.
:D
The error checker didn't work, but that's okay. The code did.

This brings up another question as long as you don't mind....

I had assumed that the pictures I made would (how can I put this) be "layered" over the original according to the hotspot coordinates, so that no matter what block I chose, the colored blocks would be in the same spot I clicked on after entering the associated number. This didn't happen. What did happen was that the colored block would replace the 12 block image.

To avoid being a pain in the butt here, I experimented and found that if I make my colored blocks into AVI files then I could select the coordinates. However (and as you most likely well know) I can only choose 1 video for each area of the original block image. This of course defeats the whole purpose of being able to put whatever color I choose, wherever I want on the original image and (of course) however many I want also.

I hope I'm not being confusing here.

So my question now is: How would I accomplish "layering" in this sense? Thanks again for your consideration.
laserman
Member
 
Posts: 16
Joined: Fri Mar 21, 2008 6:06 pm

Postby Lyberodoggy » Sat Mar 22, 2008 3:11 pm

If I got your point, you created only one hotspot... Well that is definitely wrong. You must create one hotspot for each block. I 'm attaching a sample project.
Attachments
testagain.rar
the sample project I mentioned... This should help you...
(141.8 KiB) Downloaded 458 times
Last edited by Lyberodoggy on Sun Mar 23, 2008 6:46 pm, edited 1 time in total.
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby laserman » Sat Mar 22, 2008 5:12 pm

It worked great! That is what I am talking about.
:D
So apparently I create 1 hotspot for each block, with the code, and that is what allows me to chose whatever colors I want. I am assuming also that if I save it, it will be saved with the colors I left off on when I load it again later on?

Thanks so much for this. Amazing how simple the solution was,
I will of course have more questions as time goes on. I will post them here as this progresses. Thanks again you've been an amazingly big help.
2 big thumbs up to you.
laserman
Member
 
Posts: 16
Joined: Fri Mar 21, 2008 6:06 pm

Postby Candle » Sat Mar 22, 2008 5:32 pm

Going to move this to Tutorials so others can find it and use it.
Please don't PM me questions, ask here in the forums!
``````````````
Between grand theft and a legal fee, there only stands a law degree.
User avatar
Candle
Administrator
 
Posts: 3077
Joined: Sat Feb 07, 2004 2:21 am
Location: Rudy's Bar

Postby Lyberodoggy » Sat Mar 22, 2008 7:10 pm

To laserman: Thanks for your good words, it's always nice to be of help and I will definitely try to help you if you have any other difficulties.

To Candle: Yes, nice idea Candle!
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens


Return to Post Your Own Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests

cron