This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-10-23 13:34:30

CaptanAwesome
Scratcher
Registered: 2010-10-08
Posts: 21

help

I don't know where to post this so I guess I could here:

I am making a game called Dot Wars. Basicly you go around and defeate other dots by using spells. Each spell has a cooldown to prevent people from using the same attack every time. Say it has a cooldown of one, you can't use it for 1 turn. Because you and your ennimie take turns. Now here is the problim: When cooldown is taking affect the card is supposed to turn gray and you can not use it. If you try to use it while it is in cooldown the spell will not work. And when the cooldown is over you can use it again. But I don't know how to do that. So could somone please tell me what script I use to do that? If somone does and it works I will give them credit in the credits. Example:

Debug: YourNameHere

-CaptanAwesome


Need Voices:
http://scratch.mit.edu/projects/CaptanAwesome/1519322

Offline

 

#2 2010-10-23 14:01:02

benjamin2
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: help

Solution:

Make a variable named CoolDown(itemnamehere) for each item.
Make a broadcast called 'Item Used' and make it be broadcasted when the item is used.
Make a broadcast called 'Enemy Attacked' and have it be activated when the enemy attacks.

Let's have an example of an item called 'default item'.

Make these scripts on the sprite:

[blocks]<when green flag clicked>
<set{ CoolDowndefaultitem }to( 0

<when I receive[ Enemy Attacked
<change{ CoolDowndefaultitem }by( -1

<when I receive[ item used
<set{ CoolDowndefaultitem }to( 1[/blocks]

Have the weapon be selected when clicked.

[blocks]<when[ defaultitem ]clicked>
<if>
<( CoolDowndefaultitem <<> 1 )>[/blocks]
(then insert script here for item)
<end>

Now have two costumes, when the item is usable, and when it is unusable.

[blocks]<when green flag clicked>
<switch to costume[ costume1
<forever>
<if>
<( cooldowndefaultitem <>> 1 )>
<switch to costume[ usable
<else>
<switch to costume[ unusable
<end>

If this doesn't work tell me.


http://i.imgur.com/gp6tZ.gif

Offline

 

#3 2010-10-23 15:05:01

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: help

This looks like it would fit better in the Requests forum.  Let me move it over there for you  smile


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#4 2010-10-23 16:04:53

CaptanAwesome
Scratcher
Registered: 2010-10-08
Posts: 21

Re: help

benjamin2 wrote:

Solution:

Make a variable named CoolDown(itemnamehere) for each item.
Make a broadcast called 'Item Used' and make it be broadcasted when the item is used.
Make a broadcast called 'Enemy Attacked' and have it be activated when the enemy attacks.

Let's have an example of an item called 'default item'.

Make these scripts on the sprite:

[blocks]<when green flag clicked>
<set{ CoolDowndefaultitem }to( 0

<when I receive[ Enemy Attacked
<change{ CoolDowndefaultitem }by( -1

<when I receive[ item used
<set{ CoolDowndefaultitem }to( 1[/blocks]

Have the weapon be selected when clicked.

[blocks]<when[ defaultitem ]clicked>
<if>
<( CoolDowndefaultitem <<> 1 )>[/blocks]
(then insert script here for item)
<end>

Now have two costumes, when the item is usable, and when it is unusable.

[blocks]<when green flag clicked>
<switch to costume[ costume1
<forever>
<if>
<( cooldowndefaultitem <>> 1 )>
<switch to costume[ usable
<else>
<switch to costume[ unusable
<end>

If this doesn't work tell me.

The one thing that might break that is each item has a diffrent cooldown time. One might be 1 and one might be 5. Woud the script still work?


Need Voices:
http://scratch.mit.edu/projects/CaptanAwesome/1519322

Offline

 

#5 2010-10-23 16:30:49

lilacfuzz101
Scratcher
Registered: 2010-05-22
Posts: 1000+

Re: help

you would probably just have to use different variables for each item. this sounds like it will be a fun game  smile


http://25.media.tumblr.com/tumblr_lzqaicLrY01r5wdo7o1_500.gif

Offline

 

#6 2010-10-23 17:19:54

CaptanAwesome
Scratcher
Registered: 2010-10-08
Posts: 21

Re: help

okay thanks!


Need Voices:
http://scratch.mit.edu/projects/CaptanAwesome/1519322

Offline

 

#7 2010-10-24 03:27:40

benjamin2
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: help

CaptanAwesome wrote:

benjamin2 wrote:

Solution:

Make a variable named CoolDown(itemnamehere) for each item.
Make a broadcast called 'Item Used' and make it be broadcasted when the item is used.
Make a broadcast called 'Enemy Attacked' and have it be activated when the enemy attacks.

Let's have an example of an item called 'default item'.

Make these scripts on the sprite:

[blocks]<when green flag clicked>
<set{ CoolDowndefaultitem }to( 0

<when I receive[ Enemy Attacked
<change{ CoolDowndefaultitem }by( -1

<when I receive[ item used
<set{ CoolDowndefaultitem }to( 1[/blocks]

Have the weapon be selected when clicked.

[blocks]<when[ defaultitem ]clicked>
<if>
<( CoolDowndefaultitem <<> 1 )>[/blocks]
(then insert script here for item)
<end>

Now have two costumes, when the item is usable, and when it is unusable.

[blocks]<when green flag clicked>
<switch to costume[ costume1
<forever>
<if>
<( cooldowndefaultitem <>> 1 )>
<switch to costume[ usable
<else>
<switch to costume[ unusable
<end>

If this doesn't work tell me.

The one thing that might break that is each item has a diffrent cooldown time. One might be 1 and one might be 5. Woud the script still work?

Just change the numbers marked in red.  smile

Last edited by benjamin2 (2010-10-24 03:28:09)


http://i.imgur.com/gp6tZ.gif

Offline

 

Board footer