Incomplete Scripts


Although understanding Iptscrae is beyond the scope of this tutorial there are a couple of things you can look for in a script to make sure you haven't missed something when you copied it to your room:

 

Iptscrae basics:
Iptscrae is comprised of one or more 'event handlers' which cause things to happen in specific events. The events are:

Each of these events must be coded in a very precise way. Each must start with the event name, above, followed by the "{" character, followed by scripting and end with the "}" character. Thus a typical event handler looks like:

ON SIGNON
{
lots of Iptscrae here
}

Scripts can also have comments. A comment line is any line starting with a ";".

Thus, a typical script might look like the following, which changes the spot picture of a door when it is 'selected' or when "next" is said:

ON ENTER
{
getnextstate GLOBAL
; define a function that changes spot 2's picture
{
{ 2 GETSPOTSTATE 1 + 2 SETSPOTSTATELOCAL } { 0 2 SETSPOTSTATELOCAL } 2 GETSPOTSTATE 3 < IFELSE
} getnextstate DEF
}

ON SELECT
{
getnextstate GLOBAL
; execute the code that changes spot 2's picture when this spot is selected
getnextstate EXEC
}
ON OUTCHAT
{
getnextstate GLOBAL
; execute the code that changes spot 2's picture if a person types "next"
{ getnextstate EXEC } CHATSTR "next" == IF
}

 

What should I look for?
When adding a script to a room a common problem is missing the first or last character. So check for the following:

When adding code to an existing script (like adding code to an existing ON OUTCHAT event or adding an ON OUTCHAT event to a script with only a ON SELECT event) a common problem is losing or adding too many brackets. The following shows the correct way to add scripts together:

Script 1:

ON OUTCHAT
{
script 1 iptscrae here
}

Script 2:

ON OUTCHAT
{
script 2 iptscrae here
}

The combined script::

ON OUTCHAT
{
script 1 iptscrae here
script 2 iptscrae here
}

 

Exercise 4-1:
Find the error with the following script:

;Alan's looping sound with on/off control
;modified from a script by unknown author
ON ENTER
{
snd GLOBAL
1 snd =
"Say 'on' or 'off' to control the music." STATUSMSG
1 ME SETALARM
}
ON OUTCHAT
{
snd GLOBAL
{ 1 snd =
1 ME SETALARM
"" CHATSTR =
} snd NOT
CHATSTR "on" == AND IF
{ 0 snd =
"" CHATSTR =
} CHATSTR "off" == IF
}
ON ALARM
{
snd GLOBAL
;*************************************************************
;Enter the name of your sound file in quotes:
"tobeloved_m" soundfile =
;Specify the time it takes to play your sound in minutes, seconds
;and 10ths of seconds.
;Adjust the time until the sound starts again just after it stops each time.
;A long pause means it is trying to start too soon.
4 minutes =
55 seconds =
0 tenthsofseconds =
;*************************************************************
MIDISTOP
soundfile SOUND
;if an old client use MIDIPLAY in case it is a midi on a PC.
{ soundfile MIDIPLAY } IPTVERSION NOT IF
minutes 3600 * seconds 60 * + tenthsofseconds 6 * + ME SETALARM
} snd IF
}