Difference between revisions of "T4modules-4emodule 1"

From Tales of Maj'Eyal
Jump to: navigation, search
(Created page with "==== 4Emodule Part 1: load.lua ==== t4modules t4modules | t4modules module howto guides In this part I will be defining the goal of this tutorial series, and start wi...")
 
(Fixed code formatting, added category)
Line 10: Line 10:
 
=== init.lua ===
 
=== init.lua ===
  
First off, open your init.lua file in your favourite text editor.
+
First off, open your init.lua file in your favorite text editor.
  
 
You will see a pretty plain default file, so lets change it to reflect the new module.
 
You will see a pretty plain default file, so lets change it to reflect the new module.
  
<code>
+
  name = "DND 4E Module"
name = "DND 4E Module"
+
  long_name = "Tutorial Module creating a DND 4E game system"
long_name = "Tutorial Module creating a DND 4E game system"
+
  short_name = "4emodule"
short_name = "4emodule"
+
  author = { "YOUR NAME", "EMAIL@PROVIDER.COM" }
author = { "YOUR NAME", "EMAIL@PROVIDER.COM" }
+
  homepage = "YOUR WEBSITE"
homepage = "http //doku.t-o-m-e.net/t4modules:module_howto_guides"
+
  version = {1,0,0}
version = {1,0,0}
+
  engine = {1,0,0}
engine = {1,0,0}
+
  description = [[t4modules  
description = [[t4modules  
+
  t-engine 4 module simulating the 4e dnd game system.
t-engine 4 module simulating the 4e dnd game system.
+
  ]]
]]
+
  starter = "mod.load"
starter = "mod.load"
+
</code>
+
  
 
And thats it.
 
And thats it.
Line 43: Line 41:
 
</code>
 
</code>
 
And where the default stats are defined, replace with the following:
 
And where the default stats are defined, replace with the following:
<code>
 
ActorStats:defineStat("Strength", "str", 10, 1, 100, "Melee basic attacks and Fortitude saves are based on Strength.")
 
ActorStats:defineStat("Constitution", "con", 10, 1, 100, "The amount of healing surges you get per day, Fortitude saves and the amount of hit points added 1st level are determined by Constitution.")
 
ActorStats:defineStat("Dexterity", "dex", 10, 1, 100, "Ranged basic attacks are based on Dexterity.  Dexterity also affects Reflex saves and AC bonus for light armor users.")
 
ActorStats:defineStat("Intelligence", "int", 10, 1, 100, "If you wear light armor, intelligence may contribute to your AC.  Intelligence also affects Reflex saves.")
 
ActorStats:defineStat("Wisdom", "wis", 10, 1, 100, "Wisdom contributes to will defense.")
 
ActorStats:defineStat("Charisma", "cha", 10, 1, 100, "Charisma contributes to will defense.")
 
</code>
 
  
In ActorStats:defineStat, the first parameter is the name of the stat, also used for displaying it.  The second is a shorthand way of refering to it, but the player won't ever see this.  The Third value is the default value for this stat, the fourth is the minimum, the fifth the maximum and the sixth a description of the stat.
+
  ActorStats:defineStat("Strength", "str", 10, 1, 100, "Melee basic attacks and Fortitude saves are based on Strength.")
 +
  ActorStats:defineStat("Constitution", "con", 10, 1, 100, "The amount of healing surges you get per day, Fortitude saves and the amount of hit points added 1st level are determined by Constitution.")
 +
  ActorStats:defineStat("Dexterity", "dex", 10, 1, 100, "Ranged basic attacks are based on Dexterity.  Dexterity also affects Reflex saves and AC bonus for light armor users.")
 +
  ActorStats:defineStat("Intelligence", "int", 10, 1, 100, "If you wear light armor, intelligence may contribute to your AC.  Intelligence also affects Reflex saves.")
 +
  ActorStats:defineStat("Wisdom", "wis", 10, 1, 100, "Wisdom contributes to will defense.")
 +
  ActorStats:defineStat("Charisma", "cha", 10, 1, 100, "Charisma contributes to will defense.")
 +
 
 +
In ActorStats:defineStat, the first parameter is the name of the stat, also used for displaying it.  The second is a shorthand way of referring to it, but the player won't ever see this.  The Third value is the default value for this stat, the fourth is the minimum, the fifth the maximum and the sixth a description of the stat.
  
 
For each stat, you can use the shorthand form getStr() to get the value (replacing Str with whatever short name you use for the stat).
 
For each stat, you can use the shorthand form getStr() to get the value (replacing Str with whatever short name you use for the stat).
Line 59: Line 56:
  
 
Next up is inventory and equipment slots.  As before, you need to add an import at the top of the file.
 
Next up is inventory and equipment slots.  As before, you need to add an import at the top of the file.
<code>
+
 
local ActorInventory = require "engine.interface.ActorInventory"
+
  local ActorInventory = require "engine.interface.ActorInventory"
</code>
+
  
 
Now for the actual inventory definitions:
 
Now for the actual inventory definitions:
<code>
+
 
-- Body parts
+
  -- Body parts
ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.")
+
  ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.")
ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use weapons two-handed or a second weapon in your off hand.")
+
  ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use weapons two-handed or a second weapon in your off hand.")
ActorInventory:defineInventory("ARMOR", "Main armor", true, "Armor protects your from physical attacks.")
+
  ActorInventory:defineInventory("ARMOR", "Main armor", true, "Armor protects your from physical attacks.")
ActorInventory:defineInventory("RING", "On fingers", true, "Rings are worn on fingers.")
+
  ActorInventory:defineInventory("RING", "On fingers", true, "Rings are worn on fingers.")
ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets and cloaks are worn around the neck.")
+
  ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets and cloaks are worn around the neck.")
ActorInventory:defineInventory("ARMS", "On arms", true, "Bracers or shields are worn on the arms slot.")
+
  ActorInventory:defineInventory("ARMS", "On arms", true, "Bracers or shields are worn on the arms slot.")
ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.")
+
  ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.")
ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.")
+
  ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.")
ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head.")
+
  ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head.")
ActorInventory:defineInventory("WAIST", "Around waist", true, "You can wear belts around your waist.")
+
  ActorInventory:defineInventory("WAIST", "Around waist", true, "You can wear belts around your waist.")
ActorInventory:defineInventory("IMPLEMENT", "On hands", true, "Divine or magic classes often use an implement to assist their attacks.")
+
  ActorInventory:defineInventory("IMPLEMENT", "On hands", true, "Divine or magic classes often use an implement to assist their attacks.")
</code>
+
  
 
The slot INVEN is defined by default and does not need to be explicitly mentioned.
 
The slot INVEN is defined by default and does not need to be explicitly mentioned.
Line 84: Line 79:
  
 
We will also set a maximum level the player can reach with
 
We will also set a maximum level the player can reach with
<code>
+
  local ActorLevel = require "engine.interface.ActorLevel"
local ActorLevel = require "engine.interface.ActorLevel"
+
</code>
+
 
and
 
and
<code>
+
  ActorLevel:defineMaxLevel(10)
ActorLevel:defineMaxLevel(10)
+
</code>
+
  
 
The maximum level is 10 since we will only be dealing with heroic tiers, but this can be set to 30 if you wish to also implement the paragon and epic tiers.
 
The maximum level is 10 since we will only be dealing with heroic tiers, but this can be set to 30 if you wish to also implement the paragon and epic tiers.
  
 
Note that you can also define resources, such as mana or stamina that regenerates over time, but 4E does not use any additional ones.
 
Note that you can also define resources, such as mana or stamina that regenerates over time, but 4E does not use any additional ones.
 +
 +
[[Category:Module Guides]]

Revision as of 02:59, 4 January 2021

4Emodule Part 1: load.lua

t4modules t4modules | t4modules module howto guides

In this part I will be defining the goal of this tutorial series, and start with the first modifications in the creation of the 4Emodule T-Engine module.

The goal of this series is to introduce the reader to how to easily use T-Engine to create any module of their choosing, often using mostly data driven definitions.

To start, make a copy of the example folder in your /game/modules/ directory and rename it to 4Emodule. Congratulations! You now have a playable module, and you will see it as an option when you start T-Engine and start a new game. It is at the moment identical to the example module, but that will change very quickly.

init.lua

First off, open your init.lua file in your favorite text editor.

You will see a pretty plain default file, so lets change it to reflect the new module.

 name = "DND 4E Module"
 long_name = "Tutorial Module creating a DND 4E game system"
 short_name = "4emodule"
 author = { "YOUR NAME", "EMAIL@PROVIDER.COM" }
 homepage = "YOUR WEBSITE"
 version = {1,0,0}
 engine = {1,0,0}
 description = [[t4modules 
 t-engine 4 module simulating the 4e dnd game system.
 ]]
 starter = "mod.load"

And thats it.

If you start T-Engine again you will see it appear properly in the module selection list.

load.lua

The example load.lua is reasonably sparse, so lets add some 4E definitions to it.

First, some stats.

To the top of the file, add this line: local ActorStats = require "engine.interface.ActorStats" And where the default stats are defined, replace with the following:

 ActorStats:defineStat("Strength", "str", 10, 1, 100, "Melee basic attacks and Fortitude saves are based on Strength.")
 ActorStats:defineStat("Constitution", "con", 10, 1, 100, "The amount of healing surges you get per day, Fortitude saves and the amount of hit points added 1st level are determined by Constitution.")
 ActorStats:defineStat("Dexterity", "dex", 10, 1, 100, "Ranged basic attacks are based on Dexterity.  Dexterity also affects Reflex saves and AC bonus for light armor users.")
 ActorStats:defineStat("Intelligence", "int", 10, 1, 100, "If you wear light armor, intelligence may contribute to your AC.  Intelligence also affects Reflex saves.")
 ActorStats:defineStat("Wisdom", "wis", 10, 1, 100, "Wisdom contributes to will defense.")
 ActorStats:defineStat("Charisma", "cha", 10, 1, 100, "Charisma contributes to will defense.")

In ActorStats:defineStat, the first parameter is the name of the stat, also used for displaying it. The second is a shorthand way of referring to it, but the player won't ever see this. The Third value is the default value for this stat, the fourth is the minimum, the fifth the maximum and the sixth a description of the stat.

For each stat, you can use the shorthand form getStr() to get the value (replacing Str with whatever short name you use for the stat).

We won't worry too much about the minimum and maximum stats in this module since the game system prevents it from running off too much.

Next up is inventory and equipment slots. As before, you need to add an import at the top of the file.

 local ActorInventory = require "engine.interface.ActorInventory"

Now for the actual inventory definitions:

 -- Body parts
 ActorInventory:defineInventory("MAINHAND", "In main hand", true, "Most weapons are wielded in the main hand.")
 ActorInventory:defineInventory("OFFHAND", "In off hand", true, "You can use weapons two-handed or a second weapon in your off hand.")
 ActorInventory:defineInventory("ARMOR", "Main armor", true, "Armor protects your from physical attacks.")
 ActorInventory:defineInventory("RING", "On fingers", true, "Rings are worn on fingers.")
 ActorInventory:defineInventory("NECK", "Around neck", true, "Amulets and cloaks are worn around the neck.")
 ActorInventory:defineInventory("ARMS", "On arms", true, "Bracers or shields are worn on the arms slot.")
 ActorInventory:defineInventory("FEET", "On feet", true, "Sandals or boots can be worn on your feet.")
 ActorInventory:defineInventory("HANDS", "On hands", true, "Various gloves can be worn on your hands.")
 ActorInventory:defineInventory("HEAD", "On head", true, "You can wear helmets or crowns on your head.")
 ActorInventory:defineInventory("WAIST", "Around waist", true, "You can wear belts around your waist.")
 ActorInventory:defineInventory("IMPLEMENT", "On hands", true, "Divine or magic classes often use an implement to assist their attacks.")

The slot INVEN is defined by default and does not need to be explicitly mentioned.

Note that the above only signifies the existance of these slots. The slots and the amount of each slot is defined per Actor.

We will also set a maximum level the player can reach with

 local ActorLevel = require "engine.interface.ActorLevel"

and

 ActorLevel:defineMaxLevel(10)

The maximum level is 10 since we will only be dealing with heroic tiers, but this can be set to 30 if you wish to also implement the paragon and epic tiers.

Note that you can also define resources, such as mana or stamina that regenerates over time, but 4E does not use any additional ones.