Main
Projects
Art
Music
Scripting
LiveJournal
Forum
Links
Scriptsplit Example
by James `SPAM Man' Paige

This is actually two separate scripts: a "good" script and a "bad" one. The purpose of these is to split a long script into smaller ones, avoiding script buffer overflows. First, the "bad" one.


include, plotscr.hsd

#--this script is an example of the WRONG way to break up reeeeeeealy
#  long scripts to avoid "script buffer overflow" errors. By breaking
#  up a big script in this way, you gain absolutely nothing, because
#  each part of the script gets stacked on top of each other in memory

define script(1,big daddy script,0)
define script(autonumber,baby script A,0)
define script(autonumber,baby script B,0)
define script(autonumber,baby script C,0)
define script(autonumber,baby script D,0)

script,Big Daddy script,begin
  baby script A
end

script,baby script A,begin
  # stuff
  baby script B
end

script,baby script B,begin
  # more stuff
  baby script C
end

script,baby script C,begin
  # even more stuff
  baby script D
end

script,baby script D,begin
  # the rest of the stuff
end

Don't do that. When you want to break a script into smaller pieces, this is the way to go:



define script(1,big daddy script,0)
define script(autonumber,baby script A,0)
define script(autonumber,baby script B,0)
define script(autonumber,baby script C,0)
define script(autonumber,baby script D,0)

script,Big Daddy script,begin
  baby script A
  baby script B
  baby script C
  baby script D
end

script,baby script A,begin
  # stuff
end

script,baby script B,begin
  # more stuff
end

script,baby script C,begin
  # even more stuff
end

script,baby script D,begin
  # the rest of the stuff
end

Site layout (c)2000 Jennifer Raby. Used by permission.