Okay, so, seeing as I'm a mediocre programmer at best, I've been working at scripting a bit; mostly looking at other peoples' projects and analyzing the code. I'm kind of puzzled by these two Operator blocks, though:
(join [hello] [world])
(( ) mod ( ))I just want to know how they can be used, and how they work / what they do. I've seen them in a lot of complicated scripts, so I'll bet that they're worth their code.
Offline
Join adds the 2 strings.
So,
when gf clicked ask [what's your name?] and wait say (join [hello,] (answer))Would have the sprite say the answer.
((28) mod (9))gives 1.
Last edited by berberberber (2012-08-12 22:34:42)
Offline
berberberber wrote:
Join adds the 2 strings.
So,when gf clicked ask [what's your name?] and wait say (join [hello,] (answer))Would have the sprite say the answer.
Modulo, or mod, gives the remainder of the 1st number divided by the second.
So,((28) mod (9))gives 1.
I don't quite understand what you mean for the mod block. Isn't that the same as the division block?
Offline
No, it gives the remainder.
((28) / (9))gives 3, the answer.
((28) mod (9))gives 1, the remainder.
Last edited by berberberber (2012-08-12 22:42:46)
Offline
The join block, joins to strings together. I use it a lot in Scanning stuff. Here's an example of a use: you have a picture with black squares and white squares (like those things you scan everywhere with your iPhone). You want to be able to save it in data. So, you say that black=1 and white=0. So you set it up so that it would move 1 pixel, sense if it's touching black or white, and record it. Well, how do you record it? You have a variable and you add this script:
if <touching color [#FFFFFF]?> set [var v] to <join (var) [0]> else set [var v] to <join (var) [1]> endthat way it would take the stored value it has, let's say it's 10010101, and add either 1: 100101011, or 0: 100101010. You would be able to do that another way, but this way is more understandable.
set [score v] to <join (actualscore) [%]>For the
<()mod()>block, it's like the
<()/()>block, but instead of reporting the answer, it reports the remainder.
set [direction v] to <(directionvar)mod(360)>That way, if direction ever get's below or above 360, it'll set it to it's right spot in 0-360.
Last edited by TorbyFork234 (2012-08-12 22:52:20)
Offline
Sorry to bump a (somewhat) old topic, but I found another one that's puzzling:
round ( )When I tested it out by making a script like this:
when gf clicked say (round (10))...all it said was the number 10, so apparently, no calculations were made. I've tried it with other numbers, too.
Offline
Zangooser wrote:
Sorry to bump a (somewhat) old topic, but I found another one that's puzzling:
round ( )When I tested it out by making a script like this:when gf clicked say (round (10))...all it said was the number 10, so apparently, no calculations were made. I've tried it with other numbers, too.
What's it for?
rounding a decimal
round (5.2) = 5
round(5.7) = 6
Offline
It rounds the number.
So,
say (round (8.7))would actually say 9.
Offline
Zangooser wrote:
berberberber wrote:
It rounds the number.
So,say (round (8.7))would actually say 9.Oh. Thanks, ber! The names of the blocks are just so vague, it's hard to tell what they stand for. XP
if you right click a block and select "Help" there will be a blurb describing the block (if you didnt know)
Offline