Author Topic: [Solved] SCI0 How to "look at" Inventory Items?  (Read 602 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

[Solved] SCI0 How to "look at" Inventory Items?
« on: June 12, 2022, 11:22:17 PM »
Here's my problem:
When the player types "look at widget," how do I open that item [the widget] as if from the inventory menu? I've looked at the Inv script as well as the following bit of code from ErikorOakford's SCI0 template:
Code: [Select]
((Said 'look[<at]>')
(cond
;look at inventory items
((= i (inventory saidMe:))
(if (i ownedBy: ego)
(i showSelf:)
else
(DontHave)
)
)
But I've been unable to produce anything beyond opening up the menu with all the items listed by using the same command as in the menubar:
Code: [Select]
(gInv showSelf: gEgo) That's nice and all, but I'd like to zero in on the particular item "looked" at by the plater.
Erik's script looks like it should work (and I'm sure it does in his template), but I'm using the standard template, and even correcting for a few differences in naming conventions, I'm still not returning anything that runs.
I know it's actually a fairly simple command, something already there in the template, I'm just not fitting the pieces together and need a hand.
Thanks.
« Last Edit: June 14, 2022, 06:44:50 PM by Doan Sephim »


Artificial Intelligence Competition

Offline troflip

Re: How to "look at" Inventory Items?
« Reply #1 on: June 13, 2022, 06:37:09 PM »
What does the said property look like for your inventory items?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Doan Sephim

Re: How to "look at" Inventory Items?
« Reply #2 on: June 13, 2022, 09:14:26 PM »
What does the said property look like for your inventory items?
Something like this:
Code: [Select]
(instance Hammer of Iitem ; Item 2
(properties
said 'hammer'
description 2
owner 0
view 612
loop 0
cel 0
script 0
name "Hammer"
)
)

Offline troflip

Re: How to "look at" Inventory Items?
« Reply #3 on: June 14, 2022, 12:32:20 PM »
Doesn't there need to be a '/' before the word in the said property? Otherwise it's looking for "hammer" in the first part of the phrase you typed in.

The code needs to do this:
Code: [Select]
(Said 'look>')
followed by this:
Code: [Select]
(Said '/hammer')
which is basically the equivalent of
Code: [Select]
(Said 'look/hammer')
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Doan Sephim

Re: How to "look at" Inventory Items?
« Reply #4 on: June 14, 2022, 02:06:28 PM »
Doesn't there need to be a '/' before the word in the said property? Otherwise it's looking for "hammer" in the first part of the phrase you typed in.

The code needs to do this:
Code: [Select]
(Said 'look>')
followed by this:
Code: [Select]
(Said '/hammer')
which is basically the equivalent of
Code: [Select]
(Said 'look/hammer')
That could be. I will check it out.
Edit 1: Yes, that does help!

Edit 2: I'm getting the same result, which is a "Oops! You tried something we didn't think of" crash error. I was getting that before with Erik's code, so it's not the /hammer part. I wonder if he has more and/or less to his template that's fixing for this. I'll test around and see if I can determine exactly what's causing the crash.

Edit 3: The part that is causing the crash is the "(i ownedBy: gEgo)" and the "(i showSelf:)" I'm guessing variables cannot be used in this way? So any idea what's allowing it to work with Erik's template? He put "i" as a variable to the changeState method, and I followed that example in my code as well.

Good news is that now it's identifying the typed command by the player, now all that's left is how to spit out the correct description.

Edit 4: So I apparently did not put &tmp beofre the i in the method when declaring the variable. Everything now seems to work correctly. Looks like this one is solved. Erik's code works exactly as intended, but Troflip, THANK YOU, I would not have ever thought of the said properties needing the "/" - and that was clearly a huge component of my problems.
« Last Edit: June 14, 2022, 02:40:07 PM by Doan Sephim »
Artificial Intelligence Competition


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

Page created in 0.044 seconds with 22 queries.