How do I call one script directly from another script?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

Very simple, just by using its name. When you make a script, it can be used exactly like any normal plotscripting command. Permit me to give an example.

#-------------------------------------------------

script, show a box in greyscale and wait, begin
  greyscale palette
  update palette
  show text box(3)
  wait for text box
  reset palette
  update palette
end

#-------------------------------------------------

plotscript, my main script, begin
  # call your script just as if it was a command
  show a box in greyscale and wait
end

#-------------------------------------------------

You can also give arguments to your scripts. Example:

#-------------------------------------------------

script, show a box in greyscale and wait, box to show=0, begin
  greyscale palette
  update palette
  show text box(box to show)
  wait for text box
  reset palette
  update palette
end

#-------------------------------------------------

plotscript, my main script, begin
  # call your script just as if it was a command
  show a box in greyscale and wait (3)
end

#-------------------------------------------------

Not only that, but your scripts can also return values. Here is another example.


#------------------------------------------------------------

script, area of a circle, radius=1, begin
  # Area equals PI times Radius Squared

  # the OHRRPGCE only uses integers, so we are going to
  # pretend PI is 314 and divide the result by 100
  variable(PI)
  PI:=314

  variable(result)
  result:=PI * (Radius ^2)

  # now we divide the result by 100 before we return it.
  # the result will be rounded off to an integer
  return(result / 100)
end

#------------------------------------------------------------

plotscript, my main script, begin
  variable(area)
  area:=area of a circle(25)
  show value(area)
end

#------------------------------------------------------------