{{outdated}}
Scripts are usually kept in the npc folder for the sake of organization even
though scripts can contain more than a mere NPC. All files are saved as text
files. Scripts cannot be loaded on to the server unless their text file is
activated in a *.conf file.
New scripts must be saved as a text file first. The file may be located
anywhere in the Hercules directory, but is in the npc folder by default.
Any text editor may be used to edit .conf files. The _npc/.conf_ files are
used to determine which script text files should be loaded. There are about a
dozen .conf that handle different groups of scripts for the purpose of
organization. It does not matter which .conf holds your custom scripts as
long as the path is correct.
Typical *.conf entry layout:
npc: npc/path/to/yourscript1.txt
// npc: npc/path/to/yourscript2.txt
Note how the second line is preceded with a double slash. Content on the same
line after double slashes will not be parsed. In other words, script2.txt
will not be loaded. The slashes can be used to write comments.
{{git|npc/pre-re/scripts_main.conf}} or {{git|npc/re/scripts_main.conf}}
determines which of the *.conf will be read by the server.
import: npc/path/to/configuration.conf
After adding the script, it must be loaded before the script contents take
effect in game. There are a few ways to do this.
The NPC name used in examples is "Teddy".
The two files you will need to open and edit are "jobname.lua" and
"npcidentity.lua". Jobname.lua will look like:
[jobtbl.NPCNAME] = "NPCNAME",
Example:
[jobtbl.TEDDY] = "TEDDY",
npcidentity.lua will look like:
["NPCNAME"] = NPCID,
Example:
["TEDDY"] = 587,
If your NPC has spaces in its name, its best to either remove them or replace
them with underscores. So if the NPC's name was Brown Teddy the sprite's name
would be Brown_Teddy.spr or BrownTeddy.spr and the lua files would be
BROWN_TEDDY or BROWNTEDDY. Whatever ID you choose for your sprite, either NPC
Sprite name(Case-Sensitive, In Capital Letters) or ID will be use in the
script. The beginning of my script will look like:
xmas_in,111,107,3 script Teddy 587,{
xmas_in,111,107,3 script Teddy TEDDY,{
The sprite part is straightforward, just Teddy.spr is fine, you don't need
Teddy_m.spr or anything like that, but if you want to add m for male to the
name you can do that, but it won't effect its functionality in-game. NPC
sprites are located in data/sprite/npc.