author | almikes@aol.com |
Wed, 03 Dec 2014 19:08:24 +0000 | |
changeset 423 | 0b62abc50ac3 |
parent 246 | 7b1a6c46c3b5 |
child 500 | dc66ea78b36d |
permissions | -rw-r--r-- |
84
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
1 |
#summary Libraries for writing Lua scripts in Hedgewars. |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
2 |
|
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
3 |
= Introduction = |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
4 |
|
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
5 |
Libraries in scripts in Hedgewars are lua files that are used by many scripts to add a common function, as an example the Locale library that allows scripts to translate text. The variables in these files are not exposed to the script using it but all the functions can be called. |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
6 |
|
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
7 |
To use a library you only need to add one row at the top of the script: |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
8 |
<code lang="lua"> |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
9 |
loadfile(GetDataPath() .. "Scripts/<Library Name>.lua")() |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
10 |
</code> |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
11 |
Where <Library Name> is replaced by the name. Do not forget the "()" at the end as this initialises the file. |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
12 |
|
85
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
13 |
|
84
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
14 |
= Locale = |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
15 |
|
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
16 |
This library allows you to translate string and should be used whenever a script has text. It loads the appropriate locale file and check automatically. |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
17 |
|
85
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
18 |
=== lang(text) === |
84
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
19 |
<blockquote> |
6fa418422e57
Created wiki page through web user interface.
henrik.rostedt@gmail.com
parents:
diff
changeset
|
20 |
Returns the localised string of text or if it is not found it returns text. |
85
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
21 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
22 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
23 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
24 |
= Utils = |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
25 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
26 |
This library includes miscellaneous functions to use, they are all independent of each other and can be used everywhere. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
27 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
28 |
=== gearIsInBox(gear, x, y, w, h) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
29 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
30 |
Returns whether the gear is inside (centre point of the gear) a box with x and y as the top left corner and having the width and height of w and h respectively. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
31 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
32 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
33 |
=== gearIsInCircle(gear, x, y, r, useRadius) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
34 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
35 |
Returns whether the gear is inside a circle with x and y being the centre point and r being the radius of the circle. The boolean useRadius determine whether only the centre point of the gear will be used or the radius of the gear will be checked too. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
36 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
37 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
38 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
39 |
= Tracker = |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
40 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
41 |
This library is intended to be used if you need to keep track of gears. It can also keep track of teams and clans and as an extra functionality it can also store variables for a gear, team or clan. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
42 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
43 |
To set it up you need to add some hooks in different events. The hooks trackGear and trackDeletion to onGearAdd and onGearDelete respectively. It is strongly recommended to only track the gears you are interested in as, especially with snow on, the amount of gears can go up high and that will slow down the script. To keep track of teams you need to keep track of gtHedgehog and gtResurrector (if resurrection might be used) and add trackTeams to onGameStart. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
44 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
45 |
If you want to call a function on a couple of gears you will have to call the "runOn" functions. To these you will pass the function you want to be run as a variable to the function. The function must take a gear as a parameter, nothing else, for example: |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
46 |
<code lang="lua"> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
47 |
function killall(gear) |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
48 |
SetHealth(gear, 0) |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
49 |
end |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
50 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
51 |
function onGearDelete(gear) |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
52 |
if GetGearType(gear) == gtTarget then |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
53 |
runOnHogs(killall) |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
54 |
end |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
55 |
end |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
56 |
</code> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
57 |
This will kill all hogs if a target is destroyed. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
58 |
|
103
023ff3c709ac
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
86
diff
changeset
|
59 |
To see a commented example of the tracker in use by a script you can look at |
023ff3c709ac
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
86
diff
changeset
|
60 |
[http://code.google.com/p/hedgewars/source/browse/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Random Weapons] |
023ff3c709ac
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
86
diff
changeset
|
61 |
|
86 | 62 |
== Tracking functions == |
85
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
63 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
64 |
=== trackGear(gear) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
65 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
66 |
Will keep track of the gear. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
67 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
68 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
69 |
=== trackDeletion(gear) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
70 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
71 |
Will stop keeping track of the gear (gears not tracked will be ignored). |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
72 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
73 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
74 |
=== trackTeams() === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
75 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
76 |
Will start the tracking of teams, clans and hedgehogs (hogs can be tracked without this). |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
77 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
78 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
79 |
== "runOn" functions == |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
80 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
81 |
=== runOnGears(func) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
82 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
83 |
Runs the function func on all gears. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
84 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
85 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
86 |
=== runOnHogs(func) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
87 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
88 |
Runs the function func on all hedgehogs. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
89 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
90 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
91 |
=== runOnHogsInTeam(func, team) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
92 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
93 |
Runs the function func on all hedgehogs in the specified team. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
94 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
95 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
96 |
=== runOnHogsInOtherTeams(func, team) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
97 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
98 |
Runs the function func on all hedgehogs but those in the specified team. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
99 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
100 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
101 |
=== runOnHogsInClan(func, clan) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
102 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
103 |
Runs the function func on all hedgehogs in the specified clan. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
104 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
105 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
106 |
=== runOnHogsInOtherClans(func, clan) === |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
107 |
<blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
108 |
Runs the function func on all hedgehogs but those in the specified clan. |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
109 |
</blockquote> |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
110 |
|
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
111 |
== Variable functions == |
9f1d2d3db844
Edited wiki page LuaLibraries through web user interface.
henrik.rostedt@gmail.com
parents:
84
diff
changeset
|
112 |
|
246
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
113 |
to be continued... |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
114 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
115 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
116 |
= Animate = |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
117 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
118 |
This library provides functions that aid cinematic/cut-scene creation and functions for handling events. |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
119 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
120 |
In order to use it's full potential, the following lines need to be at the beginning of onGameTick. |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
121 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
122 |
<code lang="lua">function onGameTick() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
123 |
!AnimUnWait() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
124 |
if !ShowAnimation() == false then |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
125 |
return |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
126 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
127 |
!ExecuteAfterAnimations() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
128 |
!CheckEvents() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
129 |
end</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
130 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
131 |
Also, !AnimInit() needs to be called in !onGameInit(). |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
132 |
Each of these functions will be explained below. |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
133 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
134 |
== Cinematic Handling == |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
135 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
136 |
=== !ShowAnimation() === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
137 |
<blockquote>Performs the current action in the cinematic and returns true if finished, otherwise false. It needs to be used in onGameTick. Cut-scenes need to be added with !AddAnim(steps).</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
138 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
139 |
=== !AddAnim(steps) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
140 |
<blockquote>Adds steps to the array of animations, where steps is a table with numbers as keys and elements of the following form. Each step is a table having the following keys: func, args, swh. |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
141 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
142 |
* _func_ is the function to be executed. It can be any function that returns false when it needs to be called again in following game ticks (e.g. !AnimMove). It can be one of the cinematic functions. |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
143 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
144 |
* _args_ is a table containing the arguments that need to be passed to the function given |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
145 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
146 |
* _swh_ is an optional boolean value that defaults to true and denotes whether the current hedgehog should be switched to the hog given as argument.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
147 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
148 |
<code lang="lua">cinem = { |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
149 |
{func = AnimSay, args = {myHog, "Snails! SNAILS!", SAY_SAY, 3000}}, |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
150 |
{func = AnimMove, args = {myhog, "Left", 2000, 0}}, |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
151 |
{func = AddCaption, swh = false, args = {"But he found no more snails..."}} |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
152 |
} |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
153 |
AddAnim(cinem)</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
154 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
155 |
=== !RemoveAnim(steps) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
156 |
<blockquote>Removes steps from the animations array.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
157 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
158 |
=== !AddSkipFunction(anim, func, args) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
159 |
<blockquote>Adds _func_ to the array of functions used to skip animations, associating it with _anim_. When the animation is skipped (see below), the function is called with _args_ as arguments.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
160 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
161 |
<code lang="lua">AddSkipFunc(cinem, SkipCinem, {})</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
162 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
163 |
=== !RemoveSkipFunction(anim) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
164 |
<blockquote> Removes the skip function associated with _anim_.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
165 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
166 |
=== !SetAnimSkip(bool) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
167 |
<blockquote> Sets the state of animation skipping to _bool_. It is useful in case the player is allowed to skip the animation.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
168 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
169 |
<code lang="lua">function onPrecise() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
170 |
if !AnimInProgress() then |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
171 |
SetAnimSkip(true) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
172 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
173 |
end</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
174 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
175 |
=== !AnimInProgress() === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
176 |
<blockquote> Returns true if a cinematic is currently taking place, false otherwise.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
177 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
178 |
=== !ExecuteAfterAnimations() === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
179 |
<blockquote> Calls the functions (added with !AddFunction) that need to be executed after the cinematic. The best location for this function call is in onGameTick.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
180 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
181 |
=== !AddFunction(element) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
182 |
<blockquote> Adds _element_ to the functions array that are to be called after the cinematic. _element_ is a table with the keys: func, args.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
183 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
184 |
<code lang="lua">AddFunction({func = AfterCinem, args = {2}})</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
185 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
186 |
=== !RemoveFunction() === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
187 |
<blockquote> Removes the first function from the aforementioned list.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
188 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
189 |
=== !AnimInit() === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
190 |
<blockquote> Initializes variables used by the other functions. Needs to be called in onGameInit.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
191 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
192 |
=== !AnimUnWait() === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
193 |
<blockquote> Decreases the wait time used by cinematics. It is best called in onGameTick</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
194 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
195 |
== Cinematic Functions == |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
196 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
197 |
=== !AnimSwitchHog(gear) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
198 |
<blockquote> Switches to _gear_ and follows it. </blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
199 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
200 |
=== !AnimWait(gear, time) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
201 |
<blockquote> Increases the wait time by _time_. _gear_ is just for compatibility with !ShowAnimation.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
202 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
203 |
=== !AnimSay(gear, text, manner, time) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
204 |
<blockquote> Calls HogSay with the first three arguments and increses the wait time by _time_.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
205 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
206 |
<code lang="lua">cinem = { |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
207 |
{func = AnimSay, args = {gear1, "You're so defensive!", SAY_SAY, 2500}}, |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
208 |
{func = AnimSay, args = {gear2, "No, I'm not!", SAY_SAY, 2000}} |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
209 |
}</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
210 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
211 |
=== !AnimSound(gear, sound, time) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
212 |
<blockquote> Plays the sound _sound_ and increases the wait time by _time_.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
213 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
214 |
=== !AnimTurn(hog, dir) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
215 |
<blockquote> Makes _hog_ face in direction _dir_, where _dir_ is either "Right" or "Left".</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
216 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
217 |
=== !AnimMove(hog, dir, x, y) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
218 |
<blockquote> Makes _hog_ move in direction _dir_ until either his horizontal coordinate is _x_ or his vertical coordinate is _y_.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
219 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
220 |
=== !AnimJump(hog, jumpType) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
221 |
<blockquote> Makes _hog_ perform a jump of type _jumpType_, where _jumpType_ is either "long", "high" or "back".</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
222 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
223 |
=== !AnimSetGearPosition(gear, x, y, fall) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
224 |
<blockquote> Sets the position of _gear_ to (x, y). If the optional argument _fall_ is not false then the gear is given a small falling velocity in order to get around exact positioning.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
225 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
226 |
=== !AnimDisappear(gear, x, y) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
227 |
<blockquote> Teleports the gear to (x, y), adding some effects at the previous position and sounds. Doesn't follow the gear.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
228 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
229 |
=== !AnimOutOfNowhere(gear, x, y) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
230 |
<blockquote> Teleports the gear to (x, y), adding effects and sounds at the final position. Follows gear.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
231 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
232 |
=== !AnimTeleportGear(gear, x, y) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
233 |
<blockquote> Teleports the gear to (x, y), adding effects and sounds both at the starting position and the final position. Follows gear.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
234 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
235 |
=== !AnimVisualGear(gear, x, y, vgType, state, critical, follow) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
236 |
<blockquote> Calls AddVisualGear with arguments second to sixth. If the optional argument _follow_ is true then the gear is followed. _gear_ is for compatibility only.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
237 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
238 |
=== !AnimCaption(gear, text, time) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
239 |
<blockquote> Adds _text_ as caption and increases wait time by _time_.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
240 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
241 |
=== !AnimCustomFunction(gear, func, args) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
242 |
<blockquote> Calls the function _func_ with _args_ as arguments. This function is useful, for instance, when the cinematic uses the position of a gear at the moment of execution. If _func_ needs to be called in following game ticks then it should return false.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
243 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
244 |
<code lang="lua">function NeedToTurn(hog1, hog2) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
245 |
if GetX(hog1) < GetX(hog2) then |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
246 |
HogTurnLeft(hog1, false) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
247 |
HogTurnLeft(hog2, true) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
248 |
else |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
249 |
HogTurnLeft(hog2, false) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
250 |
HogTurnLeft(hog1, true) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
251 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
252 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
253 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
254 |
cinem = {{func = AnimCustomFunction, args = {hog1, NeedToTurn, {hog1, hg2}}}}</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
255 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
256 |
=== !AnimInsertStepNext(step) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
257 |
<blockquote> Inserts _step_ after the current step (read: action) in the cinematic array. Useful when an action depends on variables (e.g. positoins). It can be used mostly with !AnimCustomFunction. Note: In case of multiple consecutive calls, steps need to be added in reverse order.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
258 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
259 |
<code lang="lua">function BlowHog(deadHog) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
260 |
AnimInsertStepNext({func = DeleteGear, args = {deadHog}, swh = false}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
261 |
AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog), GetY(deadHog), vgtBigExplosion, 0, true}, swh = false}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
262 |
AnimInsertStepNext({func = AnimWait, args = {deadHog, 1200}}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
263 |
AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) + 20, GetY(deadHog), vgtExplosion, 0, true}, swh = false}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
264 |
AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
265 |
AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) + 10, GetY(deadHog), vgtExplosion, 0, true}, swh = false}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
266 |
AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
267 |
AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) - 10, GetY(deadHog), vgtExplosion, 0, true}, swh = false}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
268 |
AnimInsertStepNext({func = AnimWait, args = {deadHog, 100}}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
269 |
AnimInsertStepNext({func = AnimVisualGear, args = {deadHog, GetX(deadHog) - 20, GetY(deadHog), vgtExplosion, 0, true}, swh = false}) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
270 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
271 |
cinem = {{func = AnimCustomFunction, args = {liveHog, BlowHog, {deadHog}}}}</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
272 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
273 |
== Event Handling == |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
274 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
275 |
Events are pairs of functions that are used to check for various conditions. One of them is for verification and, if it returns true, the second function is called. |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
276 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
277 |
=== !AddEvent(condFunc, condArgs, doFunc, doArgs, evType) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
278 |
<blockquote> Adds the functions _condFunc_ and _doFunc_ to the events list. They get called with the respective args (_condArgs_ and _doArgs_). _condFunc_ will get called in every game tick until it returns true or is removed. Once it returns true, doFunc is called and they are or are not removed from the list, depending on _evType_ (0 for removal, 1 for keeping). An _evType_ of 1 is useful for repeating actions (e.g. every time a hog gets damaged, do something).</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
279 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
280 |
<code lang="lua">function CheckPos() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
281 |
return GetX(myHog) > 1500 |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
282 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
283 |
function CheckAmmo() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
284 |
return GetAmmoCount(myHog, amGrenade) == 0 |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
285 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
286 |
function DoPos() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
287 |
ShowMission("Scooter", "Mover", "Nice Work", 0, 0) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
288 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
289 |
function DoAmmo() |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
290 |
AddAmmo(myHog, amGrenade, 5) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
291 |
end |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
292 |
AddEvent(CheckPos, {}, DoPos, {}, 0) -- Add event that gets removed on completion |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
293 |
AddEvent(CheckAmmo, {}, DoAmmo, {}, 1) -- Add repeating event</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
294 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
295 |
=== !AddNewEvent(condFunc, condArgs, doFunc, doArgs, evType) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
296 |
<blockquote> Does the same as !AddEvent, but first checks if the event is already in the list so that it isn't added twice.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
297 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
298 |
=== !RemoveEventFunc(cFunc, cArgs) === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
299 |
<blockquote> Removes the event(s) that have _cFunc_ as the condition checking function. If _cArgs_ is not nil then only those events get removed that have _cArgs_ as arguments for _cFunc_, too.</blockquote> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
300 |
Example: |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
301 |
<code lang="lua">AddEvent(condFunc1, condArgs1, doFunc, doArgs) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
302 |
AddEvent(condFunc1, condArgs2, doFunc, doArgs) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
303 |
AddEvent(condFunc1, condArgs2, doFunc, doArgs) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
304 |
AddEvent(condFunc2, condArgs1, doFunc, doArgs) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
305 |
AddEvent(condFunc2, condArgs2, doFunc, doArgs) |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
306 |
RemoveEventFunc(condFunc1) --Removes all three events that have condFunc1 |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
307 |
RemoveEventFunc(condFunc2, condArgs1) --Removes a single event</code> |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
308 |
|
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
309 |
=== !CheckEvents === |
7b1a6c46c3b5
Edited wiki page LuaLibraries through web user interface.
szabibibi@gmail.com
parents:
103
diff
changeset
|
310 |
<blockquote> Verifies all the condition functions in the events list and calls the respective 'action' functions if the conditions are met. If the evType of a completed event is 0 then it is removed from the list. This function is best placed in onGameTick.</blockquote> |