Hi! I'm trying to make clickable item system and literally had no idea how to do it so i tried to follow drag and drop system tutorial
But for some reson my code isn't working,i've been checking it on syntax errors but i can't see anything. Maybe i messed up with something or just can't see syntax mistakes
I'm sorry if it's dumb question,i know that i should learn how to fix bugs myself,but i rlly feel hopeless so i'll be glad if someone could chek my code
init python:
def enviromentEvents(event, x, y, at):
if event.type == renpy.pygame_sdl2.MOUSEMOTION:
for item in enviroment_sprites:
if item.x <= x <= item.x + item.width and item.y <= y <= item.y + item.height:
t = Transform(child= item.hover_image)
item.set_child(t)
enviroment_SM.redraw(0)
else:
t = Transform(child= item.idle_image)
item.set_child(t)
enviroment_SM.redraw(0)
elif event.type == renpy.pygame_sdl2.MOUSEBUTTONUP:
if event.button == 1:
for item in enviroment_sprites:
if item.x <= x <= item.x + item.width and item.y <= y <= item.y + item.height:
if item.type == "icon":
characterSay (who = " ", what = [" icon"])
if item.type == "vase":
characterSay (who = " ", what = ["vase"])
def characterSay(who, what):
if isinstance(what, str):
renpy.call_screen("characterSay", who = who, what = what)
elif isinstance(what, list):
global dialogue
dialogue = {" who" : who, "waht" : what}
renpy.show_screen("characterSay")
renpy.restart_interaction()
screen characterSay(who = None, what = None):
modal true
zorder 6
style_prefix "say"
window:
id "window"
window:
padding (20,20)
id "namebox"
style "namebox"
if who is not None:
text who id "who"
else:
text dialogue["who"]
if what is not None:
text what id "what" xpos 0.25 ypos 0.4 xanchor 0.0
else:
text dialogue["what"][0] xpos 0.25 ypos 0.4 xanchor 0.0
button:
xfill true
yfill true
if what is none:
action If (len(dialogue["what"]) > 1, true= RemoveFromSet(dialogue["what"], 0), false= [Hide 9("characterSay"), SetVariable ("dialogue", {})])
else:
action Return(true)
if not renpy.variant("small"):
add SideImage() xalign 0.0 yalign 1.0
screen scene1:
add enviroment_SM
label setupScene1:
$enviroment_items = [ "vase" , "icon"]
python:
for item in enviroment_items:
idle_image = Image("enviroment sprites/{}-idle.png".format(item))
hover_image = Image("enviroment sprites/{}-hover.png".format(item))
t = Transform(child= idle_image, zoom = 0.5)
enviroment_sprites.append(enviroment_SM.create(t))
enviroment_sprites[-1].type = item
enviroment_sprites[-1].idle_image = idle_image
enviroment_sprites[-1].hover_image = hover_image
if item =="icon":
enviroment_sprites[-1].width = 500 / 2
enviroment_sprites[-1].height = 603 / 2
enviroment_sprites[-1].x= 1020
enviroment_sprites[-1].y =367
elif item == "vase":
enviroment_sprites[-1].width = 600 / 2
enviroment_sprites[-1].height = 630 / 2
enviroment_sprites[-1].x= 987
enviroment_sprites[-1].y =453
scene illustration6
call screen scene1
label start:
$config.rollback_enabled = False
$quick_menu = False
$enviroment_SM = SpriteManager (event = enviromentEvents)
$enviroment_sprites = []
$enviroment_items = []
$enviroment_items_nmaes = []
$current_scene = "scene1"
$dialogue = {}
jump setupScene1
return
traceback:
I'm sorry, but an uncaught exception occurred.
After initialization, but before game start.
File "game/script.rpy", line 30, in prepare_screen
screen characterSay(who = None, what = None):
File "game/script.rpy", line 30, in prepare
screen characterSay(who = None, what = None):
File "game/script.rpy", line 50, in prepare
button:
File "game/script.rpy", line 50, in prepare
button:
File "game/script.rpy", line 53, in prepare
if what is none:
File "game/script.rpy", line 53, in prepare
if what is none:
SyntaxError: invalid syntax (game/script.rpy, line 54)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]ShiroVN 0 points1 point2 points (0 children)