Author Topic: SCI1.1: Missing something with inventory items  (Read 8666 times)

0 Members and 1 Guest are viewing this topic.

Offline Cloudee1

SCI1.1: Missing something with inventory items
« on: June 21, 2015, 05:05:04 PM »
Ok, so I have started adding an item or two to the game and I seem to be missing something. I can't get the look item message to display. As well, the item icons seem to overlap a bit as well... Here is what I have done so far.

First in the messages, I added a new noun N_TOILETPAPER. Then I went in and added a message for V_LOOK, N_TOILETPAPER. I also added a verb, V_TEEPEE but that is irrelevant for now until I am ready to use the item in some way.

Next in the sq5invitem script, I added in the instance for the item.

Code: [Select]
(instance ToiletPaper of Sq5InvItem
    (properties
        view 901
        loop 1
        cursor 901
        message V_TEEPEE
        signal $0002
        noun N_TOILETPAPER
    )
)

And in the same script, up towards the top in the sq5Inv instance of scrollableinventory, I added my instance name to the add list.

Code: [Select]
            add(Money ToiletPaper) // TODO: addmore inventory items

Next I drew the necessary views, in 901 as defined in the instance of the item, and finally in the title screen script I threw in a send gEgo get statement so that I had the item at game start.

Now for the most part everything seems to be working, The item is there in my inventory, I can click on it with the arrow and the cursor changes to it. However, when I click to look at the item, the look item message is not triggered. As well, if you look at the screen shot, when the item is highlighted, it seems to overlap the money item icon a bit. Any ideas why the look item message isn't triggering... and whats up with the overlap?

« Last Edit: June 21, 2015, 05:18:06 PM by Cloudee1 »


Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline lskovlun

Re: SCI1.1: Missing something with inventory items
« Reply #1 on: June 21, 2015, 05:38:11 PM »
I'm wondering why you have set message to V_TEEPEE in the instance? You noted that it was irrelevant for the time being. As for the lack of reaction, the most obvious reason would seem to be that the if statement in the default doVerb never succeeds. You can test that by putting a Print in there temporarily.

Offline Kawa

Re: SCI1.1: Missing something with inventory items
« Reply #2 on: June 21, 2015, 05:38:39 PM »
Followed all steps but the verb, with my own crass humor to replace yours... couldn't reproduce either problem.



Could it be a size thing? That is, could it be that your TP is too large to fit in what the script expects? Coin's 21 pixels wide, and so is my thing (including some padding) so maybe...

Offline Cloudee1

Re: SCI1.1: Missing something with inventory items
« Reply #3 on: June 21, 2015, 06:00:20 PM »
Quote from: lskovlun
I'm wondering why you have set message to V_TEEPEE in the instance? You noted that it was irrelevant for the time being. As for the lack of reaction, the most obvious reason would seem to be that the if statement in the default doVerb never succeeds. You can test that by putting a Print in there temporarily.

I was really just following the money instance as my guide. I have the verb set up in some other scripts to test it. I am assuming that the message is what sets the cursor to the verb in corresponding room script uses.

Quote from: kawa
Followed all steps but the verb, with my own crass humor to replace yours... couldn't reproduce either problem.

Could it be a size thing? That is, could it be that your TP is too large to fit in what the script expects? Coin's 21 pixels wide, and so is my thing (including some padding) so maybe...

Alas, my view is also 21 pixels wide.

Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: SCI1.1: Missing something with inventory items
« Reply #4 on: June 21, 2015, 06:03:17 PM »
Can you attach your project so we can take a look?

Is the inventory script still 15, or did you move it around?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: SCI1.1: Missing something with inventory items
« Reply #5 on: June 21, 2015, 06:10:27 PM »
Well of course I moved it lol. But before you ask, I did make sure to change the message header that is included.

Project attached

« Last Edit: December 03, 2015, 12:32:14 AM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: SCI1.1: Missing something with inventory items
« Reply #6 on: June 21, 2015, 06:22:14 PM »
As I suspected, this is related to your script re-arranging. The inventory descriptions are still coming from 15.msg, which you didn't remove.

So somewhere in the code there must be a reference to resource 15 for the inventory messages.

[edit:]

In sq5initem.sc, change this:
Code: [Select]
eachElementDo(#modNum 15)

to this:
Code: [Select]
eachElementDo(#modNum SQ5INVITEM_SCRIPT)

I'll take note of that and put that define in the template game.


Note sure about the black border overlap though...
« Last Edit: June 21, 2015, 06:30:42 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: SCI1.1: Missing something with inventory items
« Reply #7 on: June 21, 2015, 06:29:07 PM »
Uh oh, Lars has me now lol

I had suspected as much myself, I just haven't managed to find the reference yet myself. I'm scared it might be somewhere in the assembly code cause so far I haven't found anything but I'm thinking probably invi.sc
« Last Edit: June 21, 2015, 06:31:44 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: SCI1.1: Missing something with inventory items
« Reply #8 on: June 21, 2015, 06:36:39 PM »
Searching all files for 15, matching whole word, makes it pretty easy to find.

As for the inventory icon border, the coin inventory view has specific offsets for each loop/cel. Your toilet paper just has them at default values (the icon dimensions are also off). That might be the reason? Maybe just copy the view.900 to view.901, and then paste your toilet paper images into it.


If that's the case, that's kind of annoying for someone adding inventory items... maybe the code should be changed to handle things with the default offset.

And yeah, when we are all still learning about how the SCI 1.1 games were set up, re-arranging the scripts just makes more possible things go wrong when trying to debug why something isn't working. So for the official template game, for the foreseeable future, I'm going to keep the scripts numbers exactly the same.
« Last Edit: June 21, 2015, 06:39:57 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: SCI1.1: Missing something with inventory items
« Reply #9 on: June 21, 2015, 06:39:44 PM »
As for the inventory icon border, the coin inventory view has offsets for each loop/cel. Your toilet paper just has them at default values. That might be the reason? Maybe just copy the view.900 to view.901, and then paste your toilet paper images into it.
Mine has offset 0?0 though?

Offline Cloudee1

Re: SCI1.1: Missing something with inventory items
« Reply #10 on: June 21, 2015, 06:48:27 PM »
Yeah, found and fixed the print statement... In the Sq5InvItem script

Code: [Select]
   eachElementDo(#modNum SQ5INVITEM_SCRIPT)

Unfortunately changing the offset had no effect.
« Last Edit: June 21, 2015, 06:53:12 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: SCI1.1: Missing something with inventory items
« Reply #11 on: June 21, 2015, 07:22:08 PM »
Ok. the highlight thing (actually the inv items are drawn overlapping) might be a bug in the drawInvWindow method. Either improperly decompiled, or maybe it got changed after decompilation or something. I'll add it to the list of bugs to investigate.

Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: SCI1.1: Missing something with inventory items
« Reply #12 on: June 24, 2015, 08:21:32 AM »
Ok, this will hopefully be my last question about the general functionality of inventory items.

I am having trouble combining two items. The anticipated result being to put the initial 2 and to get a 3rd.

So here is what I have going on... There is the ToiletPaper item

Code: [Select]
//****************************************************
(instance ToiletPaper of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_TOILETPAPER
        message V_TEEPEE
        signal $0002
        noun N_TOILETPAPER
    )
  (method (init)
  = cursor toiletpaperCursor
  (super:init())
  )
)
(instance toiletpaperCursor of Cursor(properties view 1000 loop 0 cel ITEM_TOILETPAPER))

and there's the FilledBasket item, which is what I am hoping to get out of combining the two items.

Code: [Select]
(instance FilledBasket of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_FILLEDBASKET
        message V_FBASKET
        signal $0002
        noun N_FBASKET
    )
  (method (init)
  = cursor fullbasketCursor
  (super:init())
  )
)
(instance fullbasketCursor of Cursor(properties view 1000 loop 0 cel ITEM_FILLEDBASKET))

and then there is the EmptyBasket item. This is where I am attempting to code the combination of the two items. I spent several hours last night trying to get this to work right... and for the most part this sort of does. But not really.

I included a doVerb method in the item instance and when the verb is the toilet paper verb, I attempt to swap the items around. If I include the print or the testmessager as part of the verb case, bad things happen, so you'll notice that I do still include the super doverb in the case just to get the dialog to occur. Also, I would rather refresh the inventory window than close it, but I don't know the best way to accomplish that. And finally, the toilet paper items cursor remains the active cursor. Even though the item gets dropped.

Code: [Select]
(instance EmptyBasket of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_EMPTYBASKET
        message V_BASKET
        signal $0002
        noun N_BASKET
    )
  (method (init)
  = cursor emptybasketCursor
  (super:init())
  )
 
  (method (doVerb theVerb param2 param3)
  (switch (theVerb)
      (case V_TEEPEE
        // (send gTestMessager:say(N_BASKET V_TEEPEE 0)) // Noun, Verb, Condition

      //     (Print:addText("You wisely throw the toilet paper into the empty basket.")
      //           init()
      //      )
          (send gEgo:put(ITEM_TOILETPAPER))
          (send gEgo:put(ITEM_EMPTYBASKET))
          (send gEgo:get(ITEM_FILLEDBASKET))
        (super:doVerb(theVerb param2 rest param3))
          (send gSq5Inv:hide(1))
      )
      (default (super:doVerb(theVerb param2 rest param3)))
    )
  )
)
(instance emptybasketCursor of Cursor(properties view 1000 loop 0 cel ITEM_EMPTYBASKET))

Has anyone else managed to successfully combine two items. This was as close as I could come on my own.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Cloudee1

Re: SCI1.1: Missing something with inventory items
« Reply #13 on: June 24, 2015, 09:45:45 PM »
So I lied about that being my last question regarding inventory items... Which I still haven't figured out yet.

But anyway, I have another one. So we start off with money as a built in inventory item. That's all fine and dandy but we are going to need a way to know how much money we have, or rocks, or empty potion bottles etc.

I am just 20 pixels from having this sorted out but I just can't seem to get it done. Again, this is something I have spent a couple of hours trying to sort out and again. This is as close as I can come on my own.

So first, in the main script I added a global variable to keep track of just how much cash we currently have on hand.
Code: [Select]
  gTotalMoney= 150

Then again, I added a doVerb method to the money items instance.
Code: [Select]
(instance Money of Sq5InvItem
    (properties
        view 1001
        loop 0   // icon view
        cel ITEM_MONEY   // icon cel
        message V_PAY
        signal $0002
        noun N_MONEY
    )
    (method (init)
  = cursor moneyCursor
    (super:init())
    )

    (method (doVerb theVerb param2)
    (var temp0,temp1,tempStr1[40], dialog)
    (if(not modNum)
       = modNum gModNum
    )
        (switch (theVerb)
            (case V_LOOK
            (if (== gTotalMoney 1)
              Format(@tempStr1 "You have %d single solitary dollar." gTotalMoney)
                )
                (else
              Format(@tempStr1 "You have %d bucks." gTotalMoney)
                )
                = temp1 CelWide(view loop cel)
                = temp0 GetPort()
                      (Print:
                        addIcon(view loop cel 1 1)
                        addText(@tempStr1)
                        init()
                      )
                SetPort(temp0)
            )
            (default
                (super:doVerb(theVerb param2))

            )
        )
    )

)
(instance moneyCursor of Cursor(properties view 1000 loop 0 cel ITEM_MONEY))

As you can see in the screenshot, I am so close... but the text and the icon overlap. Please help.... With this and the last issue. They are really driving me bananas
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: SCI1.1: Missing something with inventory items
« Reply #14 on: June 24, 2015, 10:32:04 PM »
It looks like you're passing 1 and 1 for the position of the icon.
What happens if you change those numbers so it is positioned below the text?

Also, do you really need that GetPort/SetPort stuff?
Check out my website: http://icefallgames.com
Groundhog Day Competition


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

Page created in 0.122 seconds with 22 queries.