Skip to content

Commit adca37b

Browse files
committed
Convert some of the "Scripting" section pages to markdown
this was done automatically with pandoc, page formatting may still be broken in some parts
1 parent c0994c5 commit adca37b

15 files changed

+3065
-2413
lines changed

docs/scripting/basic-scripting.md

Lines changed: 228 additions & 171 deletions
Large diffs are not rendered by default.

docs/scripting/functions.md

Lines changed: 73 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,116 @@
1-
== Why would a function be useful? ==
1+
## Why would a function be useful?
22

3-
A function is mainly a chunk of code that either is used for multiple actions of the same item, or a simple way to check the status of something. This eliminates lots of code from the main script and makes it a bit cleaner for you to see and debug.
3+
A function is mainly a chunk of code that either is used for multiple actions of the same item, or a simple way to check
4+
the status of something. This eliminates lots of code from the main script and makes it a bit cleaner for you to see and
5+
debug.
46

5-
== Creating a Function ==
7+
## Creating a Function
68

7-
In order to create a function, you can do one of many things. Many scripters place their functions in 1 of 2 locations. I, myself, place my functions in a functions.txt script file and load that independently. By doing this, you can organize your functions and keep all your other scripts clean and free of clutter. Another method is to simply place them inside the script itself, however, I find this to lengthen the script quite a bit, and makes it complicated to find where the function is located in case another script file is calling it.
9+
In order to create a function, you can do one of many things. Many scripters place their functions in 1 of 2 locations.
10+
I, myself, place my functions in a functions.txt script file and load that independently. By doing this, you can
11+
organize your functions and keep all your other scripts clean and free of clutter. Another method is to simply place
12+
them inside the script itself, however, I find this to lengthen the script quite a bit, and makes it complicated to find
13+
where the function is located in case another script file is calling it.
814

9-
<pre>function(TAB)script(TAB)name(TAB){
10-
// code
11-
}</pre>
12-
13-
14-
== The RETURN Command ==
15+
function(TAB)script(TAB)name(TAB){
16+
// code
17+
}
1518

16-
Sometimes it's necessary to send back information that you retrieved from your function. Such as a TRUE/FALSE 0/1 response, or sometimes even more. In order to do this, your function needs a return statement.
19+
## The RETURN Command
1720

18-
<pre>return <Value>;
19-
return <Variable>;</pre>
21+
Sometimes it's necessary to send back information that you retrieved from your function. Such as a TRUE/FALSE 0/1
22+
response, or sometimes even more. In order to do this, your function needs a return statement.
2023

24+
return <Value>;
25+
return <Variable>;
2126

22-
== Calling a Function ==
27+
## Calling a Function
2328

2429
There are a few ways to call functions, depends on what information you are retrieving.
2530

26-
<pre>callfunc "MyFunction";</pre> // Simply calls the function that does not use a RETURN command
31+
callfunc "MyFunction";
2732

28-
=== Using Arguments in a Function ===
33+
// Simply calls the function that does not use a RETURN command
2934

30-
Sometimes it's helpful to pass variables or values to a function in order to retrieve the information that you would like. These values are called arguments. Many people use these in order to make calculations.
35+
### Using Arguments in a Function
3136

32-
==== The Function ====
37+
Sometimes it's helpful to pass variables or values to a function in order to retrieve the information that you would
38+
like. These values are called arguments. Many people use these in order to make calculations.
3339

34-
<pre>function(TAB)script(TAB)calc(TAB){
35-
set @a, getarg(0) + getarg(1);
36-
return @a;
37-
}</pre>
40+
#### The Function
3841

42+
function(TAB)script(TAB)calc(TAB){
43+
set @a, getarg(0) + getarg(1);
44+
return @a;
45+
}
46+
47+
#### Calling the Function
3948

40-
==== Calling the Function ====
49+
set @a, callfunc("calc",1,2)
50+
mes @a;
4151

42-
<pre>set @a, callfunc("calc",1,2)
43-
mes @a;</pre>
52+
#### The Result/Return
4453

45-
==== The Result/Return ====
54+
3
4655

47-
<pre>3</pre>
56+
#### Passing Arrays as Arguments
4857

49-
==== Passing Arrays as Arguments ====
58+
Calling the Function:
5059

51-
Calling the Function:
52-
<pre>callfunc "calc", MyArrayName;</pre>
60+
callfunc "calc", MyArrayName;
5361

5462
The Function:
55-
<pre>function(TAB)script(TAB)calc(TAB){
56-
getelementofarray(getarg(0), 1);
57-
}
58-
</pre>
5963

60-
* Please note, that npc variable arrays will not function in the same manner (this will be updated at a later date)
64+
function(TAB)script(TAB)calc(TAB){
65+
getelementofarray(getarg(0), 1);
66+
}
67+
68+
- Please note, that npc variable arrays will not function in the same manner (this will be updated at a later date)
6169

62-
==== Calling Function as a Script Command ====
70+
#### Calling Function as a Script Command
6371

64-
<pre>
65-
prontera,150,150,5<TAB>script<TAB>Calculator<TAB>999,{
72+
prontera,150,150,5<TAB>script<TAB>Calculator<TAB>999,{
6673

67-
function<TAB>Add<TAB>{
68-
return (getarg(0)+getarg(1));
69-
}
74+
function<TAB>Add<TAB>{
75+
return (getarg(0)+getarg(1));
76+
}
7077

71-
mes Add(1,2);
72-
}
73-
</pre>
78+
mes Add(1,2);
79+
}
7480

75-
=== Special Notes ===
81+
### Special Notes
7682

7783
Variables are passed to functions by reference
7884

7985
This means that you can do normal variable operations on a variable reference returned by getarg.
8086

8187
Ex:
8288

83-
<pre>function<tab>script<tab>F_Increment<tab>-1,{
84-
// getarg(0) returns a reference to the .@num variable in NPC_Test
85-
// NOTE: you can't use .@num directly, it's a different variable from the .@num in NPC_Test
86-
set getarg(0), getarg(0) + 1;
87-
return;
88-
}
89-
90-
prontera,156,156,4<tab>script<tab>NPC_Test<tab>56,{
91-
// initial number
92-
set .@num, 123;
93-
mes .@num;
94-
95-
// increment inside the function
96-
callfunc("F_Increment", .@num);
97-
mes .@num;
98-
99-
close;
100-
}</pre>
89+
function<tab>script<tab>F_Increment<tab>-1,{
90+
// getarg(0) returns a reference to the .@num variable in NPC_Test
91+
// NOTE: you can't use .@num directly, it's a different variable from the .@num in NPC_Test
92+
set getarg(0), getarg(0) + 1;
93+
return;
94+
}
95+
96+
prontera,156,156,4<tab>script<tab>NPC_Test<tab>56,{
97+
// initial number
98+
set .@num, 123;
99+
mes .@num;
100+
101+
// increment inside the function
102+
callfunc("F_Increment", .@num);
103+
mes .@num;
104+
105+
close;
106+
}
101107

102108
Operators always return values, so this would provoke an error on the set inside F_Increment:
103109

104-
<pre>callfunc("F_Increment", .@num + 1);</pre>
110+
callfunc("F_Increment", .@num + 1);
105111

106112
It's important to note the difference between the reference of the variable and the value of the variable:
107113

108-
* ''reference'' : the variable itself. It knows it's name, value and index. The type of variable is determined from the name.
109-
* ''value'': the value of the variable (string or number).
114+
- *reference* : the variable itself. It knows it's name, value and index. The type of variable is determined from the
115+
name.
116+
- *value*: the value of the variable (string or number).

docs/scripting/index.md

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,71 @@
11
# Scripting
22

3-
All pages that specifically related to the '''Scripting''' goes in this Category Page.
3+
All pages that specifically related to the **Scripting** goes in this Category Page.
44

5-
Articles will cover the following topics Map Flags, Permanent Monster Spawns, Non Playable Characters, Warp Points, Shops, and Functions.
5+
Articles will cover the following topics Map Flags, Permanent Monster Spawns, Non Playable Characters, Warp Points,
6+
Shops, and Functions.
67

7-
All articles related to scripting can be found alphabetically [[:Category:Scripting]]
8+
All articles related to scripting can be found alphabetically [:Category:Scripting](:Category:Scripting "wikilink")
89

10+
## General
911

10-
== General ==
1112
Articles in this category are mainly written to create or improve your foundations on Scripting.
1213

1314
More Information:
14-
* [[Adding_a_Script|[Tutorial] Add a Script]]
15-
* [[Basic_Scripting|[Tutorial] NPC Scripting (Basics)]]
16-
* [[Overview_of_Errors|NPC Errors]]
17-
* [[Tips_and_Tricks_(Scripting)|Tips and Tricks]]
1815

19-
== Map Flags ==
20-
A Map Flag describes restriction, property, and behavior of a certain map. The map flags alter the behavior of the map regarding teleporting, storing location when disconnected, dead branch usage, penalties upon death, PVP behavior, WoE behavior, ability to use skills or open up trade deals ,current weather effects, and whether day/night will be in effect on this map. Articles about Map Flags are placed under this category...
16+
- \[\[Adding_a_Script\|\[Tutorial\] Add a Script\]\]
17+
- \[\[Basic_Scripting\|\[Tutorial\] NPC Scripting (Basics)\]\]
18+
- [NPC Errors](Overview_of_Errors "wikilink")
19+
- [Tips and Tricks](Tips_and_Tricks_(Scripting) "wikilink")
2120

22-
Read more at [[Mapflag|Map Flags]]
21+
## Map Flags
22+
23+
A Map Flag describes restriction, property, and behavior of a certain map. The map flags alter the behavior of the map
24+
regarding teleporting, storing location when disconnected, dead branch usage, penalties upon death, PVP behavior, WoE
25+
behavior, ability to use skills or open up trade deals ,current weather effects, and whether day/night will be in effect
26+
on this map. Articles about Map Flags are placed under this category...
27+
28+
Read more at [Map Flags](Mapflag "wikilink")
29+
30+
## Monster Spawns
2331

24-
== Monster Spawns ==
2532
In Depth articles that are related to Monster Spawns can be found under this category.
2633

27-
* [[Permanent_Monster_Spawn|Permanent Monster Spawns]]
34+
- [Permanent Monster Spawns](Permanent_Monster_Spawn "wikilink")
35+
36+
## Non Playable Character
2837

29-
== Non Playable Character ==
3038
In Depth articles that are related to NPC Scripting can all be found under this category.
3139

3240
More Information
33-
* [[Loops|NPC Loops]]
34-
* [[Timers (Scripting)|NPC Timers]]
35-
* [[Variables|NPC Variables]]
36-
* [[Menus|NPC Menus]]
3741

38-
== Warp Points ==
42+
- [NPC Loops](Loops "wikilink")
43+
- [NPC Timers](Timers_(Scripting) "wikilink")
44+
- [NPC Variables](Variables "wikilink")
45+
- [NPC Menus](Menus "wikilink")
46+
47+
## Warp Points
48+
3949
In Depth articles related to Warp Points are listed in this category
40-
* [[Defining_Warp_Points|Defining a warp point]]
4150

42-
== Shops ==
51+
- [Defining a warp point](Defining_Warp_Points "wikilink")
52+
53+
## Shops
54+
4355
Articles about Shops and Cash Shops are placed under this category.
44-
* [[General Shop creation]]
4556

46-
== Functions ==
57+
- [General Shop creation](General_Shop_creation "wikilink")
58+
59+
## Functions
60+
4761
In Depth articles that are related to Functions can all be found under this category.
48-
* [[Functions|How functions work]]
49-
* [[WoE|Functions used in WoE]]
5062

51-
== Help Expand This Section ==
63+
- [How functions work](Functions "wikilink")
64+
- [Functions used in WoE](WoE "wikilink")
65+
66+
## Help Expand This Section
67+
5268
Help minimize the broadness of Scripting by helping create or expand the following pages
5369

54-
* [[Basic Scripting]]
55-
* [[Binaries|Binary Variable System]]
70+
- [Basic Scripting](Basic_Scripting "wikilink")
71+
- [Binary Variable System](Binaries "wikilink")

0 commit comments

Comments
 (0)