Yup, you sure did. A simple script that full heals your health and magic when you enter the screen. See, scripting's not that hard when you start simple and work your way up from there.
The NJF Script Learning Topic
#16
Posted 30 March 2014 - 10:32 PM
#17
Posted 30 March 2014 - 11:29 PM
read zscript.txt std.txt and eventually string.txt. Go through saffith's tutorials. Slowly and don't advance until you have a firm understanding of the previous topics. Also bit mask are fun. :tard:
#18
Posted 31 March 2014 - 07:46 AM
#19
Posted 31 March 2014 - 08:06 AM
Waitframe() waits for 1 frame or 1/60th of a second. You typically put it at the end of a loop or any place you want a pause in the script. There's also Waitframes() which does have an argument and waits for multiple frames.
If you have an infinite loop without a Waitframe() anywhere in your script, it'll cause ZC to freeze, so it's pretty important to remember.
Edit: I should also mention that frames are basically ZC's smallest measurement of time, so if you want something to always be true, like a script that keeps Link's HP at max, you set it every frame.
Edited by Moosh, 31 March 2014 - 08:10 AM.
#20
Posted 31 March 2014 - 08:19 AM
#21
Posted 31 March 2014 - 08:27 AM
#22
Posted 31 March 2014 - 08:28 AM
#23
Posted 31 March 2014 - 08:30 AM
Edited by DaviAwesome, 31 March 2014 - 08:31 AM.
#24
Posted 31 March 2014 - 08:37 AM
#25
Posted 31 March 2014 - 08:41 AM
Scripts that wouldn't need a loop would be a script that only happens once or one time per 'click'; an example would be an item script that restores HP and MP, kind of like the one you made.
I could be more descriptive but I am sort of limited as to how much I type when I'm using a phone, xD. Hope this helps, and keep asking away!
Edited by DaviAwesome, 31 March 2014 - 08:42 AM.
#26
Posted 31 March 2014 - 08:46 AM
I'm going to continue reading, and will use this topic to share thoughts and questions I may have. I thank everybody who is answering my questions, even though are are mostly added for reference (I don't want to intrude on other people's valuable time), but seeing as people have taken their time to answer these questions means a lot to me and encourages me to learn more.
---------
I've taken notice that void run() is needed to run a script (or at least I think), but why not just run()? What is the significance of void? And also, why is the parenthesis blank? Is it always blank?
Edited by NewJourneysFire, 31 March 2014 - 08:47 AM.
#27
Posted 31 March 2014 - 08:54 AM
Hopefully this can help others as well with scripting if they have questions too!
#28
Posted 31 March 2014 - 09:45 AM
Everything in ZC runs frame by frame, and only one thing updates at a time. Link is updated, then enemies, one by one, then weapons, one by one... When your script is running, it holds everything else up. When a Waitframe is reached, that tells ZC the script has done all it's going to do for the frame and it should move on to other things.
Every function needs a return type. If the function doesn't actually return any data, the return type is void.I've taken notice that void run() is needed to run a script (or at least I think), but why not just run()? What is the significance of void?
No. If your script takes arguments, that's where they'll go.And also, why is the parenthesis blank? Is it always blank?
void run(int D0, int D1, int D2) // etc.
#29
Posted 31 March 2014 - 10:31 AM
Even more about what Saffith said, let's say you want to incorporate something that happens that frame this is where Waitdraw comes in() this let's the code for link, enemies, weapons, and so on run up to drawing. Any changes to these will have effect. Also only run Waitdraw() once per frame, and it only functions in actives slot. Item scripts only ffcs and the active script run for 1 frame. If you have any questions feel free too ask them here. Also take a peak at my AMA thread, link is in my signature.
#30
Posted 31 March 2014 - 11:03 AM
void FunctionName() { Link->X = 250; Link->Y = 250; } FunctionName();This script starts with defining the function called FunctionName(). This script makes Link's X and Y position to equal 250. However, then you have to call the function as I did where I wrote "FunctionName();".
You can take this a step further by having the function have something called arguments. Here is an example:
void FunctionName(int XValue, int YValue) { Link->X = XValue; Link->Y = YValue; } FunctionName(250, 250); FunctionName(79, 79); FunctionName(45, 183);In this script, I'm passing the arguments XValue and YValue. Inside the function, I am setting Link's X position to XValue and Link's Y position to YValue. Then where I call the function, I can set any values I want (as long as they are in the screen of ZC) and Link will go there. In the first one, I set Link's X position to 250 and Link's Y position to 250. In the second one, I am setting Link's X position to 79 and Link's Y position to 79. In the last one, I am setting Link's X position to 45 and Link's Y position to 183. This is the advantage of having arguments; when you call the function you can put any values you want even if it is the same function.
But now you may ask: What do you do when you do have a function that returns a value and you can't use void? Well, let's see an example:
int FunctionName(int Number1, int Number2) { return Number1 + Number 2; } FunctionName(1, 1); //This would return 2 FunctionName(2, 5); //This would return 7As you can see in the script, instead of "void" it has "int". This means that the function returns an integer. As you can see, I passed in arguments and the function returns the addition of those two numbers. I added comments (the writing after the "//") to show you how it returns the number that it is supposed to.
I hope this helps you understand better how functions with "void" and without "void" work.
Edited by DaviAwesome, 31 March 2014 - 12:18 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users