1
SCI Syntax Help / Re: SCI0 - Custom buttons, windows and gauges
« Last post by AGKorson on Today at 10:15:05 AM »Yeah I may have missed some things in editing.
Maybe you should have used AI to check for errors...
Yeah I may have missed some things in editing.
(Display
text
dsCOORD
(+ nsLeft (>> (- w [rect rtRIGHT]) 1))
(+ (+ nsTop (>> (- h [rect rtBOTTOM]) 1)) 1)
dsCOLOR gWndColor
dsBACKGROUND clTRANSPARENT
dsFONT font
dsWIDTH [rect rtRIGHT]
)
Chapter 7
Change: (= nsBottom (+ nsTop [rect rtBOTTOM]))
To: = nsBottom (+ nsTop (| (& rect[rtBOTTOM] $FFFC) 7))
and change: (= nsRight (+ [rect rtRIGHT] nsLeft))
To: = nsRight (+ (| (& rect[rtRIGHT] $FFFC) 7) nsLeft)
Add the following code to the DButton class.Code: [Select](method (draw &tmp x y x2 y2 w h [rect 4])
; Calculate the areas
(= x2 (- nsRight 8))
(= y2 (- nsBottom 8))
(= w (- nsRight nsLeft))
(= h (- nsBottom nsTop))
(TextSize @rect text font)
; Draw the side borders
(for ( (= y (+ nsTop 8))) (< y y2) ( (= y (+ y 8))) (DrawCel 900 0 4 nsLeft y -1) (DrawCel 900 0 6 x2 y -1))
; Draw the top and bottom borders
(for ( (= x (+ nsLeft 8))) (< x x2) ( (= x (+ x 8))) (DrawCel 900 0 5 x nsTop -1) (DrawCel 900 0 7 x y2 -1))
; Draw the corners
(DrawCel 900 0 0 nsLeft nsTop -1)
(DrawCel 900 0 1 x2 nsTop -1)
(DrawCel 900 0 2 nsLeft y2 -1)
(DrawCel 900 0 3 x2 y2 -1)
; Draw the text
(Display
text
dsCOORD
(+ nsLeft (>> (- w [rect rtRIGHT]) 1))
(+ (+ nsTop (>> (- h [rect rtBOTTOM]) 1)) 1 dsCOLOR)
gWndColor
dsBACKGROUND
clTRANSPARENT
dsFONT
font
dsWIDTH
[rect
rtRIGHT]
)
)
To go with the default custom button, we'll make the window silver.
Change: (= gWndBack clWHITE)
To: (= gWndBack clSILVER)
(= nsBottom (+ nsTop (| (& [rect rtBOTTOM] $FFFC) 7)))
(= nsRight (+ (| (& [rect rtRIGHT] $FFFC) 7) nsLeft))
It would be good to include this post from Gumby as well
(= Verb UNSET) ; initialize it to 'nothing' before each parse
(if (Said 'dig/*/*>') ; ex: dig in ground with shovel
(= Verb VERB_DIG)
)
(if (Said 'dig/*[/!*]>') ; ex: dig in ground
(= Verb VERB_DIG)
(= needSecond TRUE) ; what do you want to dig in the ground with?
)
(if (Said 'dig[/!*]>') ; ex: dig
(= Verb VERB_DIG)
(= needNoun TRUE) ; what do you want to dig in?
)
(= noun UNSET) ; initialize it to 'nothing' before each parse
(if (Said '*/ground>')
(= noun GROUND_OBJ)
)
(if (Said '*/shovel>')
(= noun SHOVEL_OBJ)
)
and: (= second UNSET) ; initialize it to 'nothing' before each parse
(if (Said '*/*/ground>')
(= second GROUND_OBJ)
)
(if (Said '*/*/shovel>')
(= second SHOVEL_OBJ)
)
(procedure (RobustPragmaFail)
(if (and (== needNoun TRUE) (== noun UNSET))
(FormatPrint "What do you want to %s?" VERB_NAMES Verb)
(return TRUE)
)
(if (and (== needSecond TRUE) (== second UNSET))
(FormatPrint "What do you want to %s the %s with?" VERB_NAMES Verb NOUN_NAMES noun)
(return TRUE)
)
(if (and (== unneededNoun TRUE) (!= noun UNSET))
(FormatPrint "I understood only as far as you wanting to %s." VERB_NAMES Verb)
(return TRUE)
)
(if (and (== unneededSecond TRUE) (!= second UNSET)
(FormatPrint "I understood only as far as you wanting to %s the %s." VERB_NAMES Verb NOUN_NAMES noun)
(return TRUE)
)
(return FALSE)
)
;;; *************** Main.sc *************
;; global variables
Verb
noun
second
needNoun
needSecond
unneededNoun
unneededSecond
;; The array that will track where our objects are
[objectLocations10] ; one for each object in our game
;; in the init method of Main.sc
(= [objectLocations TREE_OBJ] TREE_ROOM)
(= [objectLocations SAW_OBJ] NOWHERE)
(= [objectLocations GROUND_OBJ] EVERYWHERE)
(= [objectLocations SHOVEL_OBJ] HOUSE_ROOM)
(= [objectLocations BIRD_OBJ] TREE_ROOM)
(= [objectLocations HOUSE_OBJ] HOUSE_ROOM)
(= [objectLocations DOOR_OBJ] HOUSE_ROOM)
(= [objectLocations KEY_OBJ] INVENTORY)
;; Rooms
(define INVENTORY -2)
(define EVERYWHERE -1)
(define NOWHERE 0)
;; From here, the number should match the room script numbers
(define HOUSE_ROOM 1)
(define TREE_ROOM 2)
Here's the procedure that does the checking for whether the nouns are 'in-scope':(procedure (ValidateNouns)
(if (!= noun UNSET)
(if (and
(!= [objectLocations noun] gRoomNumber)
(!= [objectLocations noun] INVENTORY)
(!= [objectLocations noun] EVERYWHERE)
)
(FormatPrint "I don't see any %s here." NOUN_NAMES noun)
return FALSE)
)
)
(if (!= second UNSET)
(if (and
(!= [objectLocations second] gRoomNumber)
(!= [objectLocations second] INVENTORY)
(!= [objectLocations second] EVERYWHERE)
)
(FormatPrint "I don't see any %s here." NOUN_NAMES second)
(return FALSE)
)
)
; All the nouns are here
(return TRUE)
)
(procedure (CallAction)
(if (== Verb VERB_CUT) (CutAction) (return))
(if (== Verb VERB_CLIMBUP) (ClimbUpAction) (return))
(if (== Verb VERB_CLIMBDOWN) (ClimbDownAction) (return))
(if (== Verb VERB_DIG) (DigAction) (return))
(if (== Verb VERB_LISTEN) (ListenAction) (return))
(if (== Verb VERB_LOOK) (LookAction) (return))
(if (== Verb VERB_RUN) (RunAction) (return))
)
(KAWA NOTE: I'd rewrite that as a switch but maybe that's just me lol.(procedure public (DigAction)
; Could be "dig ground with shovel" or "dig with shovel in ground"
(if (and (!= second SHOVEL_OBJ) (!= noun SHOVEL_OBJ))
Print "That doesn't have a blade adequate for digging.")
(return)
)
(if (and (!= second GROUND_OBJ) (!= noun GROUND_OBJ))
(Print "It would be best if you dug in something sensible!")
(return)
)
(Print "Nice hole. What next?")
)
If I had access to edit the wiki I would help update it.
(method (wordFail theString)
(switch (Random 0 4)
(0
(FormatPrint {Oh, yeah? Well, %s this!} theString)
)
(1
(FormatPrint {You may know the word %s but it's beyond the game's vocabulary!} theString)
)
(2
(FormatPrint {Oh, yeah? Well, I've got your %s right here!} theString)
)
(3
(FormatPrint {You don't need to type the word %s to complete this game!} theString)
)
(else
(FormatPrint {Don't you ever say the word %s again!} theString)
)
)
)
(method (syntaxFail theString)
(switch (Random 0 2)
(0
(Print {That doesn't appear to be a proper sentence.})
)
(1
(Print {What in the hell are you talking about?})
)
(else
(Print {That's probably something you could do, but this game won't!})
)
)
)
(method (pragmaFail theString)
(switch (Random 0 2)
(0
(Print {The hell you say?})
)
(1
(Print {You're too smart for this game!})
)
(else
(Print {Congratulations! You have dumbfounded this game!})
)
)
)
SMF 2.0.19 |
SMF © 2021, Simple Machines
Simple Audio Video Embedder
Page created in 0.047 seconds with 16 queries.