This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
door_scripting_tutorial [2017/11/03 14:59] – justin | door_scripting_tutorial [2017/11/04 11:22] (current) – justin | ||
---|---|---|---|
Line 6: | Line 6: | ||
=====Creating the Model===== | =====Creating the Model===== | ||
- | You'll first need to build a [[voxel]] model for your door. Create a new [[object]] in the [[Voxel Editor]] and build a door model similar to one of those shown in the examples below. For this tutorial, you'll want to have at least two separate frames, one for the door in its closed state and one in its open state. | + | You'll first need to build a [[voxel]] model for your door. Create a new [[object]] in the [[Voxel Editor]] and build a door model similar to one of those shown in the examples below. For this tutorial, you'll want to have at least two separate frames, one for the door in its closed state and one in its open state. Most of the examples in this tutorial will be be based on the first type of door shown. |
The style, orientation, | The style, orientation, | ||
Line 22: | Line 22: | ||
{{: | {{: | ||
- | |||
- | {{: | ||
=====Scripting the Door for One-Time Use===== | =====Scripting the Door for One-Time Use===== | ||
Line 37: | Line 35: | ||
</ | </ | ||
- | The [[quick script]] will play the " | + | The [[quick script]] will play the " |
If you'd prefer, you can also create a visual [[script]] in the [[Script Editor]] and assign it to the door instead of a [[quick script]]. This method of creating the [[script]] as its own file can be useful in cases where it's generic enough to be reusable (i.e. no explicit entity IDs are referenced). | If you'd prefer, you can also create a visual [[script]] in the [[Script Editor]] and assign it to the door instead of a [[quick script]]. This method of creating the [[script]] as its own file can be useful in cases where it's generic enough to be reusable (i.e. no explicit entity IDs are referenced). | ||
Line 44: | Line 42: | ||
====Method 2: Modify Navigation==== | ====Method 2: Modify Navigation==== | ||
- | (Explain method using [[Modify Navigation]] function. | + | Alternatively, |
{{: | {{: | ||
+ | |||
+ | This version of the [[script]] is very similar to the first one, with the exception of calling the [[Modify Navigation]] function to explicity modify each " | ||
<code lua> | <code lua> | ||
Line 59: | Line 59: | ||
=====Allowing the Door to Be Toggled===== | =====Allowing the Door to Be Toggled===== | ||
- | * Script | + | The previous [[script|scripts]] work fine for some cases, but most of the time you probably wouldn' |
- | * Using "Save as Script" to save the quick script | + | |
+ | The key to this functionality is maintaining the state of the door in an entity property | ||
+ | |||
+ | The new versions of the [[script|scripts]] are very similar to the previous ones except there is now a second set of events that can occur to " | ||
====Method 1: Replace Navigation==== | ====Method 1: Replace Navigation==== | ||
+ | The improved version of the [[script]] using the [[Replace Navigation]] method is fairly straightforward. We simply swap the navigation types between " | ||
<code lua> | <code lua> | ||
if self.property[" | if self.property[" | ||
Line 76: | Line 80: | ||
end | end | ||
</ | </ | ||
+ | |||
+ | {{: | ||
====Method 2: Modify Navigation==== | ====Method 2: Modify Navigation==== | ||
+ | For the improved version using the [[Modify Navigation]] method, let's assume we are using a different type of door that swings open, as shown in the image below. In the [[script]], the navigation between " | ||
+ | |||
{{: | {{: | ||
<code lua> | <code lua> | ||
Line 95: | Line 103: | ||
</ | </ | ||
- | There are often multiple methods to accomplish the same functionality and there isn't necessarily a right or wrong way. As with many other concepts, the best way to learn is to experiment with different setups and determine what works best for you and the particular game that you're creating. | + | Scripting [[object|objects]] like doors is a great way to learn more about the RPG in a Box [[script_syntax|scripting language]]. |