Scripting: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:


==Custom Variables==
==Custom Variables==
[[Gamevar|Variables]] were introduced in EDuke 2.0 and remain the most important aspect of the new commandset.  Variables allow you to store values, manipulate values, and execute code based on these values.  Prior to custom variables, the only usable variables available were manipulations of inventory item counters and were very limited.
[[Gamevar|Variables]] were introduced in EDuke 2.0 and remain the most important aspect of the new commandset.  Variables allow you to store, manipulate, and execute code based on defined values.  Prior to custom variables, the only usable alternatives were manipulations of inventory item counters and were, as you can imagine, very limited.


There are three types of custom variables, each type storing a signed, 32-bit fixed-point integer.
There are three types of custom variables, each type storing a signed, 32-bit fixed-point integer.
* Global variables. A global variable will be the same for any actor it is used in. Changing a global variable changes it for all actors in the game.  
* Global variable: A global variable will be the same for any actor it is used in. Changing a global variable changes it for all actors in the game.  
* Per-player variables. A per-player variable may be set independently for each player in the game.  If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action.  If an actor changes a per-player variable, it will change for the closest player to the actor that changed it.
* Per-player variable: A per-player variable may be set independently for each player in the game.  If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action.  If an actor changes a per-player variable, it will change for the closest player to the actor that changed it.
* Per-actor variables.  A per-actor variable may be independently assigned to each copy of an actor in the game.
* Per-actor variable: A per-actor variable may be independently assigned to each copy of an actor in the game.


==Events==
==Events==


EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings.  As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens.  Events in the game are triggered internally whenever a certain point in the code is reached.
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings.  As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section.  As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens.  Events in the game are triggered internally whenever a certain point in the code is reached.
 
Events are a key component in the manipulation of the game.  Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.


==Members of the game structures==
==Members of the game structures==


==Drawing commands==
==Drawing commands==

Revision as of 20:10, 6 September 2005

About this Guide

This guide assume that you are familiar with the original CON code from DN3D v1.3d-1.5. If you are not already familiar with the default commands, the authors of this guide recommend the following guides to the basics:

This guide will get you started with the basic aspects of EDuke32's commands which set it apart from vanilla DN3D. This guide assumes that the reader has little to no experience with any programming language outside of the CON language.

Custom Variables

Variables were introduced in EDuke 2.0 and remain the most important aspect of the new commandset. Variables allow you to store, manipulate, and execute code based on defined values. Prior to custom variables, the only usable alternatives were manipulations of inventory item counters and were, as you can imagine, very limited.

There are three types of custom variables, each type storing a signed, 32-bit fixed-point integer.

  • Global variable: A global variable will be the same for any actor it is used in. Changing a global variable changes it for all actors in the game.
  • Per-player variable: A per-player variable may be set independently for each player in the game. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor that changed it.
  • Per-actor variable: A per-actor variable may be independently assigned to each copy of an actor in the game.

Events

EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an event is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.

Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.

Members of the game structures

Drawing commands