; This example is an actual "story package" from Enhanced Newcomer,
; the previous major revision of our game.

; Story packages are made of one or two parts:
;    1./ a script package
;    2./ a local string package (optional)
; Loading and executing story packages can be triggered by two kinds of events:
;    1./ Entering an X,Y location that has a "story" flag loads the story package set for that location,
;        and if the package contains an 'enter' event-handler, that function is immediately executed
;    2./ Timer activation -- we can set up a timer, and specify a story package for it as an arg
; -An alternative way to trigger a story package is that any script can invoke and execute another one.

; Creating a story package by declaring a unique ID for it
                    ; constructed from the following parts: story package indexed as '4' for location '1' of area 'FR'.
                    ; On entering that particular location the scipt is loaded and the 'enter' function is executed.
                    ; -From then on it is the script that evaluates and handles events and conditions,
                    ; except for the following "external" events:
                    ;    1./ a concurrently running timer triggering its specified story package
                    ;        (maskable -- the timer can be cleared)
                    ;    2./ the ACTivity level of the protagonist, Neil Quoit, reaching RIP due to bleeding or environmental damage
                    ;        (non-maskable -- always jumps to the "GAME OVER" function of the game engine).

          txtst     fr1t4          
; Specifies the ID label of the string package to use as 'local' for this script package.

; EVENT-HANDLER: This function is executed when the player enters the location.

          print     story,4             
; Print string index .4 in the bottom window, arg 'story' refers to the local string package,
                                        ; there are engine-embedded global strings as well.

; Exit function 'enter', return to the main control loop that checks for:
                                   ; timed events, user input events (like Use, Find, Look, Open, 'leave'), and "Neil_RIP".

          search    west,5         
; EVENT-HANDLER: Pressing '[F]ind', IF Detection Skill level <= 5 turn Neil to west

          window    story,noyn,2        
; Print local string .2 in the center window,
                                        ; arg 'noyn' means no [Y]es/[N]o requester for user interaction.


; EVENT-HANDLER: "Looking" to the South

          print     story,1

; EVENT-HANDLER: "Using" a Skill or an Item

          useitem   north,0,60,lok2     
; like item index '60', facing 'north', with '0' (ie. no) skill requirement,

; execution branches to label 'lok2'.

          useitem   west,0,60,lok2      
; In our example the same thing happens

          useitem   south,0,60,lok2     
; for all four directions, but you can see

          useitem   east,0,60,lok2      
; the flexibility inherent in the system.

; End of 'use' function.

lok2      remove    60                  
; Remove item index '60' from the inventory of the "using" character.

          window    story,noyn,3
          story     FR1,5               
; Change story package for this location (args: area+location index,new story index).


; End of script package.

; Creating a local string package by declaring a unique ID for it.

.1        dc.b "A spring... (no `thing on/it`!)"+                     
; '/' is a forced line break

.2        dc.b "There are small excrements of a rodent everywhere."+  
; '+' is the string terminator

.3        dc.b "You set the trap."+  
.4        dc.b "There is a spring here. Clear/"                       
; so we can use multi-line strings like this,

          dc.b "water is coming up from it..."+                       
; to assist with the formatting of text

; End of string package.

; End of story package.

; 'dc.b' might clue you in on all of this being part of an assembler source -- indeed IT IS.
; The Newcomer and Enhanced Newcomer "scripting" language was implemented
; by the macro functions of the Asm-One cross-assembler on AmigaOS.

; We hope this example makes it clear to you how Newcomer was done, at least regarding some of the technical aspects,
; if not the amount of work, planning, and deBUGging involved.
; We also hope you already found this particular story in the game while you were playing,
; so it was familiar as you were reading this example.

; Please, keep looking for Ultimate Newcomer,
; Revision #3 of our original game, already in Release Candidate,
; meant to be the last and finest NEWCOMER update!

; Cheers,
;    Istvan Belanszky \ Ultimate Newcomer Crew