Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Welcome to my tutorial. This is a hands on tutorial that teaches by taking apart and for this we are using Wizzup?'s essence miner. It may be out of date, but it's still full of scripting gold dust.
- You can find the aforemention script [URL="http://www.villavu.com/forum/showthread.php?t=34175"]here[/URL]
- We will be going top down regardless of the difficulty involved. Rather than jump around to make things easier, we shall make it hard for ourselves and more importantly make it even more clear I am a terrible person for explaining things. Luckily, just about every area of scripting has its own tutorial, so if in doubt, find a specific tutorial
- The first line is "program New;". This is line has no use at all. Instead of 'New', you can use an identifier to sort of summarise your script, but you don't need the line.
- Before we go on though, what is this identifier I mentioned! You'll come across it several times and it's really just a unique word to describe something. It has a few naming rules, but to summarise you can use letters (must start with a letter) and numbers and no spaces (people usually use _ instead of spaces). Now, as a general rule, they are useful for telling us what they are about.
- 'program' is one of many reserved identifiers. They are generally unusual enough that you won't accidentally name something the same as them, so don't worry too much about learning them for that reason.
- Now after the identifier, there is a semicolon. This is generally used to terminate a statement of some kind and generally it's easier to learn when not to use them rather than when to use them.
- Next up we have the include lines. When another script is included, the script runs as though the script was copy and pasted where the include line is. Nothing overly complicated, but it gets the job done. The path to the file is relative to the Scar's include folder, so something like 'C:\Program Files\SCAR 3.22\Includes\'.
- 'Const' is another key word. It means the next section is about declaring script constants. As the name suggest, they are values that don't change. The format for this is "identifier = value;" - note the semicolon. For example, in the script it uses "NumberOfUsers = 4;", with quite a nice identifier suggesting that you change it to however many people you plan to use the script with.
- What we now have to go onto is types. In the above example, the number 4 is used and it used as a number. There are a handful of core types, with whole numbers being integers. They are simply whole numbers.
- Next up we have strings, as shown by "VersionNumber = '2.03'". When a string is being used, it has apostrophes on either side of the data, so even though '2.03' looks like a number with 2 decimals, it is in fact a string.
- Another key word, 'Type'. Type is used when you want to make up your own type to use in the script. In the script, the first user declared type is a 'Record' - another key word. A record means that it holds a collection of data rather than just one piece.
- This leads us on to variables. Like constants, they are identifiers that hold information, however they don't have to hold the same data for the entire script like constants do. Variables are assigned a type and this dictates what kind of data they can hold - an integer variable can only hold whole numbers and if you give it anything else then it throws a "type mismatch error".
- So, back to records. After you assign an identifier to a new type and say that it's a record, you have to put down what it holds. You do this by declaring variables for the record. Variables are declared in the format "Identifier: Type;" - once more, a semicolon. There can also be multiple identifiers declared at the same time using a comma to separate them, but they must be the same type - for example, "NumberOfEssMined, NumberOfLoads: Integer;". The format for declaring records is "Identifier = Record" - notice the lack of a semicolon and the similarity to declaring a constant.
- Now we know about strings, but what is this mentioning of an array - "Info: Array Of Array Of Integer"! Well, an array is a collection of the same type. If you would, think of a variable as box - you can put useful data in and get it out when you need to. Well, an array would then be a stack of boxes. You say which one you want to get data out of and then it's just a normal box. Declaring something as an array is as simple as preceding the type with "Array Of". You can then use "Array Of" multiple times - 2 times is often known as a "2D array" because you could physically display it as a wall of boxes with an x and y position; 3 times is then known as a "3D array" because you add a depth to the wall of boxes and so could also use a z position.
- That most likely confused you a lot, but it's my fault. Try to focus on "a variable is a box, an array is a stack of boxes" and if you still don't really get it, don't worry too much for now.
- Next up we have 'TPointArray'. Well, it is just a user declared type which is the same as "Array Of TPoint". A TPoint is then a user declared record - it has an x and y variable of type integer. It could be displayed as:
- [scar]type
- TPoint = Record
- x, y: Integer;
- End;[/scar]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement