Fundamental Scripting Guide

From The DarkMod Wiki
Revision as of 21:14, 13 December 2020 by Dragofer (talk | contribs) (Created page with "''Author - Dragofer'' This is a (work in progress) resource written primarily for mappers with no background in scripting or coding, though also more experienced scripters ma...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Author - Dragofer

This is a (work in progress) resource written primarily for mappers with no background in scripting or coding, though also more experienced scripters may find practical guidance in adapting to TDM's scripting system. This is the large majority of what I've picked up over the years through experimentation, looking at existing scripts and interacting with other forum members.

My aim is for the tutorial to be both comprehensive and down to earth, using many examples and avoiding unnecessary technical terms. There will be some overlap with existing wiki articles, since this aims to have everything in one place out of one hand.

The concept will be to start with teaching some basic script literacy, then introduce scripting principles one after another. Towards the end, practical examples


Contents

Anatomy of a script

Basic terms

Script functions

Rudimentary script: message to console

Basic script: simple cutscene


*More scripting basics

General

TDM Script Reference

Troubleshooting (i.e. closeup texture after mistake)


Setting up script files

Map scripts

General scripts


*How to call scripts

From other scripts

Target_callscriptfunction

Triggers

Stim/response

Frob_action_script

Objective system


Variables

Data types

Creating new variables

Example usage: puzzle with max 3 attempts


Scripts with input variables

Example useage: multiple func_movers and buttons, movement in various directions


"Get"ting information from the map

Getting spawnargs

Example usage: checking current health of an AI for an objective


Conditionals

Comparisons

Checking true or false

Multiple conditions

Chains of conditions


Looping/repeating scripts

Looping with thread

Looping with while()

Repeating with for()

Repeating with do + while()


*Scriptobjects

Applications

Setup

Entity defs


*Special methods

Going through all targets of an entity

Sounds

Trigger_touch

AI variables

Spline movers


*Practical examples