Anyway, let's get on with it, shall we?
III: Expressions
Logical expressions are often used in scripting to determine a set of rules or prerequisites for a specific event or scenario to happen. These expressions can be used to determine numerous things during gameplay, and can be regularly found in quest NPCs or anything that works around special conditions in order to operate.
Sample script:
mes "[Random Guy]"; mes "Hello there! What's your name?"; next; input .@my_name$; mes "[Random Guy]"; if (strcharinfo(0) != .@my_name$) { mes "Well, that's odd! Your nametag...hey, come back here!"; } else { mes "That's a nice name you've got there!"; } close;
Here's a situation where some fellow is asking for a player's name. Players are prompted with the input command, storing their answer in a temporary NPC string variable called .@my_name$. In the script, we present the player with a logical expression that determines whether or not they told us the truth by comparing strcharinfo(0) against .@my_name$:
if (strcharinfo(0) != .@my_name$) {
If the if expression is found to be true, the script will proceed to include the code within the curly braces { } after the expression; otherwise, it will run the code in the curly braces after else in its place. However, no matter what message is displayed, a close will be executed afterwards, as it is impartial to the condition set by the if...else expression. Note that it is not required to use else, but it is useful when substituting text or code. Before we move onto the next section, here are some things you might find useful to know:
- strcharinfo(0) returns the name of the attached player in a string format; if a player's name is Player A, the name will be returned as "Player A".
- strings are any sequence of characters (letters, numbers, and symbols) that are enclosed in quotation marks.
IV: Concatenation
In formal language theory and computer programming, string concatenation is the operation of joining two character strings end-to-end; in English, this process is commonly known as "sequencing". In *Athena scripting, concatenation is used to piece words and information together dynamically - and by dynamically, I mean with the ability to change with little or no intervention from the scripter.
Sample script:
mes "[Random Guy]"; mes "Hello there! What's your name?"; next; input .@my_name$; mes "[Random Guy]"; if (strcharinfo(0) != .@my_name$) { mes "Well, that's odd! Your nametag doesn't say "+ .@my_name$ +"!"; } else { mes "That's a nice name you've got there, "+ strcharinfo(0) +"!"; } close;
Let's use the script from earlier as an example. In order to concatenate a string, a plus sign + must trail a closing quotation mark, followed by the string you want to include. If the player input his name as Player B, .@my_name$ will be the equivalent of "Player B" - quotation marks included. Comparatively, the message in the if expression would say:
mes "Well, that's odd! Your nametag doesn't say "+ "Player A" +"!";
Think of concatenating as adding onto an existing string using variables or functions. In this example, strcharinfo(0), is being used to return the player's name as it is stored on the server; if the player's name is Player A, the function will return the string "Player A". Always keep in mind that you are concatenating strings, which must be enclosed in quotation marks to be read by the script parser properly.
Nice one , Keep it up , maybe this will reduce the ammount of " i need aTCG script for my Donations".....