SCI1.1 Inventory Cursors in a Single View

For whatever reason, you may find that you want to separate your cursor views from the inventory screens icons and look views. This requires just a bit more work when adding items to the game, but not terribly much.


 For starters, we will need to use the view editor to create a new view in which to hold all of these images. Personally, I used view 1000 but you can of course use whatever you want, you will simply need to change the following code examples accordingly. The remaining item images for the icon and print statement views are still located in view 901 for this example.

All of the coding that we will need to do is in the invItem script, so open that in sciCompanion's script editor. Assuming you have gone through the chapter on Creating Inventory Items then you should currently have something resembling this in the script.

Code: [Select]
(instance testItem of InvItem
    (properties
        view 901
        loop 1
        cel 0     
        cursor 901
        message V_TEST
        signal $0002
        noun N_TESTER
    )
)

So now, with the cursor moving to it's own view there is an addition that we are going to need to make as well as a couple of small changes that we need to make to our previous code. First off, we will be adding a new class to the this script. I had originally approached this and made it much more work to add an item and define the cursor, when luckily Kawa came along and showed me how to make it much easier with a lot less actual coding and it all begins with this new class as well as a generic instance of a cursor. Here is the code:

Code: [Select]
//********************************************
(instance itemCursor of Cursor
  (properties
    view 1000 // this is where the view is defined
    loop 0    // changes via item instance
    cel 0     // changes via item instance
  )
)
//********************************************
(class CdItem of InvItem
(properties
cursorLoop 0
)
(method (init params)
= cursor itemCursor
(super:init(rest params))
)
(method (select params)
//--v this is the trick v--
(itemCursor:
loop(cursorLoop)
cel(cel)
)
//--^ this is the trick ^--
(super:select(rest params))
)
)

As long as this is in the invitem script somewhere, it should work. Personally I placed it directly after the invSelect instance of iconI.

With the new class and instance in place, now instead of setting up our items to be instances of InvItem, we are going to make them instances of CdItem instead. Also, since the cursors are housed in a different view and in a different way, there are a couple of other changes that can be made to our original code. The loop property for example can now be changed. As the cursor image is no longer housed in loop 0, we can place our Print statement views there instead of loop 1 like the property was originally set. As well, the cursor property can now be changed to represent the loop that this items cursor is housed in.
 
Code: [Select]
(instance testItem of CdItem
    (properties
        view 901
        loop 0
        cel 0
        cursorLoop 0
        message V_TEST
        signal $0002
        noun N_TESTER
    )
)

And there it is, we are now done. By default, all of the cursors will now be housed in view 1000, or whatever number you defined.