I think that some people might have already found about this, but I haven't seen anybody say anything about it, so here goes.
Have you ever made a game (for example, a scroller, since in that context this script is more useful) and used sensing that involved recognizing what sprites you were touching? And since there were a lot of platforms, you had to identify each one in a really long "if (touching Sprite 1) or (touching Sprite2) or (touching Sprite3)", etc. script?
Here's a solution; make a list called IfTouching (if you want, add a number so you can make more lists with that name) and add the names of all the sprites your character will be touching. Then, you can just say "if touching (item [any] of IfTouching)" and save yourself some work and space.
Hope this helped someone!
Legolas
Offline
Good idea!
Offline
Sorry to say it doesn't quite work that well...when you say any, what it does is picks a random item, not test every single one.
Offline
AtomicBawm3 wrote:
Sorry to say it doesn't quite work that well...when you say any, what it does is picks a random item, not test every single one.
You could maybe get the terrain number then. I think the terrain number will be
(ScrollX)/[480], though I'm not sure. And then just put
<touching (item (Terrain #) of [Terrain list v]) ?>
Offline
RedRocker227 wrote:
AtomicBawm3 wrote:
Sorry to say it doesn't quite work that well...when you say any, what it does is picks a random item, not test every single one.
You could maybe get the terrain number then. I think the terrain number will be
(ScrollX)/[480], though I'm not sure. And then just put<touching (item (Terrain #) of [Terrain list v]) ?>
You might have to round it though.
Last edited by scimonster (2012-02-02 07:08:03)
Offline
There is always the "and" block though. I had to make a script like this once:
when gf clicked forever if <<(sprite 1) = [1]> and>The full script went had nine different sprites in it.
Last edited by catfan8 (2012-02-02 07:23:05)
Offline
Yes, I had a lack of foresight. However, strings can still be a useful way to remove "or" scripts.
Offline
scimonster wrote:
RedRocker227 wrote:
AtomicBawm3 wrote:
Sorry to say it doesn't quite work that well...when you say any, what it does is picks a random item, not test every single one.
You could maybe get the terrain number then. I think the terrain number will be
(ScrollX)/[480], though I'm not sure. And then just put<touching (item (Terrain #) of [Terrain list v]) ?>You might have to round it though.
Yeah. Like I said, I wasn't sure if my method was completely correct, but I knew it was something like that.
Offline
RedRocker227 wrote:
scimonster wrote:
RedRocker227 wrote:
You could maybe get the terrain number then. I think the terrain number will be
(ScrollX)/[480], though I'm not sure. And then just put<touching (item (Terrain #) of [Terrain list v]) ?>You might have to round it though.
Yeah. Like I said, I wasn't sure if my method was completely correct, but I knew it was something like that.
Your method works, but you need to round it down with the
(() mod ())block.
set [terrain number v] to (((scrollx) / [480]) - (((scrollx) / [480]) mod (1))) if <touching (item (terrain number) of [terrain list v]) ?> do stuff end
Last edited by rdococ (2012-02-04 16:58:18)
Offline
K-Jam wrote:
good idea, but since ou cant hide lists, you'll see the list and it will be ugly
Um. Click the checkbox next to the list's name. :?
Offline
Kind of on topic: You can broadcast strings too. This is very nice for platformers.
broadcast [(join ["Level "][(Level #)])]
Last edited by MoreGamesNow (2012-02-06 16:44:27)
Offline
MoreGamesNow wrote:
Kind of on topic: You can broadcast strings too. This is very nice for platformers.
broadcast (join [Level ](Level #))
Fixed script.
Last edited by scimonster (2012-02-07 05:48:37)
Offline