hi,
I am very new to Sense (Scratch) and have a little experience with VB programming, I was wondering if there is a way of adding Fubctions to Scratch / Sense i.e. if I had loads of code some of which was the same and I didn't want to rewrite or copy it everytime I wanted to use it, I could use a Function to put it in and then Call the Function when I needed it - thos would reduce the amount of scripting code in the program.
Any suggestions please, and please be gentle - I am only a beginner after all.
Thanx
Offline
Sorry I don't really get what you mean completely.
You could instead of putting lots of times in differents 'ifs', but an 'or' (found in operators) and put all the things you want it to react to in their.
Offline
Hi RedRocker227,
Thank you for your reply....I mean if I had a simple program to show a numeric power i.e 2 x 4 = 16 2 to the power 4 = 16 and then I wanted to re-run the program, I would use variables for the number and the power of, so if I wanted to reset the variables each time I used them to zero I would have to rewrite:
Set Variable1 to 0
Set Variable2 to 0
and so on
can I put that code in a Function like you would in visual basic?
Offline
Yes, creating functions is unfortunately not supported in the current version of Scratch. It's a major feature in the next release, (version 2.0) however.
http://blog.scratch.mit.edu/2011/03/scr … -your.html
Offline
EDIT: My short attention led me to not read anything else, derp. >.<
I've been experimenting with creating a project API using broadcasts and lists in order to run a function and its parameters.
However, you can do something like this:
In Sprite 1
The sprite broadcasts something and a couple of global parameters are set. You can also use lists.
In Sprite 2
This sprite recieves the broadcast and the parameters set earlier.
Last edited by Greatdane (2011-11-02 20:38:35)
Offline