Character at a certain time and location

A place for Ren'Py tutorials and reusable Ren'Py code.
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.
Post Reply
Message
Author
rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Character at a certain time and location

#1 Post by rayminator »

anyone can use this if they want to or not


class.rpy

Code: Select all

class NPC(object):

        def __init__(self, name, niceName, location, hours, minutes, lbt=""):

            self.name = name

            self.niceName = niceName

            self.location = location

            self.hours = hours

            self.minutes = minutes

            self.lbt = lbt


        @property

        def avatar(self):

            global hours

            global minutes

            global location

            avtr = "avatar/{}_{}_{}_{}.png".format(self.name, str(hours), str(minutes), location)



            if renpy.loadable(avtr):

                return avtr

            else:

                return "avatar/empty.png"

character_screen.rpy

Code: Select all

screen charcater_screen():

    for q in NPCS:

        if q.location == location:

            imagebutton:

                idle q.avatar

                hover q.avatar

                focus_mask True

                action SetVariable("mainUI", False), Call(q.lbt)

default.rpy

Code: Select all

default hours = 0
default minutes = 0
default lbt = ""
default NPCS = []


label InitialiseVariables:


    $ NPCS.append(NPC("mom", "Mom", "livingroom", 12, 0, lbt="test"))

    return

Post Reply

Who is online

Users browsing this forum: No registered users