Debian Codegraph @

doc/scripts/game.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head>
3 <!--
4 ---- (c) Copyright 2002-2010 by Lutz Sammer, Russell Smith
5
6 ---- This program is free software; you can redistribute it and/or modify
7 ---- it under the terms of the GNU General Public License as published by
8 ---- the Free Software Foundation; only version 2 of the License.
9 ----
10 ---- This program is distributed in the hope that it will be useful,
11 ---- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ---- GNU General Public License for more details.
14 ----
15 ---- You should have received a copy of the GNU General Public License
16 ---- along with this program; if not, write to the Free Software
17 ---- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 ---- 02111-1307, USA.
19 -->
20 <title>Bos Wars Scripting API: Game</title>
21 <meta http-equiv="Content-Type" content="text/html; CHARSET=iso-8859-1">
22 <link rel="stylesheet" type="text/css" href="scripts.css">
23 </head>
24 <body>
25 <h1>Bos Wars Scripting API: Game</h1>
26 <hr>
27 <a href="../index.html">Bos Wars</a>
28 <a href="../faq.html">FAQ</a>
29 <a href="editor.html">PREV</a>
30 <a href="magic.html">NEXT</a>
31 <a href="index.html">LUA Index</a>
32 <hr>
33 <a href="#AddMessage">AddMessage</a>
34 <a href="#AddObjective">AddObjective</a>
35 <a href="#CenterMap">CenterMap</a>
36 <a href="#ChangeUnitsOwner">ChangeUnitsOwner</a>
37 <a href="#CreateUnit">CreateUnit</a>
38 <a href="#DefineBurningBuilding">DefineBurningBuilding</a>
39 <a href="#DefineConstruction">DefineConstruction</a>
40 <a href="#DefinePlayerColorIndex">DefinePlayerColorIndex</a>
41 <a href="#DefinePlayerColors">DefinePlayerColors</a>
42 <a href="#Diplomacy">Diplomacy</a>
43 <a href="#GetLocalPlayerName">GetLocalPlayerName</a>
44 <a href="#GetUnitVariable">GetUnitVariable</a>
45 <a href="#GetCurrentLuaPath">GetCurrentLuaPath</a>
46 <a href="#Group">Group</a>
47 <a href="#KillUnit">KillUnit</a>
48 <a href="#KillUnitAt">KillUnitAt</a>
49 <a href="#LibraryPath">LibraryPath</a>
50 <a href="#NewColors">NewColors</a>
51 <a href="#MoveUnit">MoveUnit</a>
52 <a href="#SetDiplomacy">SetDiplomacy</a>
53 <a href="#SetGamePaused">SetGamePaused</a>
54 <a href="#SetLocalPlayerName">SetLocalPlayerName</a>
55 <a href="#SetObjectives">SetObjectives</a>
56 <a href="#SetResourcesHeld">SetResourcesHeld</a>
57 <a href="#SetSharedVision">SetSharedVision</a>
58 <a href="#SetUnitVariable">SetUnitVariable</a>
59 <a href="#SharedVision">SharedVision</a>
60 <a href="#SyncRand">SyncRand</a>
61 <hr>
62 <h2>Intro - Introduction to game functions and variables</h2>
63
64 Everything around the game.
65 <h2>Functions</h2>
66
67 <a name="AddMessage"></a>
68 <h3>AddMessage(message)</h3>
69
70 Add a message to be displayed.
71
72
73 <dl>
74 <dt>message</dt>
75 <dd>Text message to display.
76 </dd>
77 </dl>
78
79 <h4>Example</h4>
80
81 <pre class="lua">
82 -- Adds the message.
83 AddMessage("This is a message")
84 </pre>
85
86 <a name="AddObjective"></a>
87 <h3>AddObjective(objective)</h3>
88
89 Add an objective to the end of the scenario objectives text list.
90
91
92 <dl>
93 <dt>objective</dt>
94 <dd>Objective text.
95 </dd>
96 </dl>
97
98 <h4>Example</h4>
99
100 <pre class="lua">
101 -- Adds the objectives "-Build a barracks" and "-Destroy all enemies"
102 -- to the end of the objectives list.
103 AddObjective("-Build a barracks")
104 AddObjective("-Destroy all enemies")
105 </pre>
106
107 <a name="CenterMap"></a>
108 <h3>CenterMap(x, y)</h3>
109
110 Center the current viewport at a certain location.
111
112
113 <dl>
114 <dt>x</dt>
115 <dd>X tile location.
116 </dd>
117 <dt>y</dt>
118 <dd>Y tile location.
119 </dd>
120 </dl>
121
122 <h4>Example</h4>
123
124 <pre class="lua">
125 -- Centers the current viewport at tile 17x40.
126 CenterMap(17, 40)
127 </pre>
128
129 <a name="ChangeUnitsOwner"></a>
130 <h3>ChangeUnitsOwner({x1, y1}, {x2, y2}, oldplayer, newplayer [,unittype])</h3>
131
132 Changes the owner of a group of units from one player to another.
133
134
135 <dl>
136 <dt>{x1, y1}</dt>
137 <dd>Upper left location for tilebox to check for units within.
138 </dd>
139 <dt>{x2, y2}</dt>
140 <dd>Lower right location for tilebox to check for units within.
141 </dd>
142 <dt>oldplayer</dt>
143 <dd>The player that currently owns the units.
144 </dd>
145 <dt>newplayer</dt>
146 <dd>The player that the units should now be owned by.
147 </dd>
148 <dt>unittype</dt>
149 <dd>Optional; change only units of this type.
150 <pre>
151 "unit-name" Unit type of this name
152 "any" Matches any unit type (default if omitted)
153 "all" All units (sum of units and buildings)
154 "units" All non building units
155 "building" All building units
156 </pre>
157 If you want some other set of unit types, then you just need to
158 call this function once for each unit type.
159 </dd>
160 </dl>
161
162 <h4>Example</h4>
163
164 <pre class="lua">
165 -- Changes the owner to player 2 for all units owned by player 3,
166 -- that are located in the area (0,0)-(10,10).
167 ChangeUnitsOwner({0, 0}, {10, 10}, 3, 2)
168
169 -- As above, but affects rocket tanks only.
170 ChangeUnitsOwner({0, 0}, {10, 10}, 3, 2, "unit-rtank")
171 </pre>
172
173 <a name="CreateUnit"></a>
174 <h3>CreateUnit(type, player, {x, y})</h3>
175
176 Create a unit at a location. If the location is occupied, the unit will be
177 placed in the closest available spot.
178
179
180 <dl>
181 <dt>type</dt>
182 <dd>Type of unit to create.
183 </dd>
184 <dt>player</dt>
185 <dd>Player number that owns the unit.
186 </dd>
187 <dt>x</dt>
188 <dd>X map tile location.
189 </dd>
190 <dt>y</dt>
191 <dd>Y map tile location.
192 </dd>
193 <dt><I>RETURNS</I></dt>
194 <dd>The slot number of the created unit.
195 </dd>
196 </dl>
197
198 <h4>Example</h4>
199
200 <pre class="lua">
201 -- Creates a footman for player 2 at location 31x34.
202 CreateUnit("unit-footman", 2, {31, 34})
203 </pre>
204
205 <a name="DefineBurningBuilding"></a>
206 <h3>DefineBurningBuilding({"percent", p, "missile", m} ...)</h3>
207
208 Define the burning animation for buildings. The animation will be laid over the building image.
209
210 <dl>
211 <dt>p</dt>
212 <dd>Hit point percentage.
213 </dd>
214 <dt>m</dt>
215 <dd>Fire missile to display.
216 </dd>
217 </dl>
218
219 <h4>Example</h4>
220
221 <pre class="lua">
222 DefineBurningBuilding(
223 {"percent", 0, "missile", "missile-big-fire"},
224 {"percent", 50, "missile", "missile-small-fire"},
225 {"percent", 75}) -- no missile
226 </pre>
227
228 <a name="DefineConstruction"></a>
229 <h3>DefineConstruction(ident, {...})</h3>
230 Defines a construction, which controls how the game draws units that
231 are being built. To make use of the construction thus defined,
232 you must also make one or more unit types refer to it;
233 see <a href="unittype.html#DefineUnitType">DefineUnitType</a>.<br>
234 <br>
235 As the unit nears completion, the game shows the frames of the
236 construction one at a time. This sequence of frames does not repeat.
237 The construction affects only the appearance of the unit, not how long
238 it takes to build. Constructions are not used for units that are
239 being trained rather than built, because those do not appear on the
240 map before they are complete.<br>
241 <br>
242 The game can load these frames from the graphics files of the unit
243 type or from separate construction-specific files: a primary file and
244 a shadow file. If you omit the shadow file, the unit will not have a
245 shadow in these frames.<br>
246 <br>
247 The construction frames should be ordered by increasing percentages and the
248 first frame should be 0.
249
250 <pre class="lua">
251 DefineConstruction(ident, {
252 Files = {
253 File = filename,
254 Size = {x, y}},
255 ShadowFile = {
256 File = filename,
257 Size = {x, y}},
258 Constructions = {{
259 percent = percent,
260 file = construction-file,
261 frame = frame-number},
262 ...}
263 })
264 </pre>
265
266 <dl>
267 <dt>ident</dt>
268 <dd>Unique name of the construction.
269 The <a href="unittype.html#DefineUnitType.Construction">Construction parameter
270 of DefineUnitType</a> refers to this.
271 </dd>
272 <dt>Files = {...}</dt>
273 <dd>The construction-specific graphic file.
274 Needed only if some construction-file is "construction".
275 Although this section is tagged "Files", you cannot specify multiple files.
276 </dd>
277 <dt>filename</dt>
278 <dd>Path of the graphic.
279 </dd>
280 <dt>x, y</dt>
281 <dd>The size of each frame in the graphic.
282 </dd>
283 <dt>ShadowFile = {...}</dt>
284 <dd>The construction-specific shadow graphic file.
285 Needed only if some construction-file is "construction"
286 and you also want shadows for those frames.
287 </dd>
288 <dt>percent</dt>
289 <dd>Percentage of construction complete.
290 </dd>
291 <dt>construction-file</dt>
292 <dd>Can be "construction" or "main", specifies which image should be displayed.
293 </dd>
294 <dt>frame-number</dt>
295 <dd>Specifies which frame number to display.
296 </dd>
297 </dl>
298
299 <h4>Example</h4>
300
301 <pre class="lua">
302 -- Defines construction-land with a construction-specific graphics file.
303 -- Buildings 0-24 percent complete use frame 0 of the construction
304 -- image, 25-49 percent complete use frame 1 of the construction image, and 50-99
305 -- percent complete use the frame 1 of the main building graphic.
306 DefineConstruction("construction-land", {
307 Files = {
308 File = "neutral/buildings/land_construction_site.png",
309 Size = {64, 64}},
310 Constructions = {{
311 Percent = 0,
312 File = "construction",
313 Frame = 0},{
314 Percent = 25,
315 File = "construction",
316 Frame = 1},{
317 Percent = 50,
318 File = "main",
319 Frame = 1}}
320 })
321 </pre>
322
323 <a name="DefinePlayerColorIndex"></a>
324 <h3>DefinePlayerColorIndex(colorstart, numcolors)</h3>
325
326 Define the graphic color indexes to be replaced by the player color.
327
328 <dl>
329 <dt>colorstart</dt>
330 <dd>Index of the first color
331 </dd>
332 <dt>numcolors</dt>
333 <dd>Total number of colors
334 </dd>
335 </dd>
336 </dl>
337
338 <h4>Example</h4>
339
340 <pre class="lua">
341 DefinePlayerColorIndex(10, 5) -- for indexes 10-14
342 </pre>
343
344 <a name="DefinePlayerColors"></a>
345 <h3>DefinePlayerColors({"color", {{R, G, B}, {R, G, B}, {R, G, B}, {R, G, B}}, ...})</h3>
346
347 Define the player colors. There should be 16 colors defined and 4 shades of each color.
348
349 <dl>
350 <dt>color</dt>
351 <dd>Name of the player color
352 </dd>
353 <dt>R, G, B</dt>
354 <dd>Red, green, blue values for each color
355 </dd>
356 </dd>
357 </dl>
358
359 <h4>Example</h4>
360
361 <pre class="lua">
362 DefinePlayerColors({
363 "red", {{164, 0, 0}, {124, 0, 0}, {92, 4, 0}, {68, 4, 0}},
364 "blue", {...},
365 ...
366 )
367 </pre>
368
369 <a name="Diplomacy"></a>
370 <h3>Diplomacy(state, enemy)</h3>
371
372 Does the same as SetDiplomacy(currentplayer, state, enemy).
373 <p>
374
375 See <a href="#SetDiplomacy">SetDiplomacy</a> for more details.
376
377
378 <a name="GetCurrentLuaPath">
379 <h3>GetCurrentLuaPath()</h3>
380
381 Returns the path of the currenly interpreted lua script.
382
383 <h4>Examples</h4>
384 <pre class="lua">
385 print(GetCurrentLuaPath())
386 Load(GetCurrentLuaPath().."unit.lua")
387 </pre>
388
389 <a name="GetLocalPlayerName"></a>
390 <h3>GetLocalPlayerName()</h3>
391
392 Returns the name of the player playing on this computer.
393 The name is used in both network games and single-player games.
394 When the engine is starting up, it chooses a default name.
395 Lua scripts can change the name by calling <a href="#SetLocalPlayerName">SetLocalPlayerName</a>.
396
397 <dl>
398 <dt><I>RETURNS</I></dt>
399 <dd>The name of the local player: either set
400 with <a href="#SetLocalPlayerName">SetLocalPlayerName</a>
401 or chosen by the engine.
402 </dd>
403 </dl>
404
405 <a name="GetUnitVariable"></a>
406 <h3>GetUnitVariable(unit, VariableName)</h3>
407
408 Get a unit's mana.
409
410 <dl>
411 <dt>unit</dt>
412 <dd>Unit to get info for.</dd>
413 <dt>VariableName</dt>
414 <dd>Name of the variable to get info for.</dd>
415 </dl>
416
417 <h4>Example</h4>
418
419 <pre class="lua">
420 -- Get mana of the unit (slot #11).
421 GetUnitMana(11, "Mana");
422 </pre>
423
424 <a name="Group"></a>
425 <h3>Group(group, quantity, {unit0, unit1, ...})</h3>
426
427 Create a group of units.
428
429
430 <dl>
431 <dt>group</dt>
432 <dd>Group number.
433 </dd>
434 <dt>quantity</dt>
435 <dd>How much units are in the group.
436 </dd>
437 <dt>unitX</dt>
438 <dd>unit slot number.
439 </dd>
440 </dl>
441
442
443 <a name="KillUnit"></a>
444 <h3>KillUnit(unit, player)</h3>
445
446 Kill a unit.
447
448 <dl>
449 <dt>unit</dt>
450 <dd><pre>
451 "unit-name" Unit type of this name
452 "any" Matches any unit type
453 "all" All units (sum of units and buildings)
454 "units" All non building units
455 "building" All building units
456 </pre></dd>
457 <dt>player</dt>
458 <dd><pre>
459 0 .. 8 Player number
460 "any" Matches any player
461 "all" All players (Not used)
462 "this" Player on the local computer, Human player in the campaign.
463 </pre></dd>
464 <dt><I>RETURNS</I></dt>
465 <dd>true if it killed one unit; false if there is no matching unit.</dd>
466 </dl>
467
468 <h4>Example</h4>
469
470 <pre class="lua">
471 -- Kills a peasant of the player on the local computer.
472 KillUnit("unit-peasant", "this");
473 </pre>
474
475 <a name="KillUnitAt"></a>
476 <h3>KillUnitAt(unit, player, quantity, location1, location2)</h3>
477
478 Kills units at a specific location.
479
480
481 <dl>
482 <dt>unit</dt>
483 <dd><pre>
484 "unit-name" Unit type of this name
485 "any" Matches any unit type
486 "all" All units (sum of units and buildings)
487 "units" All non building units
488 "building" All building units
489 </pre></dd>
490 <dt>player</dt>
491 <dd><pre>
492 0 .. 16 Player number
493 "any" Matches any player
494 "all" All players (Not used)
495 "this" Player on the local computer, Human player in the campaign.
496 </pre></dd>
497 <dt>quantity</dt>
498 <dd><pre>
499 0 ... oo Number for the quantity
500 </pre></dd>
501 <dt>location1</dt>
502 <dd><pre>
503 {x1, y1} Upper left corner
504 </pre></dd>
505 <dt>location2</dt>
506 <dd><pre>
507 {x2, y2} Lower right corner
508 </pre></dd>
509 <dt><I>RETURNS</I></dt>
510 <dd>integer: how many units it killed.</dd>
511 </dl>
512
513 <h4>Example</h4>
514
515 <pre class="lua">
516 -- Kills any units in the rectangle (5,12) to (9,15).
517 KillUnitAt("any", "any", 9, {5, 12}, {9, 15});
518 </pre>
519
520 <a name="LibraryPath"></a>
521 <h3>LibraryPath()</h3>
522
523 Returns the Bos Wars library path. The Bos Wars library path points to the game data directory.
524
525 <h4>Example</h4>
526
527 <pre class="lua">
528 path = LibraryPath()
529 </pre>
530
531 <a name="ListDirectory"></a>
532 <h3>ListDirectory(path)</h3>
533
534 Returns a list with all files and subdirectories found in the directory pointed by path.
535 If the given path starts with '~', then the path is relative to the
536 user stratagus preferences directory.
537 The path cannot include any special character.
538
539 <h4>Example</h4>
540
541 <pre class="lua">
542 list = ListDirectory("music/")
543 </pre>
544
545 <a name="ListFilesInDirectory"></a>
546 <h3>ListFilesInDirectory(path)</h3>
547
548 Returns a list with all files found in the directory pointed by path.
549 The path is relative to the game directory.
550 If the given path starts with '~', then the path is relative to the
551 stratagus' user preferences directory.
552 The path cannot include any special character.
553
554 <h4>Example</h4>
555
556 <pre class="lua">
557 list = ListFilesInDirectory("music/")
558 </pre>
559
560 <a name="ListDirsInDirectory"></a>
561 <h3>ListDirsInDirectory(path)</h3>
562
563 Returns a list with all subdirectories found in the directory pointed by path.
564 The path is relative to the game directory.
565 If the given path starts with '~', then the path is relative to the
566 user stratagus preferences directory.
567 The path cannot include any special character.
568
569 <h4>Example</h4>
570
571 <pre class="lua">
572 list = ListDirsInDirectory("music/")
573 </pre>
574
575 <a name="NewColors"></a>
576 <h3>NewColors()</h3>
577
578 Change players colors.
579
580 <h4>Example</h4>
581
582 <pre class="lua">
583 NewColors()
584 </pre>
585
586 <a name="MoveUnit"></a>
587 <h3>MoveUnit(unit-slot, {x, y})</h3>
588
589 Place a unit on map. If the location is occupied,
590 the unit will be placed in the closest available spot.
591
592
593 <dl>
594 <dt>unit-slot</dt>
595 <dd>slot number of the unit to be placed
596 </dd>
597 <dt>x</dt>
598 <dd>X map tile position.
599 </dd>
600 <dt>y</dt>
601 <dd>Y map tile position.
602 </dd>
603 </dl>
604
605 <h4>Example</h4>
606
607 <pre class="lua">
608 MoveUnit(0, {10, 12})
609 </pre>
610
611 <a name="SetDiplomacy"></a>
612 <h3>SetDiplomacy(player, state, enemy)</h3>
613
614 Alters the diplomacy setting between two players. eg enemy, allied
615
616
617 <dl>
618 <dt>player</dt>
619 <dd>Player to effect change of diplomacy on.
620 </dd>
621 </dl>
622 <dl>
623 <dt>state</dt>
624 <dd>State of relationship between players ("allied", "enemy", "neutral", "crazy").
625 </dd>
626 </dl>
627 <dl>
628 <dt>enemy</dt>
629 <dd>Other player involved in diplomacy.
630 </dd>
631 </dl>
632
633
634 <h4>Example</h4>
635
636 <pre class="lua">
637 -- Sets player 1 to be an enemy of player 0.
638 SetDiplomacy(0, "enemy", 1)
639 </pre>
640
641 <a name="SetGamePaused"></a>
642 <h3>SetGamePaused(paused)</h3>
643
644 Pause or unpause the game.
645
646
647 <dl>
648 <dt>paused</dt>
649 <dd>true for paused, false for unpaused.
650 </dd>
651 </dl>
652
653 <h4>Example</h4>
654
655 <pre class="lua">
656 -- Pauses the game.
657 SetGamePaused(true)
658 </pre>
659
660 <a name="SetLocalPlayerName"</a>
661 <h3>SetLocalPlayerName("name")</h3>
662
663 Sets the name of the player playing on this computer. Does not save
664 the name in <a href="config.html#preferences">preferences</a>; the
665 caller can do that if desired. Lua scripts can read the name back by
666 calling <a href="#GetLocalPlayerName">GetLocalPlayerName</a>.
667
668 <dl>
669 <dt>"name"</dt>
670 <dd>The name of the player, limited to 16 characters.</dd>
671 <dt><I>RETURNS</I></dt>
672 <dd>Nothing</dd>
673 </dl>
674
675 <h4>Example</h4>
676
677 <pre class="lua">
678 -- Set Player Name to mr-russ
679 SetLocalPlayerName("mr-russ")
680 </pre>
681
682 <a name="SetObjectives"></a>
683 <h3>SetObjectives({ objective, ... })</h3>
684
685 Set the mission objectives. This will overwrite any previous objectives.
686
687 <dl>
688 <dt>objective</dt>
689 <dd>Mission objective text.
690 </dd>
691 </dl>
692
693 <h4>Example</h4>
694
695 <pre class="lua">
696 -- Sets the mission objectives.
697 SetObjectives({"Build 4 farms", "Mine 500 gold"})
698 </pre>
699
700 <a name="SetSharedVision"></a>
701 <h3>SetSharedVision(player, state, opponent)</h3>
702
703 Sets shared vision.
704
705
706 <dl>
707 <dt>player</dt>
708 <dd>Player number to set shared vision.
709 </dd>
710 <dt>state</dt>
711 <dd>Use true to turn on shared vision, false to turn off.
712 </dd>
713 <dt>opponent</dt>
714 <dd>Player number to change.
715 </dd>
716 </dl>
717
718 <h4>Example</h4>
719
720 <pre class="lua">
721 -- Sets shared vision for player 0 to on with player 2.
722 SetSharedVision(0, true, 2)
723 </pre>
724
725 <a name="SetResourcesHeld"></a>
726 <h3>SetResourcesHeld(unit, resources)</h3>
727
728 Set the amount of resources available in a unit. Mostly used for harvestable resources.
729
730
731 <dl>
732 <dt>unit</dt>
733 <dd>unit identifier obtained via for example CreateUnit.
734 </dd>
735 <dt>resources</dt>
736 <dd>amount of resources held by the unit.
737 </dd>
738 </dl>
739
740 <h4>Example</h4>
741
742 <pre class="lua">
743 unit = CreateUnit("unit-crystal", {10,45})
744 SetResourcesHeld(unit, 2500)
745 </pre>
746
747 <a name="SetUnitVariable"></a>
748 <h3>SetUnitVariable(unit, VariableName, amount)</h3>
749 Set the amount of VariableName of the unit.
750 <dl>
751 <dt>unit</dt>
752 <dd>Unit to set the info for.</dd>
753 <dt>VariableName</dt>
754 <dd>Variable to set.</dd>
755 <dt>amount</dt>
756 <dd>New amount of VariableName for the unit.</dd>
757 </dl>
758
759 <h4>Example</h4>
760
761 <pre class="lua">
762 -- Set mana of the unit (slot 11)
763 SetUnitVariable(12, "Mana", 255)
764 </pre>
765
766 <a name="SharedVision"></a>
767 <h3>SharedVision(state, opponent)</h3>
768
769 Sets shared vision for the player at the computer.
770
771
772 <dl>
773 <dt>state</dt>
774 <dd>Use true to turn on shared vision, false to turn off.
775 </dd>
776 <dt>opponent</dt>
777 <dd>Player number to change.
778 </dd>
779 </dl>
780
781 <h4>Example</h4>
782
783 <pre class="lua">
784 -- Sets shared vision on with player number 3.
785 SharedVision(true, 3)
786 </pre>
787
788 <a name="SyncRand"></a>
789 <h3>SyncRand(number)</h3>
790
791 Get a value from the Stratagus syncronized random number generator.
792 Used to allow the AI to make syncronized choices with multiplayer, and
793 during replays.
794
795 <dl>
796 <dt>number<dt>
797 <dd>Number to create random from, eg 10</dd>
798 <dt><i>RETURNS</i></dt>
799 <dd>the number randomly generated, eg 0-9 for input 10.</dd>
800 </dl>
801
802 <h4>Example</h4>
803
804 <pre class="lua">
805 if(SyncRand(10) &lt; 5) then
806 -- Do this
807 else
808 -- Do that
809 end
810 </pre>
811
812
813 <hr>
814 All trademarks and copyrights on this page are owned by their respective owners.
815 <address>(c) 2002-2007 by <a href="http://boswars.org">
816 The Bos Wars Project</a></address></body></html>