School project shop system help

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
mangaquna
Newbie
Posts: 2
Joined: Thu May 18, 2017 1:02 pm
Tumblr: MightyStory
Contact:

School project shop system help

#1 Post by mangaquna »

Hi, I have a project due to tomorrow and I can not get it to work as It should can someone please help me?

I do not get an error but however I do the money just won't register so one of the items for a neutral ending is just not available currently

Code: Select all

    
#Items 
init python:
    class Item:
        def __init__(self, name, cost):
            self.name = name
            self.cost = cost
            
#This is your money and your inventory. This will give option to two second endings upon entering scene 4 the town
    class Bags:
        def __init__(self, Dollar = 0):
            self.Dollar = Dollar
            self.items = [ ]

#How do you buy stuffssssssssssssssssssssss
        def buy(self, item):
            if self.Dollar >= item.cost:
                self.Dollar -= item.cost
                self.items.append(item)
                return True
            else:
                return False

#Earning money is simpel and clean :3
        def earn(self, amount):
            self.Dollar += amount

#Item managing for the ending so the game can check after the requierd items for the, DRAW or the TAIL ending
# Never used beacuse of the shop menu being a better way to jump straight to the endings of choice
        def has_item(self, item):
                if item in self.items:
                    return True
                else:
                    return False    
    

Code: Select all

    
python:
    bag = Bags()
                
$ bag.earn(10)
$ current_Dollar = bag.Dollar 
        
M "Thanks %(current_Dollar)d Dollars... You have done to much guys"


Code: Select all

python:
    bag = Bags()
    Gun = Item("Gun", 6)
    Whip = Item("Whip", 6)
    WaterBottle = Item("WaterBottle", )
    
label Shit:
    $ Guncost = Gun.cost
    $ Whipcost = Whip.cost
    $ WaterBottlecost = WaterBottle.cost
    
N "After buying a horse you named Volley to commemorate Clacker you go to check the store."
S "Welcome traveler Just tell me if you wanna buy anything."
N "You glance at the items in stock"
    
menu shop1:
    "Buy Gun for %(Guncost)d coins.":
        if bag.buy(Gun):
            S "Ah a gun! Of course in this world being able to defend yourself is important with the steel ball run going!"
            M "I have noticed" 
            S "Ah, I am guessing that encounter made you decide on the gun."
            M "You think?"
            N "You spin the gun wheel getting a feel for the gun before thanking the shopkeeper leaving the shop"
            N "You decide to check in on the tavern and eat dinner with Johnny and Gyro before going to bed to get some 
well deserved sleep"
            jump GoodEnd
    "Buy olives for %(Whipcost)d coins.":
        if bag.buy(Whip):
            S "A whip. A hard weapon to master but powerful if you do. You must have time on your hand"
            M "I have some experience with whips but not near enough to use them properly thought I'd pick one up and properly learn."
            S"That is an excellent idea I hope you do well!"
            N "You take the whip thanking the shopkeeper before leaving the shop"
            N "You decide to check in on the tavern and eat dinner with Johnny and Gyro before going to bed to get some well-deserved sleep"
            jump GoodEnd
    
    "Buy chocolate for %(WaterBottlecost)d coins.":
        if bag.buy(WaterBottle):
            S  "A water bottle is an excellent choice in this heat wave we are currently having!"
            M "Yeah I've kind of lost mine"
            S "Then It's an even better purchase! Hope your travels goes well!"
            M "Hope your business goes well"
            N "You are given the water bottle and leaves the shop"
            N "You decide to check in on the tavern and eat dinner with Johnny and Gyro before going to bed to get some well-deserved sleep"
            jump GoodEnd
    "Buy nothing.":
        N "You decide to buy nothing as you don't see anything you like and you leave the shop"
        N "You decide to check in on the tavern and eat dinner with Johnny and Gyro before going to bed to get some well-deserved sleep"
        jump GoodEnd
                
label fallthrough1:
        M "Not enough money to buy that..."
        N "You decide to leave the shop as you don't have money for anything..."
        N "You decide to check in on the tavern and eat dinner with Johnny and Gyro before going to bed to get some well-deserved sleep"
        jump GoodEnd
I don't know what's going on but I can not get it to work. When I pick the Gun which is the option for a neutral ending it just says I have too little money despite earning money just before that. I do not understand what's wrong and it's driving me insane

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: School project shop system help

#2 Post by Ocelot »

I notice that you resetting your bag in the last code snipeet, and there is nothing giving you money after reset.
< < insert Rick Cook quote here > >

mangaquna
Newbie
Posts: 2
Joined: Thu May 18, 2017 1:02 pm
Tumblr: MightyStory
Contact:

Re: School project shop system help

#3 Post by mangaquna »

How do I not reset it then? beacuse I'm very lost :/

Post Reply

Who is online

Users browsing this forum: Google [Bot], recreation, Sugar_and_rice, voluorem