Author Topic: Inventory Display  (Read 4903 times)

gwal

  • Regular
  • **
  • Posts: 69
  • Game Progress: Outer Space / Items
    • View Profile
Inventory Display
« on: 2006-03-02, 07:13:01 PM »
I have a couple of questions about changing inventory display with scripting. My first question is this: If I have an item which is normally displayed, but isn't on a specific map, how can I make it display? Something like the player activating a special function which triggers the item to be displayed.
My second question is this: If you have an item displayed as a bar, how can you increase its length? I experimented with InvBarLength. but it didn't seem to work.

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: Inventory Display
« Reply #1 on: 2006-03-02, 10:39:16 PM »
The following code shows 4 common commands for changing what inventory the map displays "on the fly".  As far as I know, script is the only way to do this. 

Code: [Select]
With ProjectObj.GamePLayer
    'Change how the map displays inventory with the following commands:
    .rMap.DisplayInventory.SetAll
    .rMap.DisplayInventory.ClearAll
    .rMap.DisplayInventory.SetMember 0   'use whatever number you want to change here
    .rMap.DisplayInventory.ClearMember 1  'use whatever number you want to change here
   
   'When done, and want to update how the map displays inventory:
    .PrepareMapInventory
  End With

If you run the code as written, it will make it so the only inventory displayed is #1 (it is 2 in SGDK, but 1 in code since in code it starts counting at 0, not 1)


Unfortunately, it is impossible to change many aspects of an inventory's display properties dynamically (ie you have to set them when you make them and can only change them at design time, never at runtime)  Things you cant change: InvBarBackgroundColor, InvBarColor, InvBarLength, InvBarOutlineColor, InvBarThickness, InvDisplayX, InvDisplayY,InvIconTileIdx, InvIconTilesetIdx

My only suggestion for changing bar length is to have 2 or more inventory and just change which ones of them are displayed if you want a longer/shorter bar.  This is a bad work-around; however, if you are using this inventory in a lot of special functions.  Actuallly, you could get a script that automatically equates the displayed inventory to the "real" inventory (that is used by your special functions and whatnot)

I think if we had a better idea of what you were trying, we could suggest a more specific solution.

*Goes to bed*



bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Inventory Display
« Reply #2 on: 2006-03-03, 06:51:10 AM »
Actually you should be able to set all those bar properties with one method of the Player object called InvSetBarInfo.

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: Inventory Display
« Reply #3 on: 2006-03-03, 04:14:49 PM »
grrrr. >:(

I wish I woulda saw that earlier.  I just saw that you couldn't change the properties directly, but never thought to look in methods.

Very helpful.


Now I have a question for you.  Is it possible to display inventory tiles as transparent tiles?

*Walks out laughing*

gwal

  • Regular
  • **
  • Posts: 69
  • Game Progress: Outer Space / Items
    • View Profile
Re: Inventory Display
« Reply #4 on: 2006-03-03, 06:22:58 PM »
I think if we had a better idea of what you were trying, we could suggest a more specific solution.

Well, the first level of my game serves as a type of tutorial to teach players the controls and stuff. Anyway, I wanted to start out with no inventory items being displayed on the screen. Then, as the player learns what each one item does, the item is displayed.

As for your more recent question, I don't think it's possible to display inventory tiles as transparent; that really bugs me too... :-\

The reason I wanted to increase the length of the bar was because I was using the item as the player's HP. Since you can level up and increase your max HP in the game, I thought it would look good visually if the bar itself got longer. So how do you use InvSetBarInfo?

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Inventory Display
« Reply #5 on: 2006-03-03, 09:24:09 PM »
Here's the template to use InvSetBarInfo on the first inventory item (Number 0):

Code: [Select]
Dim Index, BarColor, BarThickness, BarLength, BackgroundColor, OutlineColor
Index = 0   'Get first inventory Item
With ProjectObj.GamePlayer
   BarColor = .InvBarColor(Index)
   BarThickness = .InvBarThickness(Index)
   BarLength = .InvBarLength(Index)
   BackgroundColor = .InvBarBackgroundColor(Index)
   OutlineColor = .InvBarOutlineColor(Index)
   .InvSetBarInfo(Index, BarColor, BarThickness, BarLength, BackgroundColor, OutlineColor)
End With

If you want to change the length of the bar by adding 10 to it, just change this line:

Code: [Select]
   BarLength = .InvBarLength(Index)
To this:

Code: [Select]
   BarLength = .InvBarLength(Index) + 10
And just change the Index value to switch which inventory item you're applying this to.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Inventory Display
« Reply #6 on: 2006-03-04, 07:08:51 AM »
Now I have a question for you.

gwal

  • Regular
  • **
  • Posts: 69
  • Game Progress: Outer Space / Items
    • View Profile
Re: Inventory Display
« Reply #7 on: 2006-03-05, 02:51:03 PM »
thanks once again for the code