123 Adds `animation` to the animation list. `animation` is a list of animation steps; see data structures above for details. |
123 Adds `animation` to the animation list. `animation` is a list of animation steps; see data structures above for details. |
124 |
124 |
125 Example: |
125 Example: |
126 <code language="lua"> |
126 <code language="lua"> |
127 -- Makes myHog say "Snails! SNAILS!, wait 3 seconds, move it to the left until its X coordinate equals 2000, then show the caption "But he found no more snails ..." |
127 -- Makes myHog say "Snails! SNAILS!, wait 3 seconds, move it to the left until its X coordinate equals 2000, then show the caption "But he found no more snails ..." |
128 cinem = { |
128 animation = { |
129 {func = AnimSay, args = {myHog, "Snails! SNAILS!", SAY_SAY, 3000}}, |
129 {func = AnimSay, args = {myHog, "Snails! SNAILS!", SAY_SAY, 3000}}, |
130 {func = AnimMove, args = {myHog, "Left", 2000, 0}}, |
130 {func = AnimMove, args = {myHog, "Left", 2000, 0}}, |
131 {func = AddCaption, swh = false, args = {"But he found no more snails ..."}} |
131 {func = AddCaption, swh = false, args = {"But he found no more snails ..."}} |
132 } |
132 } |
133 AddAnim(cinem)</code> |
133 AddAnim(animation)</code> |
134 |
134 |
135 ==== `RemoveAnim(animation)` ==== |
135 ==== `RemoveAnim(animation)` ==== |
136 Removes `animation` from the animation list. |
136 Removes `animation` from the animation list. |
137 |
137 |
138 ==== `AddSkipFunction(animation, func, args)` ==== |
138 ==== `AddSkipFunction(animation, func, args)` ==== |
139 Adds `func` to the array of functions used to skip animations, associating it with `animation`. When the animation is skipped (see below), the function is called with `args` as arguments. |
139 Adds `func` to the array of functions used to skip animations, associating it with `animation`. When the animation is skipped (see below), the function is called with `args` as arguments. |
140 Example: |
140 Example: |
141 <code language="lua">AddSkipFunc(cinem, SkipCinem, {})</code> |
141 <code language="lua">AddSkipFunc(animation, myAnimationSkipFunction, {})</code> |
142 |
142 |
143 ==== `RemoveSkipFunction(animation)` ==== |
143 ==== `RemoveSkipFunction(animation)` ==== |
144 Removes the skip function associated with `animation`. |
144 Removes the skip function associated with `animation`. |
145 |
145 |
146 ==== `SetAnimSkip(bool)` ==== |
146 ==== `SetAnimSkip(bool)` ==== |
163 |
163 |
164 ==== `AddFunction(element)` ==== |
164 ==== `AddFunction(element)` ==== |
165 Adds `element` to the functions array that are to be called after the animation. `element` is a table with the keys: `func`, `args`. |
165 Adds `element` to the functions array that are to be called after the animation. `element` is a table with the keys: `func`, `args`. |
166 |
166 |
167 Example: |
167 Example: |
168 <code language="lua">AddFunction({func = AfterCinem, args = {2}})</code> |
168 <code language="lua">AddFunction({func = myAfterAnim, args = {2}})</code> |
169 |
169 |
170 ==== `RemoveFunction()` ==== |
170 ==== `RemoveFunction()` ==== |
171 Removes the first function from the aforementioned list. |
171 Removes the first function from the aforementioned list. |
172 |
172 |
173 ==== `AnimUnWait()` ==== |
173 ==== `AnimUnWait()` ==== |
203 |
203 |
204 ==== `AnimSay(gear, text, manner, time)` ==== |
204 ==== `AnimSay(gear, text, manner, time)` ==== |
205 Calls `HogSay` with the first three arguments and increases the wait time by `time`. |
205 Calls `HogSay` with the first three arguments and increases the wait time by `time`. |
206 |
206 |
207 Example: |
207 Example: |
208 <code language="lua">cinem = { |
208 <code language="lua">animation = { |
209 {func = AnimSay, args = {gear1, "You're so defensive!", SAY_SAY, 2500}}, |
209 {func = AnimSay, args = {gear1, "You're so defensive!", SAY_SAY, 2500}}, |
210 {func = AnimSay, args = {gear2, "No, I'm not!", SAY_SAY, 2000}} |
210 {func = AnimSay, args = {gear2, "No, I'm not!", SAY_SAY, 2000}} |
211 }</code> |
211 }</code> |
212 |
212 |
213 ==== `AnimSound(gear, sound, time)` ==== |
213 ==== `AnimSound(gear, sound, time)` ==== |
214 Plays the sound `sound` and increases the wait time by `time`. |
214 Plays the sound `sound` and increases the wait time by `time`. |
215 |
215 |
216 ==== `AnimTurn(hog, dir)` ==== |
216 ==== `AnimTurn(hog, dir)` ==== |
258 HogTurnLeft(hog2, false) |
258 HogTurnLeft(hog2, false) |
259 HogTurnLeft(hog1, true) |
259 HogTurnLeft(hog1, true) |
260 end |
260 end |
261 end |
261 end |
262 |
262 |
263 cinem = {{func = AnimCustomFunction, args = {hog1, NeedToTurn, {hog1, hog2}}}}</code> |
263 animation = {{func = AnimCustomFunction, args = {hog1, NeedToTurn, {hog1, hog2}}}}</code> |
264 |
264 |
265 === Event handling === |
265 === Event handling === |
266 |
266 |
267 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. |
267 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. |
268 |
268 |