Inventory Screen
Forum rules
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Re: Inventory Screen
hi, how can i stop inventory screen to close itself up when you click on an item? I wanted to close it only with Close Inventory textbutton/
Thanks
Thanks
Re: Inventory Screen
Hello Tesspolar, see my comments/code on page 5 (and 6). You will see that I add a "Imagebutton" for that function, and blocked the older code with # above my imagebutton code.
#Imagebutton for hide inventory:
imagebutton idle "HUDINV_idle001.png" hover "HUDINV_hover001.png" xpos 0.933 ypos 0.417 action [Hide("inventory_screen")]
And I also did some changes to made this inventory code fit to my basic requirements in my project.
Just read the last two pages and compare to your code. You need to put some short lines in the screen.rpy for the imagebutton. You need to do a png/jpg pic for the button too. It is relative easy to do, as I am also beginner in Renpy. Just try around what happens. Made notes on paper. Do one change at a time to see what is doing what.
#Imagebutton for hide inventory:
imagebutton idle "HUDINV_idle001.png" hover "HUDINV_hover001.png" xpos 0.933 ypos 0.417 action [Hide("inventory_screen")]
And I also did some changes to made this inventory code fit to my basic requirements in my project.
Just read the last two pages and compare to your code. You need to put some short lines in the screen.rpy for the imagebutton. You need to do a png/jpg pic for the button too. It is relative easy to do, as I am also beginner in Renpy. Just try around what happens. Made notes on paper. Do one change at a time to see what is doing what.
Last edited by M-77 on Sun Aug 23, 2020 5:40 pm, edited 1 time in total.
Re: Inventory Screen
Thank you. Yeah it was textbutton and i switched it to imagebutton and it works nice right nowM-77 wrote: ↑Wed Apr 01, 2020 3:51 pm Hello Tesspolar, see my comments/code on page 5 (and 6). You will see that I add a "Imagebutton" for that function, and blocked the older code with # above my imagebutton code.
#Imagebutton for hide inventory:
imagebutton idle "HUDINV_idle001.png" hover "HUDINV_hover001.png" xpos 0.933 ypos 0.417 action [Hide("inventory_screen")]
And I also did some changes to made this inventory code fit to my basic requirements in my project.
Just read the last two pages and compare to your code. You need to put some short lines in the screen.rpy for the imagebutton. You need to do a png/jpg pic for the botton too. It is relative easy to do, as I am also beginner in Renpy. Just try around what happens. Made notes on paper. Do one change at a time to see what is doing what.
Re: Inventory Screen
Hi! How can you buy or add more than one item (in bulk)? Does anyone know?
Also, how to make a max inventory space and make a message notifying the player that his bag is full? And selling items to a vendor would be possible with this code? Thanks in advance.
Code: Select all
$inventory.buy(gun)
"Me" "Nice"
$inventory.add(laser)
Re: Inventory Screen
Hello "Ace94", I use my version of this only to show the player what items he has. And description of the items.
You can use variables in addition to the "add" "drop" items commands to remove items from the inventory.
This before "label start":
#Inventotry Item markers
Item_Spezielles_Oel = False
This in game;
Just a line after the "label start", in the list for the inventory:
default specialoil = Item("Special Oil", image="gui/inv_Special_Oil.png")
And when you obtain such item in game, like at a shop/menu code should tell this:
$ Item_Spezielles_Oel = True
$ inventory.add(specialoil)
When you use it up in game your code should tell this both:
$ Item_Spezielles_Oel = False
$ inventory.drop(specialoil)
So I use double hardcoding to simulate action in my inventory. Hope this gives you an idea.
You can use variables in addition to the "add" "drop" items commands to remove items from the inventory.
This before "label start":
#Inventotry Item markers
Item_Spezielles_Oel = False
This in game;
Just a line after the "label start", in the list for the inventory:
default specialoil = Item("Special Oil", image="gui/inv_Special_Oil.png")
And when you obtain such item in game, like at a shop/menu code should tell this:
$ Item_Spezielles_Oel = True
$ inventory.add(specialoil)
When you use it up in game your code should tell this both:
$ Item_Spezielles_Oel = False
$ inventory.drop(specialoil)
So I use double hardcoding to simulate action in my inventory. Hope this gives you an idea.
-
- Regular
- Posts: 62
- Joined: Thu Dec 31, 2020 3:37 pm
- Contact:
Re: Inventory Screen
Hello All
First of all, I have no idea how to include code in that nice green colour I see above, so I'd appreciate being told - obviously, the first jump line in the code below should be indented but I can't for the life of me work out how to display anything as code. The c and /c tags seem to do precisely nothing.
I've started using this inventory system in my science fiction game and am finding it very useful - but I have a slight problem and wonder if anyone can point me in the right direction. I've updated the use() method so that it sets a global variable called shown_badge if the player opens the inventory and clicks the police badge item at the right time. Then, in the main game, I've got something like this:
thug "Hey, what are you doing here?"
if shown_badge == True:
jump arrest_thug
thug "Eat lead!"
jump i_am_dead
The idea is that, while the say screen is displaying the text "Hey, what are you doing here?", the player can open the inventory and click the police badge, thereby identifying themselves as a policeman and sending the game to the arrest_thug label. This works, but the say screen is not removed when the player clicks the badge and remains displaying the text "Hey, what are you doing here?" until the player clicks. So how do I make the say screen go away and jump to the arrest_thug label the moment the player clicks the badge in the inventory?
TIA.
First of all, I have no idea how to include code in that nice green colour I see above, so I'd appreciate being told - obviously, the first jump line in the code below should be indented but I can't for the life of me work out how to display anything as code. The c and /c tags seem to do precisely nothing.
I've started using this inventory system in my science fiction game and am finding it very useful - but I have a slight problem and wonder if anyone can point me in the right direction. I've updated the use() method so that it sets a global variable called shown_badge if the player opens the inventory and clicks the police badge item at the right time. Then, in the main game, I've got something like this:
thug "Hey, what are you doing here?"
if shown_badge == True:
jump arrest_thug
thug "Eat lead!"
jump i_am_dead
The idea is that, while the say screen is displaying the text "Hey, what are you doing here?", the player can open the inventory and click the police badge, thereby identifying themselves as a policeman and sending the game to the arrest_thug label. This works, but the say screen is not removed when the player clicks the badge and remains displaying the text "Hey, what are you doing here?" until the player clicks. So how do I make the say screen go away and jump to the arrest_thug label the moment the player clicks the badge in the inventory?
TIA.
Re: Inventory Screen
Just want to share how thankful I am for this Leon!leon wrote: ↑Tue Sep 03, 2013 6:17 pm While there are a couple of inventory examples in the cookbook already, they don't address using pictures for inventory items. So here's one that does that, completed with hover effects, tooltips and selectable items. The inventory system here is using classes, so you might want to check Money and Inventory Systems for more detailed explanation on how these work.
fancy_inventory_screen.png
The code is taken from Time Labyrinth and simplified for this example. Feel free to use the code however you like (same goes for Time Labyrinth code).
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab
Art Portfolio: https://www.instagram.com/theartofjoshlab/
Working on a personal Visual Novel~
Art Portfolio: https://www.instagram.com/theartofjoshlab/
Working on a personal Visual Novel~
- ZeAwesomeHobo
- Newbie
- Posts: 4
- Joined: Mon Jul 19, 2021 12:10 am
- Contact:
Re: Inventory Screen
EDIT: I realized there were quite a few more comments in this thread, and after looking through them I figured out the issue. Both values needed to be changed.
I'm having trouble moving the top left item x position. Y works just find, but regardless of what number I plug in for "x," the item grid's position remains the same.
Even with negative numbers, there's no change. I haven't had any other problems, I just want to move the grid to the center of my game's screen.
I'm having trouble moving the top left item x position. Y works just find, but regardless of what number I plug in for "x," the item grid's position remains the same.
Code: Select all
screen inventory_screen:
add "gui/inventory.png" xalign .5 yalign .5
modal True
#use battle_frame(char=player, position=(.97,.20)) # we show characters stats (mp, hp) on the inv. screen
#use battle_frame(char=dog, position=(.97,.50))
hbox align (.95,.04) spacing 5:
textbutton "Close Inventory" action [ Hide("inventory_screen"), Return(None)]
$ x = 960 # coordinates of the top left item position
$ y = 200
$ i = 0
$ sorted_items = sorted(inventory.items, key=attrgetter('element'), reverse=True) # we sort the items, so non-consumable items that change elemental damage (guns) are listed first
$ next_inv_page = inv_page + 1
if next_inv_page > int(len(inventory.items)/9):
$ next_inv_page = 0
for item in sorted_items:
if i+1 <= (inv_page+1)*9 and i+1>inv_page*9:
$ x += 190
if i%3==0:
$ y += 170
$ x = 515
$ pic = item.image
$ my_tooltip = "tooltip_inventory_" + pic.replace("gui/inv_", "").replace(".png", "") # we use tooltips to describe what the item does.
imagebutton idle pic hover pic xpos x ypos y action [Hide("gui_tooltip"), SetVariable("item", item), Hide("inventory_screen"), item_use] hovered [ Play ("sound", "Types.ogg"), Show("gui_tooltip", my_picture=my_tooltip, my_tt_ypos=693) ] unhovered [Hide("gui_tooltip")] at inv_eff
if player.element and (player.element==item.element): #indicate the selected gun
add "gui/selected.png" xpos x ypos y anchor(.5,.5)
$ i += 1
if len(inventory.items)>9:
textbutton _("Next Page") action [SetVariable('inv_page', next_inv_page), Show("inventory_screen")] xpos .475 ypos .83
-
- Regular
- Posts: 62
- Joined: Thu Dec 31, 2020 3:37 pm
- Contact:
Re: Inventory Screen
I'm using this inventory system quite extensively in my game and it works nicely, but there's one thing which I can't work out and seems to be around the wrong way logically. When I press the "close inventory" button, the game moves on to the next say screen as though the player clicked, which it presumably shouldn't do. For example:
k "Hello, everyone"
k "What just happened?"
If the player brings up the inventory while "Hello, everyone" is displayed and then closes the inventory with the "close inventory" button, the game moves on to "What just happened?" instead of staying where it was.
Conversely, if I choose any item from the inventory and click it, the inventory vanishes (which I want) and I'm still looking at "Hello, everyone".
I would like it around the other way. Pressing "Close Inventory" leaves the game where it is, but clicking an item moves it on to "What just happened". In my particular game, the player has to open the inventory while a character is asking him for ID, and click the ID. When he does so, the use() method sets a variable and then the game moves onto the next line of code when the inventory disappears which checks if the variable is set.
However much I try, I cannot work out what it is that makes the Close Inventory button move on in order to replicate this when the player clicks an item. Nothing I try works.
k "Hello, everyone"
k "What just happened?"
If the player brings up the inventory while "Hello, everyone" is displayed and then closes the inventory with the "close inventory" button, the game moves on to "What just happened?" instead of staying where it was.
Conversely, if I choose any item from the inventory and click it, the inventory vanishes (which I want) and I'm still looking at "Hello, everyone".
I would like it around the other way. Pressing "Close Inventory" leaves the game where it is, but clicking an item moves it on to "What just happened". In my particular game, the player has to open the inventory while a character is asking him for ID, and click the ID. When he does so, the use() method sets a variable and then the game moves onto the next line of code when the inventory disappears which checks if the variable is set.
However much I try, I cannot work out what it is that makes the Close Inventory button move on in order to replicate this when the player clicks an item. Nothing I try works.
-
- Newbie
- Posts: 2
- Joined: Mon Nov 21, 2016 10:23 am
- Contact:
Re: Inventory Screen
Hello everyone. I have been using this system in my game for a long time and everything works well. Tell me how can I add a pop-up confirmation or rejection of a purchase?
-
- Newbie
- Posts: 6
- Joined: Thu Aug 04, 2011 7:28 pm
- Contact:
Re: Inventory Screen
EDIT: I'm also going to make my own edit here, but be extremely specific to anyone else coming in.
The first X value definitely needs to be changed. The "other" value that was reference is under the i%3 subsection. Those are the two you need to edit:
The first X value definitely needs to be changed. The "other" value that was reference is under the i%3 subsection. Those are the two you need to edit:
Can you please outline what you did? Because I looked in the thread too, and didn't find an exact, specific fix. Using M-77's code didn't work for me.ZeAwesomeHobo wrote: ↑Wed Aug 04, 2021 5:16 pm EDIT: I realized there were quite a few more comments in this thread, and after looking through them I figured out the issue. Both values needed to be changed.
However. There is a caveat to this during editing. And you're going to be hitting a wall for hours if it's not obvious.Code: Select all
[color=#BF4000]$ x = -960[/color] # coordinates of the top left item position (this is the first value you change) $ y = 200 $ i = 0 $ sorted_items = sorted(inventory.items, key=attrgetter('element'), reverse=True) # we sort the items, so non-consumable items that change elemental damage (guns) are listed first $ next_inv_page = inv_page + 1 if next_inv_page > int(len(inventory.items)/9): $ next_inv_page = 0 for item in sorted_items: if i+1 <= (inv_page+1)*9 and i+1>inv_page*9: $ x += 350 if i%3==0: $ y += 170 $[color=#BF4000] x = 960[/color] # this is the other value you change. Make sure they match!
Both numbers have to match exactly. If they're off in any way, it'll go to some "default" position, and not move regardless.
Hope that helps.
I'm having trouble moving the top left item x position. Y works just find, but regardless of what number I plug in for "x," the item grid's position remains the same.
Even with negative numbers, there's no change. I haven't had any other problems, I just want to move the grid to the center of my game's screen.Code: Select all
screen inventory_screen: add "gui/inventory.png" xalign .5 yalign .5 modal True #use battle_frame(char=player, position=(.97,.20)) # we show characters stats (mp, hp) on the inv. screen #use battle_frame(char=dog, position=(.97,.50)) hbox align (.95,.04) spacing 5: textbutton "Close Inventory" action [ Hide("inventory_screen"), Return(None)] $ x = 960 # coordinates of the top left item position $ y = 200 $ i = 0 $ sorted_items = sorted(inventory.items, key=attrgetter('element'), reverse=True) # we sort the items, so non-consumable items that change elemental damage (guns) are listed first $ next_inv_page = inv_page + 1 if next_inv_page > int(len(inventory.items)/9): $ next_inv_page = 0 for item in sorted_items: if i+1 <= (inv_page+1)*9 and i+1>inv_page*9: $ x += 190 if i%3==0: $ y += 170 $ x = 515 $ pic = item.image $ my_tooltip = "tooltip_inventory_" + pic.replace("gui/inv_", "").replace(".png", "") # we use tooltips to describe what the item does. imagebutton idle pic hover pic xpos x ypos y action [Hide("gui_tooltip"), SetVariable("item", item), Hide("inventory_screen"), item_use] hovered [ Play ("sound", "Types.ogg"), Show("gui_tooltip", my_picture=my_tooltip, my_tt_ypos=693) ] unhovered [Hide("gui_tooltip")] at inv_eff if player.element and (player.element==item.element): #indicate the selected gun add "gui/selected.png" xpos x ypos y anchor(.5,.5) $ i += 1 if len(inventory.items)>9: textbutton _("Next Page") action [SetVariable('inv_page', next_inv_page), Show("inventory_screen")] xpos .475 ypos .83
Who is online
Users browsing this forum: No registered users