I'm very new to ren'py and don't know any python, so I've been having a really hard time figuring out how to create the inventory system I want. I found Leon's awesome inventory system, and got that to work somewhat but it was lacking the one thing that I really wanted it to do, which was allow the user to drag items out onto hotspots and discard them from the inventory. Because I was having a lot of trouble trying to incorporate this drag and drop system into Leon's system, I pulled back the idea a bit to just be clicking and dragging a word from the inventory onto something else on the screen.
Let's say that I want to just drag the word "Shoe Laces" onto the drawer in the scene (I know it doesn't make sense, but just for example). How would I do this?
here's the relevant code:
Code: Select all
init python:
showitems = True
def display_items_overlay():
if showitems:
inventory_show = "Inventory: "
for i in range(0, len(items)):
item_name = items[i].title()
if i > 0:
inventory_show += ", "
inventory_show += item_name
ui.frame()
ui.text(inventory_show)
config.overlay_functions.append(display_items_overlay)
# Inventory and such.
default items = []
default flower = False
default keys = False
default diary = False
default laces = False
#image map
screen dianasroomclickable:
imagemap:
ground "diana roomwindowclosed.png"
idle "diana roomidle.png"
hover "diana roomhover.png"
alpha False
# This is so that everything transparent is invisible to the cursor.
hotspot (730, 53, 325, 287) clicked Jump("openwindow")
hotspot (539, 249, 71, 71) clicked Jump("phone")
hotspot (821, 340, 110, 100) clicked Jump("turntable")
hotspot (497, 317, 122, 134) clicked Jump("drawer")
hotspot (408, 406, 91, 63) clicked Jump("shoes")
hotspot (254, 419, 68, 61) clicked Jump("hat")
hotspot (10, 141, 405, 263) clicked Jump("bed")
hotspot (1120, 246, 81, 84) clicked Jump("dianasdoor")
hotspot (650, 435, 463, 119) clicked Jump("rug")
hotspot (493, 66, 97, 174) clicked Jump("cure")
label start:
label dianasroommap:
call screen dianasroomclickable
label openwindow:
scene dianas roomstill
menu:
"Eavesdrop on Van Leiu and police" if tell == "snitch" and eavesdropped == False:
$ tattle = True
jump listen
"Sneak out" if eavesdropped == True:
jump whichway
"Sneak out" if tell == "cover":
jump whichway
"Leave window closed":
"I'll just leave this closed for now..."
jump dianasroommap
label turntable:
scene dianas roomstill
menu:
"Play a record":
"Doesn't seem to be working right now..."
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label drawer:
scene dianas roomstill
menu:
"Open Karen's Drawer":
"Damn it, it's stuck!"
jump dianasroommap
"Nevermind":
"I should probably not go through her things anyway..."
jump dianasroommap
label shoes:
scene dianas roomstill
menu:
"Smell your chucks" if laces == False:
"WOW. Pungent."
jump laces
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
"Smell your chucks" if laces == True:
"WOW. Pungent."
jump dianasroommap
label laces:
scene dianas roomstill
menu:
"Take the shoelaces":
$ laces = True
$ items.append("Shoe Laces")
d "Who knows when a shoe lace could come in handy!"
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label phone:
scene dianas roomstill
menu:
"Call someone":
"no one to call for now"
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label hat:
scene dianas roomstill
menu:
"Look at hat":
"Eat em' up cats!"
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label bed:
scene dianas roomstill
menu:
"Sleep":
"I don't really feel like sleeping just yet..."
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label dianasdoor:
scene dianas roomstill
menu:
"Go out into the hall":
"Maybe I should just check and see if Mary's home yet."
jump hallwayMap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label rug:
scene dianas roomstill
menu:
"Move rug":
"There's nothing under here"
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap
label cure:
scene dianas roomstill
menu:
"Admire Robert Smith":
"Wonder if the carpet matches the drapes?"
jump dianasroommap
"Nevermind":
"I'll just leave this here for now..."
jump dianasroommap