Author Topic: Complete newb can't get inventory working in template game  (Read 11246 times)

0 Members and 1 Guest are viewing this topic.

Offline menotu3169

Complete newb can't get inventory working in template game
« on: July 26, 2023, 04:38:16 PM »
Hello,

I am trying to go through the tutorial to make my first SCI0 game, and I am having problems. 
Specifically, I am going through this part: http://sci.sierrahelp.com/Tutorials/Tutorial1/chapter18.html and I can't get it to work.

When I try to compile it, I get an error message saying ' Undefined Symbol "theKey" '

Based on the rest of the inventory tutorial, it seems like I should be using "key" instead, since that was the name used for creating the instance, but that gives the same error.

Any help would be greatly appreciated. Thanks

I am trying to create an SCI0 game, using SCI Studio 3.0.1.29
I know that SCICompanion is supposed to be better, but it doesn't seem to work on Linux, it just crashes any time I try to do anything with a script



Offline Kawa

Re: Complete newb can't get inventory working in template game
« Reply #1 on: July 26, 2023, 05:04:16 PM »
Did you actually follow the step in chapter 17 where theKey is added to rm001.sc?

Offline menotu3169

Re: Complete newb can't get inventory working in template game
« Reply #2 on: July 26, 2023, 06:09:07 PM »
Did you actually follow the step in chapter 17 where theKey is added to rm001.sc?

Apparently not. This fixed it, thanks!

Actually, I did go through that step, but ran into different issues while working on it yesterday.
Today I restarted from scratch and apparently I neglected that part.

Everything now compiles and runs, but when I try to take the key, i get a new error saying "bad said spec"

I am also wondering if there is a tutorial on how to bring up the inventory dialog after typing 'look <item>'
None of the tutorials I've seen talk about that, and so far the only thing I am able to do is add a basic 'look' message

Thanks

Offline Collector

Re: Complete newb can't get inventory working in template game
« Reply #3 on: July 26, 2023, 07:35:46 PM »
Perhaps I should pull those tutorials since the are old ones that use Studio script.
KQII Remake Pic

Offline menotu3169

Re: Complete newb can't get inventory working in template game
« Reply #4 on: July 27, 2023, 12:23:05 AM »
Found the issue:

The code in the tutorial (http://sci.sierrahelp.com/Tutorials/Tutorial1/chapter18.html) says
Code: [Select]
(if(Said("take/key'))
Notice that there's a double quotation before take, but only a single quotation after key. The mismatched quotes was one of the many issues I encountered. At first, I just copied and pasted from the website and didn't notice the mismatch. The compiler just kept saying 'Out bracket expected' so I kept chasing brackets. Once I did notice, however, I made the mistake of changing  the single quote to a double quote. Apparently double quotes don't get caught by the compiler, but will cause the game to crash with the 'bad said spec' error. Fun times.

And since there have been a few posts, I'm going to ask again:
Is there a tutorial on how to bring up the inventory dialog after typing 'look <item>'
None of the tutorials I've seen talk about that, and so far the only thing I am able to do is add a basic 'look' message

Thanks @Collector and @Kawa for your help.

Offline Kawa

Re: Complete newb can't get inventory working in template game
« Reply #5 on: July 27, 2023, 05:50:05 AM »
If by the inventory dialog you mean the one you get when you press Tab or type inventory, I don't know how look gizmo having the same effect makes sense to the player. But I may have sorely misunderstood your question.

Said specs take single quotes, 'take/key'. The compiler will take this string, reduce it down to a set of dictionary lookup numbers (because "get" also works), and store the result in a special section of the script resource.
Local strings take curly braces, {Larry says}. The compiler will take this as-is and store it in another special section of the script resource.
Text strings take double quotes, "O.K.". The compiler is supposed to store these in a Text resource matching the script's number and store a lookup number pair instead.

This is why (instance {Test object} of Iitem uses curly brackets instead of double quotes. Object names aren't supposed to go in the Text resource.

In the end, the first two options both end up with a single 16-bit number in the script's code -- a pointer to that said-spec or string literal. But the Said command can't really tell you gave it a string literal and misinterprets each pair of characters as a dictionary number to look up. And fails.
If the third option were compiled the way it should, it'd put two 16-bit numbers in the script code -- a text tuple. This is twice as many bytes as a pointer, but the target isn't part of the script and this frees up memory in the end.

Things like Display and Print have special checks to see if the first argument is perhaps lower than 1000. If it is, they assume it and the next argument form a Text resource lookup tuple. If it's not, it's a pointer to a string of some vintage. And that's how (Print 5 10 #font 2) and (Print "literal" #font 2) can both work.



The rest of this is just rambling about punctuation, you can stop reading here.



For the record: " is a double quote, ' is a single quote. [] are square brackets, {} are curly braces, () are parentheses or round brackets, and <> are angle brackets or chevrons. That makes ?? double chevrons, which are used as quotation marks in certain languages and that can be a source of confusion when you call ?? or even <> "quote marks" while talking to a majority "" audience. Anyway, the compiler is only so smart and may have meant a bracket (closing parenthesis likely) but mixing single and double quotes got it confused. It figured ')) and all that came after was still part of the Said spec (which must be single-quoted) so it never detected any following closing parentheses to match the opening ones. And since they're also called "round brackets" the error calls them that. But that's just a theory.

Offline menotu3169

Re: Complete newb can't get inventory working in template game
« Reply #6 on: July 27, 2023, 06:09:42 PM »
If by the inventory dialog you mean the one you get when you press Tab or type inventory, I don't know how look gizmo having the same effect makes sense to the player. But I may have sorely misunderstood your question.

I'm pretty sure I'm just explaining things poorly. I would like to be able to have the user type  'look gizmo' and bring up the inventory's description of the item(screenshot attached of what I would like to achieve).

Right now, the only thing I now how to do is to print a message. i.e.
Code: [Select]
(if(Said('look/gizmo'))
    Print("You see a gizmo"))

Offline Kawa

Re: Complete newb can't get inventory working in template game
« Reply #7 on: July 27, 2023, 07:18:46 PM »
That would be a default handler working with the description and view properties of the item. Iitem has a showSelf method that pops up that exact window.

Now I don't see this default handler in the SCI0 template, and I can't for the love of me get one to work. Might be because it's the middle of the night for me right now but I am stumped.

It's morning now and I completely replaced the template game's handleEvent. Where it says "; Add global said statements here" I now have:
Code: [Select]
; Add global said statements here

(switch (pEvent type?)
(evSAID
(cond
((Said 'hi')
(Print {Well hello to you too!})
)

((and
(Said 'look>')
(= i (gInv firstTrue: #saidMe))
)
(if (i ownedBy: gEgo)
(i showSelf:)
else
(PrintDontHaveIt)
)
)
((or (Said 'inventory') (Said 'look,take/inventory'))
(gInv showSelf: gEgo)
)
)
)
)
(return FALSE)
) ;method ends here

Importantly, the inventory items need said spec starting with a /, like '/gem'.
Less importantly, that last case lets you take inventory the hard way instead of by pressing tab, but "object" is in the same word group as "inventory", so I changed the Test Object's said spec to '/gizmo' for testing.
« Last Edit: July 28, 2023, 01:30:32 AM by Kawa »

Offline menotu3169

Re: Complete newb can't get inventory working in template game
« Reply #8 on: July 30, 2023, 03:19:34 PM »
Thanks again for all your help, Kawa

I still am unable to get it working though. I'm pretty sure it's because of the whole SCI Studio /ScI scripting language thing.

I'm going to spend some time trying to get SCI Companion working so I can use the Sierra language and hopefully that will resolve a lot of things. If that doesn't work . . . . i dunno.

But again, many thanks


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.036 seconds with 18 queries.