List item system. How do i mark item as picked?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Psion
Regular
Posts: 25
Joined: Fri Dec 11, 2020 4:01 pm
Contact:

List item system. How do i mark item as picked?

#1 Post by Psion »

I'm making item system. It working alright, but you can pick item as many times as you want. How do i mark item as picked?

Code: Select all

init python:
   class ITEMS (object):
        def __init__ (self, location, isActive, icon, func):
            self.location = location
            self.isActive = isActive
            self.icon = icon
            self.func = func

    Objects = []

    Objects.append(ITEMS("2nd Floor Hallway", True, "items/pawn.png", "pawn_00"))

screen items():
    for q in Objects:
        if q.location.lower() == location and q.isActive:
            imagebutton:
                idle q.icon
                hover q.icon
                focus_mask True
                action SetVariable("clickType", "items"), Return(q.func)

label start:
        if clickType == "items":
            call expression UIreturn

label pawn_00:
    "I took a pawn"
    return

As i think i should put somewhere after "action" in "screen items" something like q.isActive=False to make object not active anymore. But i dont know syntax good enough :( Help pls.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: List item system. How do i mark item as picked?

#2 Post by Alex »

Try SetField action - https://www.renpy.org/doc/html/screen_a ... l#SetField

Code: Select all

action [SetField(q, "isActive", False), SetVariable("clickType", "items"), Return(q.func)]

Psion
Regular
Posts: 25
Joined: Fri Dec 11, 2020 4:01 pm
Contact:

Re: List item system. How do i mark item as picked?

#3 Post by Psion »

Working nicely, thank you very much.

Post Reply

Who is online

Users browsing this forum: No registered users