This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
howto:combination_lock [2017-03-20 06:41] – [How to create a combination lock using XG] skyjake | howto:combination_lock [2017-03-20 16:20] (current) – [Introduction] skyjake | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== How to create a combination lock using XG ====== | ||
+ | |||
+ | |||
+ | //Work In Progress: This tutorial is not yet complete. It is published in the hopes that it might be of use but errors and omissions should be expected --danij, 12 October 2007// | ||
+ | |||
+ | |||
+ | ===== Overview ===== | ||
+ | |||
+ | |||
+ | Chances are, you have felt somewhat limited by [[games: | ||
+ | |||
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | |||
+ | For this tutorial we will be utilizing XG to implement a combination lock. Be aware, that we will be chaining together multiple XG [[xg: | ||
+ | |||
+ | In the process, we will discuss the event-driven nature of XG and how it can be used in different ways to replicate complex mechanisms. As such, this technique may not be suitable for those new to XG. | ||
+ | |||
+ | |||
+ | ===== Concept ===== | ||
+ | |||
+ | |||
+ | As already mentioned, we are aiming to create a combination lock, which (when the right combination is entered) will open a door. Before we go any further, lets first embelish this somewhat basic concept and try to define exactly the behavior we are trying to create. | ||
+ | |||
+ | |||
+ | ==== Requirements ==== | ||
+ | |||
+ | * The player should be able to manipulate the switches of the combination lock by //using// them. | ||
+ | * Each time a switch changes state, we must check whether the current configuration activates the door. | ||
+ | |||
+ | |||
+ | ==== Features ==== | ||
+ | |||
+ | |||
+ | It would also be nice if we didn't have to create a tailored set of [[: | ||
+ | |||
+ | * Any number of switches should be supported by an individual combination lock. | ||
+ | * Any number of combination locks should be able to co-exist within the same map. | ||
+ | * We should not have to create a new set of definitions for each combination lock. | ||
+ | * The combination should be specified in the map-editor and NOT in the definition. | ||
+ | |||
+ | |||
+ | ===== Determining events ===== | ||
+ | |||
+ | /writeme | ||
+ | |||
+ | |||
+ | ===== The switches ===== | ||
+ | |||
+ | /writeme | ||
+ | |||
+ | |||
+ | ==== Definitions ==== | ||
+ | |||
+ | |||
+ | < | ||
+ | Line Type { | ||
+ | Id = 1000 | ||
+ | Comment = "Combo Lock ON Switch" | ||
+ | Class = none | ||
+ | Flags = player_use | ||
+ | Flags2 = when_act | when_deact | any | ||
+ | Type = flip | ||
+ | Count = -1 | ||
+ | Event Chain = 32767 | ||
+ | Act sound = " | ||
+ | Act tag = 1 | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Line Type { | ||
+ | Id = 1001 | ||
+ | Comment = "Combo Lock OFF Switch" | ||
+ | Class = none | ||
+ | Flags = player_use | active | ||
+ | Flags2 = when_act | when_deact | any | ||
+ | Type = flip | ||
+ | Count = -1 | ||
+ | Event Chain = 32767 | ||
+ | Act sound = " | ||
+ | Act tag = 2 | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Explanation ==== | ||
+ | |||
+ | /writeme | ||
+ | |||
+ | |||
+ | ===== The combination validator ===== | ||
+ | |||
+ | |||
+ | The final definition we need is that of the combination validator. Recall that earlier, when defining the switches we made use of the //Event Chain// paramater (**=32767**) to execute another linetype on activation/ | ||
+ | |||
+ | |||
+ | ==== Definition ==== | ||
+ | |||
+ | |||
+ | < | ||
+ | Line Type { | ||
+ | Id = 32767 | ||
+ | Comment = " | ||
+ | Act message = " | ||
+ | Flags2 = any | when_act | line_act | line_inact | ||
+ | Class = activate | ||
+ | Count = -1 | ||
+ | Line act lref = act_tagged | ||
+ | Line act lrefd = 1 | ||
+ | Line inact lref = act_tagged | ||
+ | Line inact lrefd = 2 | ||
+ | |||
+ | Ip0 = " | ||
+ | Ip1 = 7 | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Explanation ==== | ||
+ | |||
+ | |||
+ | Notice that there are no [[xg: | ||
+ | |||
+ | |||
+ | |||
+ | |||