- Discussion Forums
- » Help with Scripts
- » Help? How can i make a character use a sword against a Sprite?
Colors-of-Code
11 posts
Help? How can i make a character use a sword against a Sprite?
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the
monster?
i've already done this but it doesn't work.
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]
But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
footsocktoe
1000+ posts
Help? How can i make a character use a sword against a Sprite?
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.
Colors-of-Code
11 posts
Help? How can i make a character use a sword against a Sprite?
footsocktoe wrote:
Colors-of-Code wrote:
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.
_______________________________________________________
yes that is what it is supposed it will constantly be on the loop cause there are multiple monsters. since there are at least one for each level.
deck26
1000+ posts
Help? How can i make a character use a sword against a Sprite?
Colors-of-Code wrote:
_______________________________________________________footsocktoe wrote:
Colors-of-Code wrote:
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.
yes that is what it is supposed it will constantly be on the loop cause there are multiple monsters. since there are at least one for each level.
What @footsocktoe means is it will happen 30 times a second and since you're using a broadcast the receiver script probably won't have time to complete before it is restarted. So broadcast and wait may be better and you may prefer not to let a broadcast happen for, say, a quarter second after the previous one.
Colors-of-Code
11 posts
Help? How can i make a character use a sword against a Sprite?
deck26 wrote:
What @footsocktoe means is it will happen 30 times a second and since you're using a broadcast the receiver script probably won't have time to complete before it is restarted. So broadcast and wait may be better and you may prefer not to let a broadcast happen for, say, a quarter second after the previous one.Colors-of-Code wrote:
_______________________________________________________footsocktoe wrote:
Colors-of-Code wrote:
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
It depends on what else the “hit monster” message does. Since it is in a forever loop it will be broadcast dozens of times whenever the condition is met. So take that into account.
yes that is what it is supposed it will constantly be on the loop cause there are multiple monsters. since there are at least one for each level.
____________________________________
thx very much i will try that know.
bastiaan1200
17 posts
Help? How can i make a character use a sword against a Sprite?
Script inside your guy that fights
when green flag clickedforever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
broadcast [Hit monster v] and wait
else
end
end
This should work (Tip: Dont work allot with broad cast you can do thiswith an variable to
when green flag clickedforever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
set [Hit.Monster v] to [1]
else
set [Hit.Monster v] to [0]
end
end
when green flag clicked
forever
if <(Hit.Monster) = [1]> then
change [Monsterhealth v] by (-10)
if <(Monsterhealth) < [1]> then
YOURSCRIPT
end
else
end
end
Now add an delay in and you are done!
I hope i helped you!
Last edited by bastiaan1200 (Aug. 1, 2016 14:41:20)
//scratch.mit.edu/projects/117474083/
when green flag clickedforever
[Yell v] [Bastiaan1200=Cool] Tone (100)<<::motion><::looks><::operators><::obsolete><::sound><::events><::control><::variables><::list><::custom><::grey>::pen>
Colors-of-Code
11 posts
Help? How can i make a character use a sword against a Sprite?
bastiaan1200 wrote:
Script inside your guy that fightswhen green flag clicked
forever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
broadcast [Hit monster v] and waitelse
end
end
This should work (Tip: Dont work allot with broad cast you can do thiswith an variable towhen green flag clicked
forever
if <<(distance to [Guy (not monster) v]) < [50]> and <key [Space v] pressed?>> then
set [Hit.Monster v] to [1]else
set [Hit.Monster v] to [0]end
end
when green flag clicked
forever
if <(Hit.Monster) = [1]> then
change [Monsterhealth v] by (-10)
if <(Monsterhealth) < [1]> then
YOURSCRIPT
endelse
end
end
Now add an delay in and you are done!I hope i helped you!
__________________________________
thx very much not what i was looking for exactly but what you added will go great in the game so i'm using that know thx. (i'll put everyone who helped in the comments)
hornbeef
34 posts
Help? How can i make a character use a sword against a Sprite?
Colors-of-Code wrote:
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
are you actually touching the monster when you press space?
((((((((((((lVl :: undefined) :: custom ) :: list) :: variables ) :: operators) :: sensing) :: control) :: events) :: pen) :: sound) :: looks) :: motion) // RAINBOW BLOCK!!!!!!!!!!
Colors-of-Code
11 posts
Help? How can i make a character use a sword against a Sprite?
hornbeef wrote:
are you actually touching the monster when you press space?Colors-of-Code wrote:
I'm making a dungeon explorer game and i was wondering how to make it when he picks up the sword and it goes in his inventory, and he presses space to use the sword it kills the monster?
i've already done this but it doesn't work.
when green flag clicked
forever
if <<touching [ Monster] ?> and <key [ Space] pressed?>> then
broadcast [ Hit Monster]But that didn't work. what that is supposed to do is when the flag is clicked forever it waits for Sprite 1 key space to be pressed and touching Monster that then Broadcast's Hit Monster when Monster receives Hit monster it hides but. that never works.
___________________________________________________________________________________
Thx in advance for anyone who helps.
________________________________________________________________
yes.
kuct
1 post
Help? How can i make a character use a sword against a Sprite?
Help, how do i create a script that makes when touching a sword you can use it to attack enemies! PLEEAASSE HELP!
deck26
1000+ posts
Help? How can i make a character use a sword against a Sprite?
kuct wrote:
Help, how do i create a script that makes when touching a sword you can use it to attack enemies! PLEEAASSE HELP!
If the above doesn't help please create your own topic rather than necroposting and share what you currently have.
erc122potter
1 post
Help? How can i make a character use a sword against a Sprite?
I need a lot of help! I need to make it so when you touch the sword you can use it and i need to find out how to strike with it. hope you can help me
deck26
1000+ posts
Help? How can i make a character use a sword against a Sprite?
erc122potter wrote:
I need a lot of help! I need to make it so when you touch the sword you can use it and i need to find out how to strike with it. hope you can help me
Create your own new topic rather than necroposting please and share the project.
5Proll
1 post
Help? How can i make a character use a sword against a Sprite?
i can not turn my sword horizontal way
- Discussion Forums
- » Help with Scripts
- » Help? How can i make a character use a sword against a Sprite?