4Dimensions - the online multiplayer text-based RPG

  • contact us
  • faq
  • forum
  • click here to play now
Home › Builder Resources

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Navigation

  • 4D Background Story
  • Click to play
  • Quick Start Guide
    • Frequently Asked Questions
    • Character creation
    • Newbie Help
    • The Hint Channel
  • Features
    • Classes
    • Races
    • Maps
    • Skills and Spells
    • Location of the Trainers
    • Quests
    • Item Artifacts
    • Currency
      • Price/Convey Guide
    • Trading in 4D
    • RolePlay in 4D
    • The Gladiator Arena
    • Player Killing in 4D
    • Travel Agency
  • Grouping in 4D
  • People in 4D
  • Zones in 4D
  • 4D Clans
  • Awards
  • Mud Clients
  • Polls
  • Ask a question
  • Builder Resources
    • 4D Build Rules
    • 4D Build Policy
    • 4D Equipment Guide
    • 4D Bad Scripts
    • 4D Build Handbook
    • 4D Flags and Speces
    • Builder of the Month Requirements
  • Recent posts
  • Feed aggregator

Visiting Website

There are currently 0 users and 12 guests online.

Online forum users

Users Online 2 Guests 0 Users

Who's new

  • nisseswe
  • lucas_p95
  • CatsDream
  • viggoh2
  • crisscriss22

Bad Scripts - A Trouble-shooter's Handbook

  • View
  • Outline
There are dozens of reasons why a script that looks good at first glance can misfire - and in the worst cases even freeze or crash the Port. A lot of different things can cause a script not to function when you test it. Some of the most common causes are listed below: If you get stuck and cannot figure out what is wrong with your buggy script, reading through this list might give you some new angles.
  • There might be a small typo somewhere in the script that you don't even notice when checking it, like for instance a missing %. Set your spellchecker to accept common expressions in the script syntax, like %actor%, %actor.name%, %echo%, %echoaround% %send% etc. That will save you from stupid mistakes like using a comma instead of a period, or dropping the odd %. A blank in the wrong place can screw up a script too, and is pretty hard to spot. Also make sure that all flags are spelled EXACTLY the same in all places (the code is case sensitive, so a capital letter in one place and not in another would screw things up). Another simple thing that could screw up a script is a missing return, which puts a command line at the end of another command. Or the opposite, a long line that got cut off for some reason, while you were editing the script. (This should give a syserr though, when the script is run).
  • There might be a missing endif somewhere, or an endif too many, or one in the wrong place. All three things could screw up a script totally. Make sure that you always put an endif to each if_check and in the right place.
  • Even a missing bracket or one too many can stop a script from working.
  • Perhaps you screwed up the if-check for a variable and put ‘if !%actor.varexists(whatever)%’ where it should be the opposite instead; ‘if %actor.varexists(whatever)%’. (This happens more often than you might think).
  • There might be another script interfering with it in the same room. For example, you cannot set two different GREET or RECEIVE scripts on the same mob, they need to be incorporated in the same script, or only the first one will go off. Likewise a room can only have one ENTER trigger. You can have several speech or command scripts on the same mob/room/object, as long as they all have an individual argument. But as soon as one of these scripts has * as arg, this will disable all other speech or command scripts that you put on the same mob/object/room. Again these need to be incorporated in the same script. If you put several random triggers in the same room, they may interact with each other and in the worst case crash the mud, so basically avoid this. Also too scripted mobs can trigger each other off by mistake, so make sure that you don’t allow heavily scripted mobs to roam around too much.
  • The script type might be wrong. (This happens sometimes if you change a script from one type to another, and forget to change the type under 3. in the main menu).
  • In order for timescripts to work, triggers should be set as type time but also as global. Meaning type: GlobalTime
  • The num arg might be wrong, (for instance 1 instead of 100 in a GREET script). This makes the script only go off in 1 percent of the cases. In speech scripts and receive script the num arg must be either 0 or 1. Object scripts have their own set of num args, which need to be used for those scripts to work properly. They can be set to check if an object is held or worn (1), in inventory (2), in the room (4), or different combinations of these (7 works for all four options).
  • Perhaps you forgot who the actual %actor% is in the script, or perhaps there isn’t even an actor. Load scripts and random scripts don’t have an actor, (although there are ways to set one). If a mob triggers a second mob with a script, the first mob becomes the actor for the second one’s script, not the player that started the first script. (This is a more common error than you might think, if there are several interactive mobs in the same room).
  • You may have used a line starting with say, tell or emote in an object or room script. Rooms and objects cannot talk. (It is quite possible to fake a conversation with a room or object script, but you need to use commands like %echo%, %echoaround% and %send% instead then).
  • Sometimes there needs to be a short wait at the beginning of the script. This is for instance essential for Greet scripts where the Quest-mob is supposed to check for a follower of the player that triggers the script. You need to give the code the time to get the everybody into the room, before it sets off.
  • The commands might be set in the wrong order. For instance you may have set the mob to purge the object it receives BEFORE it checks for the vnum of the object. Or you may have set the script to do some actions AFTER the mob that the script is set on, purges itself. Or you might have tried to make a mob say something in a DEATH script. (This cannot be done, because the DEATH scripts starts AFTER the mob died - and dead people cannot speak. They can however do things like load an item, purge or drop equipment or send an echo). Ending a DEATH script with ‘%purge% self’ will crash the Port.
  • The trigger word in a speech_script may be used in one of the phrases that the Mob says itself. This creates an infinite loop that freezes or crashes the Mud, (In 4D there is a check to prevent that in the code, but not all muds have that).
  • You may have used tell or emote instead of say in a phrase that was supposed to trigger off a speech_script on a second mob.
  • A mob can only fight one player character or non-player character at a time. If you put in a mkill command on a mob that is already fighting, it creates a bug that might crash the Mud
  • You may have used a bad command somewhere in the script. Generally you have to put an m before ”imm-commands” (like mgoto, mpurge etc.), or put the imm command within % % (like %purge%). You also have to use mkill instead of plain kill, since the mobile won’t attack the player otherwise. But sometimes builders get a bit carried away and put the m in front of quite simple commands like open, close, north, follow, etc., which of course makes them not work as they should.
  • Maybe you have mixed up %actor% or %actor.name%. (Remember the ground rule: use %actor% for ‘imm commands and %actor.name% for ‘normal commands). For instance the line ‘%teleport% %actor.name% 3001’, might teleport a mob with the same name instead of the actor. Likewise the line ‘follow %actor%’ might not be interpreted right by the mob.
There are also several outside reasons why a perfectly good script could seem not to be working when you test it. Very frequently the problem doesn’t lie with the script at all, but with rooms, pcs, mobs or objects affected by the script, or by the fact that you are an imm and not a ”normal” player. Some of the most common mistakes are listed below:
  • You forgot to purge and reload the mob/object you are testing with after you set the script on it.
  • Maybe you even forgot to set the script on the mob/object/room, or used the wrong vnum for it?
  • Or maybe you just reset the wrong zone. The vnum of the room the mob/object is in, might not be the same as the mob/object itself.
  • The room is flagged DARK, or it is night, so the mobile can’t see you because it is dark in the room. (You can avoid this by flagging the room with the script INDOORS, or give the mob infravision, or better still flag it as Quest mob).
  • You are invisible, so the mob can’t detect you. Even the greet_all triggers don’t work fully in the two above cases. Says, socials and emotes from the mob will work, but not tells or commands like ”give item %actor.name%”.
  • The item a mob is supposed to give out or handle is nodrop (cursed).
  • The item a mob is supposed to hand out is too heavy for the player to receive (or the player has his hands full). Both these factors can be avoided by loading the object directly to the player’s inventory instead.
  • The item the mob is supposed to give out is badly named. It can be a typo in the object name, or just that the name is different from what you type in the command line. "Give box %actor.name%" won’t work if the box has the alias “cube”..
  • You set the script to load the wrong object or mob (bad vnum). This is a very common mistake.
  • If a door that is supposed to be opened by a script doesn’t work, you most likely forgot to match the script with the door name (for instance the door is named ”wooden door”, while the script command is ”open south”). You may even have forgotten to set the door as such in redit, or the door could be locked and the script lacks the command line to unlock the door.
  • If the script is supposed to do a teleport, check that the rooms with the script aren't set as !teleport in or out, and also that there is no !teleport in or out flag set on the zone in zedit.
  • The room is soundproof, so the mob can’t use tells.
  • The room sector sometimes plays tricks. For instance a following mob cannot follow through the sector !swim without a boat, unless it has waterwalk set. (This isn’t necessarily an error, it may have been designed that way to make the quest a bit harder).
There are also some errors that can be caused by using your own imm char while testing.
  • You might have forgotten to toggle nohassle off, (which will make all mobs ignore you).
  • Mobs don’t teleport imms in Circle, so a mteleport command won’t work on your imm char when you test the script, although it works on morts. (The room command wteleport works with imms too, however).
  • And all COMMAND scripts need to be tested with a mortal, since commands work different for morts and imms. You can do this by typing ‘atlev 50 ’, if you don’t want to log on an alt (which by the way isn’t permitted in the game port).
Finally: Always be careful and methodical when making scripts. One single typo can ruin a script. And one single missing endif can crash the Mud. Most script errors show up on the syslog for the imms that can see it, but not all. So always spell-check your scripts. And always format them with indents, to keep track of the ifs, elseifs, elses and endifs. The command /f when in the script editor will do this automatically, and also remove surplus endifs. Back to the top 2008-01-28 Molly O’Hara

Search

Who's playing now

NameLevel
MollyGod
Jason50
Emma36
Total OnlineUptime
31 day, 6:01 hours

Vote for 4D

  • World online games
  • Mud Lists
  • Mud Connector
  • RPG Gateway
  • Top mud sites

Friends of 4D

  • Shatterlands by Meg
  • DeviantArt by Meg
  • MudQuest Free Quality Muds
  • CWG Building Forum
  • Mudlab.org Design Forum

New forum posts

Recent Posts Recent Posts
  • Re: How Do I???
    by Diandra in Scripting Board
    December 04, 2008, 12:11:07 PM
  • Re: How Do I???
    by Molly in Scripting Board
    December 03, 2008, 11:14:30 AM
  • Re: Assemblies
    by Mordecai in Building Board
    December 02, 2008, 02:39:38 PM
  • Re: How Do I???
    by Mordecai in Scripting Board
    December 02, 2008, 02:33:31 PM
  • Assemblies
    by Molly in Building Board
    November 30, 2008, 04:02:22 AM
  • Re: How Do I???
    by Molly in Scripting Board
    November 29, 2008, 05:49:42 AM
  • Re: How Do I???
    by Fizban in Scripting Board
    November 25, 2008, 01:50:49 PM
  • Re: How Do I???
    by Molly in Scripting Board
    November 24, 2008, 09:27:32 AM

Random FAQs

  • Why can't I wear certain items?
  • Can we go back to the school when we drop out?
  • Any useful commands I should know?
  • I see people with a (Helper) flag. What's so special about them?
  • I'm with a trainer, but how do I find out what he trains? Then how do I train with them?
All FAQs

  • contact us
  • faq
  • forum
  • click here to play now