- Sep 26, 2018
- 3,040
- 3,135
how to show character in a certain pose by using this code
just want to know if it is possible to do it this way or leave at is
so far the code works fine but I want to add pose or timeofday like morning,afternoon,evening,night
I have tried to put something like pose inside of the code that you have gave me error or no image at all
so what I'm trying to have is
anna_Library_afternoon_pose1.png
anna_Library_afternoon_pose2.png
anna_Library_afternoon_pose3.png
anna_Library_evening_pose1.png
anna_Library_evening_pose2.png
anna_Library_evening_pose3.png
anna_Library_Night_pose1.png
anna_Library_Night_pose2.png
anna_Library_Night_pose3.png
for now I have it
anna_Library.png
it's that I don't want to have the same pose through out the hole day long
how can I modify it so it will show anna_Library_Night_pose_1.png or anna_Library_pose_1.png
example:
or
and this is how I am changing the $ time = 0 variable
it's in a loop for now
You must be registered to see the links
just want to know if it is possible to do it this way or leave at is
so far the code works fine but I want to add pose or timeofday like morning,afternoon,evening,night
![screenshot0007.png screenshot0007.png](https://attachments.f95zone.to/2022/03/thumb/1753915_screenshot0007.png)
I have tried to put something like pose inside of the code that you have gave me error or no image at all
so what I'm trying to have is
anna_Library_afternoon_pose1.png
anna_Library_afternoon_pose2.png
anna_Library_afternoon_pose3.png
anna_Library_evening_pose1.png
anna_Library_evening_pose2.png
anna_Library_evening_pose3.png
anna_Library_Night_pose1.png
anna_Library_Night_pose2.png
anna_Library_Night_pose3.png
for now I have it
anna_Library.png
it's that I don't want to have the same pose through out the hole day long
how can I modify it so it will show anna_Library_Night_pose_1.png or anna_Library_pose_1.png
example:
Code:
self.fmt_str = "avatar/{name}/{name}_{{}}_{timeofday}_{pose}.png".format(name=name)
Code:
self.fmt_str = "avatar/{name}/{name}_{{}}_{pose}.png".format(name=name)
and this is how I am changing the $ time = 0 variable
it's in a loop for now
Python:
if dn >= 0 and dn <= 5:
$ dn += 1
#$ time += 1
elif dn >= 6 and dn <= 9:
$ dn += 1
if dn == 9:
$ time += 1
elif dn >= 10 and dn <= 12:
$ dn += 1
if dn == 12:
$ time += 1
elif dn >= 13 and dn <= 16:
$ dn += 1
if dn == 16:
$ time += 1
elif dn >= 17 and dn <= 18:
$ dn += 1
if dn == 18:
$ time += 1
elif dn >= 19 and dn <= 21:
$ dn += 1
if dn == 21:
$ time += 1
elif dn >= 22:
$ dn += 1
if dn == 23:
$ time += 1
if dn >= 24:
$ dn = 0
if dn == 6:
$ time = 0
Python:
"""
npc_schedule is a dict { (time: int, location: str): (npc_name: str, lbt: str} }
npcs is a dict { npc_name: NPC } used to get an NPC by its name.
"""
default npc_schedule = {}
default npcs = {}
init python:
class NPC:
@classmethod
def create(cls, name, nice_name, schedule):
"""
schedule: a dict {(time: int, location: str): lbt: str}
value will be converted to tuple (name, lbt) during creation
"""
npcs[name] = NPC(name, nice_name, NPC.__key)
for key, value in schedule.iteritems():
if key not in npc_schedule:
npc_schedule[key] = [ ]
npc_schedule[key].append( (name, value) )
__key = object() # To disallow accidental creation
def __init__(self, name, nice_name, key):
assert(create_key == NPC.__key)
self.nice_name = nice_name
self.fmt_str = "avatar/{name}/{name}_{{}}.png".format(name=name)
@property
def avatar(self):
global location
avtr = self.fmt_str.format(location)
if renpy.loadable(avtr):
return avtr
else:
return Crop((100, 100, 100, 100), Solid("#0F0")) #"images/avatar/empty.png"
default location = "ryan"
default time = 0
screen character_screen():
$ npc_present = npc_schedule.get( (time, location), [ ] )
vbox:
for name, lbt in npc_present:
$ npc = npcs[name]
hbox:
imagebutton:
idle npc.avatar
hover npc.avatar
focus_mask True
action Call(lbt)
text "[npc.nice_name]: [lbt]"
label start:
show screen character_screen
' . . .' # Nothing is shown, because no schedule is set
$ NPC.create("mom", nice_name="Mom", schedule={
(0, "ryan"): "sally_kitchen_talk",
(1, "parent"): "sally_parent_talk",
(2, "bathroom"): "sally_bathroom_talk",
(3, "livingroom"): "sally_livingroom_talk",
})
" . . . " # Now we see Mom
$ time = 1
' . . . ' # We changed time, but not location. There no one here
$ location = "parent"
' . . . ' # We caught up to Mom again
return
Last edited: