A to Z Scripting

From The DarkMod Wiki
Revision as of 11:20, 4 February 2021 by Dragofer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Primary contributor - Dragofer

Consultant - Obsttorte


This is an all-in-one resource for scripting as a mapper in TDM. It assumes no prior knowledge of scripting and is aimed in particular at those (like myself) who prefer to learn by looking at existing examples.

The first sections up to "Practical exercise: subtly teleporting the player" are written more in the style of a beginner's guide, while later sections aim to collect everything related to scripting in one place. So the recommended usage of this resource for a beginner would be to use the initial sections to learn the basics, then gradually acquire the remaining techniques & principles whenever you need something new for what you're trying to do.


# Article Contents
1 A to Z Scripting: Anatomy of a script Learning basic script literacy by picking apart some simple scripts.
2 A to Z Scripting: More scripting basics Further basics, including how to use the TDM Script Reference.
3 A to Z Scripting: Basic maths The elemental maths needed for scripting effectively.
4 A to Z Scripting: Setting up the .script files How to add scripts to your mission or game.
5 A to Z Scripting: Ways of calling a script Using trigger brushes, objectives and many other ways to initiate scripts.
6 A to Z Scripting: Getting map information Pulling information, such as an entity's location, from the map for use in a script.
7 A to Z Scripting: Practical exercise: subtle teleportation A guided exercise in creating a wizard's tower style unnoticeable teleportation.
8 A to Z Scripting: Conditionals Making the execution of a script depend on whether conditions are met.
9 A to Z Scripting: Looping a script Various ways of continuously running a script or until a task has been completed.
10 A to Z Scripting: Scripting with... Useful things to know when writing scripts that involve i.e. AIs, sounds or timekeeping.
11 A to Z Scripting: Special methods Running a script on every entity of a certain type or in a volume, spawning entities and more.
12 A to Z Scripting: Utility scripts Writing scripts that are designed to be used like script events.
13 A to Z Scripting: Scriptobjects Creating entities with scripted behaviours.
14 A to Z Scripting: Script addons for players Modifying a player's TDM experience, i.e. by getting rid of all spiders at every map start.
15 A to Z Scripting: Troubleshooting Techniques for solving problems; commonly encountered errors.


Why script?

Mappers in TDM are fortunate to have a large selection of entities and systems, such as the objective and stim/response systems, that allow them to use scripted effects without ever writing a line. Those systems are already quite powerful, allowing for relatively complex setups.

Knowing your way around scripts, however, adds a whole new level of control. While a teleportation entity can only teleport something to a predetermined position, a script can automatically calculate the destination, what to teleport and whether to teleport.

A lot can be said about scripting, as this series shows, but as Kingsal once said, even "a little scripting goes a long way". Already the basics give you access to all kinds of new scripted effects and synergise with other systems.