Is it possible...

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
User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Is it possible...

#1 Post by wyverngem »

I remember reading somewhere that there is a click and drag function in renpy, but I don't remember where the information was to start something like that up. I'm creating a crafting game where the player makes potions and salves.

I want players to be able to drag things from their side inventory into a cauldron, placing the images behind it. If they're happy with their selection the can hit "Mix". When the button is hit they are asked to confirm. If yes an animation plays and the items are created and shown to the player. If they are not the images will reset themselves back to the side and the player can choose a different combination. Though at any time they can hit a reset button that does the same function.

Is this possible?

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Is it possible...

#2 Post by Anima »

The drag and drop displayable documentation can be found here.
It's pretty complex, though it should support what you have in mind.
Last edited by Anima on Sat Oct 22, 2011 5:00 am, edited 1 time in total.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Is it possible...

#3 Post by wyverngem »

Thank you for sending me the link. However, now I'm confused again. I see how it's set up in the example, but it only lets me drop one item. I want to be able to drop more and then confirm the drops... Also the drops are going to depend on the inventory. Is there a way to write an if else statement?

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Is it possible...

#4 Post by wyverngem »

Okay so I'm having issues with my code. I get this error whenever I try to add a second item to my mixing pot.

It says:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 92, in script
        call screen send_detective_screen
Exception: ui.interact called with non-empty at stack.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Emilie\Desktop\renpy-6.13.1\renpy\execution.py", line 261, in run
  File "C:\Users\Emilie\Desktop\renpy-6.13.1\renpy\ast.py", line 1405, in execute
  File "C:\Users\Emilie\Desktop\renpy-6.13.1\renpy\ast.py", line 1418, in call
  File "C:\Users\Emilie\Desktop\renpy-6.13.1\renpy\statements.py", line 100, in call
  File "common/00statements.rpy", line 540, in execute_call_screen
  File "C:\Users\Emilie\Desktop\renpy-6.13.1\renpy\exports.py", line 1530, in call_screen
  File "C:\Users\Emilie\Desktop\renpy-6.13.1\renpy\ui.py", line 234, in interact
Exception: ui.interact called with non-empty at stack.

Windows-post2008Server-6.1.7600
Ren'Py 6.13.1.1629
A Ren'Py Game 0.0
I want to solve that, but I also want to do a couple of things. I have my code at the bottom. What's not working for me:
- The position "$ mixitem1_spot = Position(xpos = 136, ypos = 300)" doesn't seem to work.
- Even when Poison Shrooms are in the item_mix variable it doesn't act as it is.
- The game crashes every time that I call the screen again and try to add another item to the pot.

What I want to add.
- I want to add a "confirm" button to my screen that jumps to the label "results" after asking if they want to continue. If not it does nothing.
- I want to add a reset button on my screen that asks for confirmation and jumps to the label "start", if not it does nothing.
- I want to add a variable that controls if the player has an item so that they will display in the drag or not. I also want to control the position through a defined variable so that it doesn't leave gaps by not having the item

Code: Select all

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")
image mixpot = "cauldron.png"
image bg yellow = "wallpaper_yellow.png"
image cheryl = "cheryl.png"
image bg inv = "inv_screen.png"

# The game starts here.
init:
    $ mixitem1_spot = Position(xpos = 136, ypos = 300)    
    $ item_mix = []
    $ SeedCount = 0
init python:
    show_mixitem1 = False
    def display_mixitem1():
        if show_mixitem1:
            ui.text(mixitem1)
            ui.at(mixitem1_spot)
    config.overlay_functions.append(display_mixitem1)
    
init python:
    def detective_dragged(drags, drop):

        if not drop:
            return

        store.detective = drags[0].drag_name
        store.city = drop.drag_name

        return True

screen send_detective_screen:

    # A map as background.
    add "mix_screen.png"

    # A drag group ensures that the detectives and the cities can be
    # dragged to each other.
    draggroup:

        # Our detectives.
        if SeedsCount = 1:
            drag:
                drag_name "Seeds"
                child "seeds.png"
                droppable False
                dragged detective_dragged
                xpos 100 ypos 100
        drag:
            drag_name "Eve Blssoms"
            child "eveblossoms.png"
            droppable False
            dragged detective_dragged
            xpos 200 ypos 100
        
        drag:
            drag_name "Poison Shrooms"
            child "poi_shrooms.png"
            droppable False
            dragged detective_dragged
            xpos 300 ypos 100

        # The cities they can go to.
        drag:
            drag_name "Cauldron"
            draggable False
            child "clearpot.png"
            xpos 255 ypos 270

label start:

    scene bg yellow
    show mixpot
    show cheryl at right
        
    "Add your ingrediants;"
    
    call screen send_detective_screen    
    $ item_mix.append(detective)
    $ mixitem1 = detective
    $ mixitem1_spot = Position(xpos = 136, ypos = 400)
    $ show_mixitem1 = True    
    
    call screen send_detective_screen
    $ item_mix.append(detective)
    
    call screen send_detective_screen
    $ item_mix.append(detective)
    
    "Are you happy with your selection?"
    menu:
        "Yes":
            jump results
        
        "No":
            jump start
    
    jump results
    
    return
    
label results:
    if "'Poison Shrooms'" in item_mix:
        "You crated a {color="ff00FF"}Strange Poison{/color}."
        
    jump start
    
    return
Any help would be appreciated.

KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Is it possible...

#5 Post by KimiYoriBaka »

Code: Select all

Exception: ui.interact called with non-empty at stack.
this means you used an ui function that is supposed to affect another ui function, but didn't put in the second one that it's supposed to affect. in this case, you have ui.at without anything after it. It should go before ui.text

also, if you're going to use screens anyway, it'd better to add the text using the screen rather than as an overlay.

for making button to confirm or reset, I suggest you read the screen language sections on buttons and actions

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Is it possible...

#6 Post by wyverngem »

Thanks for clearing the ui.at up with me. The game is working fine now. I would have the whole label start in the screen, but I do not know how to code that properly. I still don't know how to fix it so that it doesn't ignore the Poison Shrooms....

KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Is it possible...

#7 Post by KimiYoriBaka »

now that I look at it again, you have both double and single quotations in your comparison. this means that the code is checking for an item name with single quotations as part of the name (which your drag_name for poison shrooms doesn't have). Does it work if you take them out?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]