Expected top-level declaration but found

From OHRRPGCE-Wiki
Jump to: navigation, search

This error message means you have written your script wrong. Here is an example of a script that would generate this error:

show text box (1)
wait for text box
walk hero (me,north,3)
wait for hero (me)
set hero direction (me,south)

If you tried to compile this script, you would see an error message saying;

ERROR: in line 3 of test.hss
show text box (1)
Expected top-level declaration, but found hardcoded function showtextbox. 
Perhaps there is an extra end or ) earlier in the file

This error can be a little misleading. Sometimes this error does occur because you have an extra end or ) somewhere in your script, but in this example it is happening because you did not use a plotscript command to mark the beginning of your script. The same script, if written correctly, would look like this:

plotscript, Hello World, begin
  show text box (1)
  wait for text box
  walk hero (me,north,3)
  wait for hero (me)
  set hero direction (me,south)
end

Notice the plotscript, Hello World, begin that marks the beginning of the script, and the end that marks the end of the script. It is necessary to separate your scripts this way because a single script file can contain many individual scripts.


See Also[edit]