Pages: 1
when gf clicked set (fun times) to 10 set (herderp) to 0 set(herp) to herp set (derp) to derp repeat until <join<( herp ) (derp) > = (fun times)> say [I am performing an action.] for 1 seconds change (herpderp) by 1 endClearly I am not very good at in-post scratch blocks, but I think you can understand what I am getting at here (Please don't tell me about how I'm bad at them or tell me how to do the correct formatting for them; that's not why I made this thread). This program here does what I want it to. The program says it's phrase until herpderp gets to 10, then it stops. No big deal, right? The problem arises when you try to use characters instead of numbers.
when gf clicked set (fun times) to lulz set (herderp) to NO set(herp) to herp set (derp) to derp repeat until <join<( herp ) (derp) > = (fun times)> say [I am performing an action.] for 1 seconds end when gf clicked wait 10 seconds set herpderp to lulzNow, you would think that the program would wait be saying the phrase for 10 seconds until herpderp got set to lulz, and then the program would end. But no. It just keeps on going, because I assume it thinks that a variable with characters (a string, in other words) is just 0 when used in a number block. And 0 of course never equals lulz.
when gf clicked set (herp) to herp set (herp) to derp set (herpderp) to 5 set lulz to 10 - <join (herp) (derp)>It should be 5, right? Nope. It's 10, because a string equals 0.
when gf clicked set (Enemy 1 weapon) to fists // public string in sprite 1 when gf clicked set (my name) to Enemy 1 //private string in sprite 2 set (weapon) to weapon // private string sprite 2 if < <join (my name) (weapon) > = fists > perform x action endWhat I would like to happen is that my sprite "Enemy 1" will see that "Enemy 1 + weapon" (or, Enemy 1 weapon, a public string I declared in a different sprite) equals "fists" so that it can know to perform the intended action. But it doesn't. So again, if anyone knows how to help me that would be great. And by the way, I already read this and I didn't find it particularly helpful.
Last edited by radicalace (2012-09-28 23:44:25)
Offline
There is a way to call variables based on sprites, but it's not exactly what you're looking for because it uses local variables which can only be set inside the sprite that hosts that variable.
You could, however, use lists. Create a list called "weapon" and any other lists you need. Then the sprite you are working with depends on a single item in that list specified by the item number (i.e. Enemy 1 looks at item 1). You can then set weapons fairly easily. You can also put variables into the section where the item number is usually entered meaning you can decrease the amount of code needed.
Basically, you can do this:
replace item (Enemy #) of [weapon v] with (weapon)
Offline
AtomicBawm3 wrote:
There is a way to call variables based on sprites, but it's not exactly what you're looking for because it uses local variables which can only be set inside the sprite that hosts that variable.
You could, however, use lists. Create a list called "weapon" and any other lists you need. Then the sprite you are working with depends on a single item in that list specified by the item number (i.e. Enemy 1 looks at item 1). You can then set weapons fairly easily. You can also put variables into the section where the item number is usually entered meaning you can decrease the amount of code needed.
Basically, you can do this:replace item (Enemy #) of [weapon v] with (weapon)
Well, what I wanted to do was make it so that when I copied a enemy sprite to make another one, all I would have to do is change the declaration of "My Name" and a few other minor things, and then all the work would be done for me. However, I think I can still use that method to accomplish my goal, so I will try it.
Offline
Pages: 1