Here is the screen's snippet:
Code: Select all
screen pointnclick_screen(location):
tag pointnclick
layer "master"
zorder 0
imagemap:
ground [location.name]
for i,spot in enumerate(location.spots):
if spot.is_visible():
imagebutton:
pos spot.position
idle spot.sprite
focus_mask spot.sprite
action Jump(spot.target)
Code: Select all
class Location:
def __init__(self, name, spots):
self.name = name
self.spots = spots
class Hotspot:
def __init__(self, position, sprite, target = None, visible = None):
self.position = position
self.sprite = sprite
self.target = target
self.visible = visible
def is_visible(self):
if self.visible:
return eval(self.visible)
else:
return True
Code: Select all
define my_scene = Location("bg myscene",
[
# Foo
Hotspot((2918, 1027),
sprite = "sprite foo",
target = "ask_foo"),
# Bar
Hotspot((6370, 957),
sprite = "sprite bar",
target = "goto_bar",
visible = "not need_to_ask_foo"),
]
- I can't write the variable name as is, because - according to the compiler - the variable is not known at that point, and because sometimes I need to add a "not" or make combined/complex conditional statements.
- I know I can't use lambdas
- I played with renpy.curry(), but messed it up.
- Maybe my whole python approach is wrong
- The pointnclick_screen is more complex (I pasted here only the relevant parts), including frames, keymaps, and control buttons, so I really want to reuse it rather than create one for every scene.