making an autoshop in my vn

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
texasstallion
Regular
Posts: 33
Joined: Tue Jun 27, 2017 4:11 pm
Contact:

making an autoshop in my vn

#1 Post by texasstallion »

sorry for asking so many questions

So I am making an autoshop, and I am trying to have the character, be able to work there for money, but if he has more auto knowledge he gets to work a better job, at the shop

This is how i tried to implement it

Code: Select all

label autojob:

if auto_point < 20:
"sorry kid you need more automotive knowledge"
jump autoshop

elif auto_point>20 and auto_point<40:
"yeah kid go and sweep up in the back"
"you sweep the floors around the shop"
$ money_point+=7
$ energy_point-=10
$ energy_point+=1
jump autoshop

elif auto_point>40 and auto_point<60
"yeah kid we need help out on the front register"
$ money_point+=10
$ energy_point-=10
$ energy_point+=1
jump autoshop
and so on and so on

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 682: if statement expects a non-empty block.
    if auto_point < 20:
                       ^

File "game/script.rpy", line 686: expected statement.
    elif auto_point>20 and auto_point<40:
                   ^

File "game/script.rpy", line 694: expected statement.
    elif auto_point>40 and auto_point<60





also i want to be able to but auto parts from the autoshop to as in
buy sport muffler 200$ (+10hp)
buy preformance muffler 300$(15hp)

i want it to where you can only buy one thought
i know this will be complecated but i think it will be a cool game if i get it to work

Code: Select all

label autostore
"what do you want"
menu:
    "mufflers":
        jump mufflers
label muffler
menu:
    "sport 200$"
    if money_point>199
    $ money_point-=200
    $ hp_point+= 10
        jump autoshop
    "preformance 300$"
    if money_point>299
    $ money_point-=300
    $ hp_point+= 15
        jump autoshop   
sorry if this is confusing

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: making an autoshop in my vn

#2 Post by Errilhl »

The first error is because you're not following the proper indentation.

Your code should look like this:

Code: Select all

label autojob:
    if auto_point < 20:
        "sorry kid you need more automotive knowledge"
	jump autoshop
    elif auto_point>20 and auto_point<40:
	"yeah kid go and sweep up in the back"
	"you sweep the floors around the shop"
	$ money_point+=7
	$ energy_point-=10
	$ energy_point+=1
	jump autoshop
    elif auto_point>40 and auto_point<60
	"yeah kid we need help out on the front register"
	$ money_point+=10
	$ energy_point-=10
	$ energy_point+=1
	jump autoshop
Currently working on: Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: making an autoshop in my vn

#3 Post by Remix »

Every (well every except for perhaps if you were typing a dialogue that had a colon in it) time you type a colon indent the following block by 1 tab or a set number of spaces

Code: Select all

some statement with a colon at the end:
    # everything related to (contained by) that statement is indented

# only return to the lower indentation level once the block is complete
Frameworks & Scriptlets:

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: making an autoshop in my vn

#4 Post by Errilhl »

For the "buy only once" you could probably set a check with a flag, so that the item won't show up if you already have it.

Something like this:

Code: Select all

init:
    $ sport_muffler = False
    $ performance_muffler = False

label autostore:
    "what do you want"
    menu:
        "mufflers":
            jump mufflers
label muffler:
    menu:
    if not sport_muffler:
        "sport 200$"
        if money_point >= 200:
            $ money_point-=200
            $ hp_point+= 10
            $ sport_muffler = True
            jump autoshop
    if not performance_muffler:
        "performance 300$"
        if money_point>=300:
            $ money_point-=300
            if sport_muffler:
                $ hp_point+=5
            else: 
                $ hp_point+=15
            $ performance_muffler = True
            jump autoshop 
Quick example - I took the liberty of modifying a few bits (grammar error on performance), and also modifying the value added with performance, since mufflers don't really stack in the real world (ie, if you have the sport muffler, you wouldn't get another 15 health points by adding performance muffler, only 5 (5 more than the sport one). If you buy the performance on directly (without buying the sport one) then you get 15. If that's not desireable, just take out that if / else statement. Added the necessary check-variables to see if the items have been bought.

Not entirely sure the if/else there will work within the menu (I use a condition modified menu/choices one myself, where I can add conditions to show / enable items in the menu list), so this is just a suggestion of how to do it, you probably need to modify to suit you
Currently working on: Image

ArcialIntegra
Regular
Posts: 53
Joined: Mon Nov 13, 2017 12:10 am
Contact:

Re: making an autoshop in my vn

#5 Post by ArcialIntegra »

Might I comment on the redundancy of decreasing energy by 10 in one line then increasing it by 1 in the next? This may be a relatively minor point, but if you have a bunch of redundancies like this, it may make coding a tad exhausting. My recommendation would be to have the shop be its own label you call to with "Shop", "Work", and "Leave" being your three options. I mocked up what I think this should look like in theory, but I'm not much of a programmer, so you may want others to look this code over or you may want to run it on its own be for pasting it into your work. I copied some of Errihil's recommendation in order to write this more quickly, so be sure to thank them if you use this. I don't need any thanks.

Code: Select all

init:
    $ sport_muffler = False
    $ performance_muffler = False

label start:
	"I'm an auto enthusiast who is ready to make it big in racing!"
	"I have big plans, but first I need a job."
	"I may be able to get one at the Auto Shop once I learn more about cars."
	"Until then, I should focus on my studies."
	"But first, I should get some sleep."
	"I slept soundly with dreams of cars racing through the night."
	jump newday

label newday:
	"It's a new morning and a new day."
 	"What should I do today?"
    	menu:
        	"Rest":
        		call rest
        	"Study":
            		call study
        	"Go to the Shop":
       			call autoshop
       	"It's been a good day, but it's not over yet."
       	"What should I do for the rest of the day?"
       	menu:
       		"Rest":
       			call rest
       		"Study":
       			call study
       		"Go to the Shop":
       			call autoshop
       	"After such a great day, I should probably go to bed so I can be ready for tomorrow!"
	$ energy_point += 1
	jump newday

label rest:
	"I got some well-needed sleep, but I shouldn't slack off too much."
	$ energy_point += 5
	return

label study:
	"I learned a lot more about automotives, but I shouldn't overwork myself."
	$ energy_point -= 5
	$ auto_point += 5
	return
	
label autoshop:
	menu:
		"Now that I'm here, what should I do?"
		"Shop":
			call autostore
		"Work":
			call autojob
		"Leave":
			"Maybe I should head back home."
			return
	"That should be good for today."
	"Let's head home."
	return
	
label autojob:
    if auto_point < 20:
        "Shopkeep" "Sorry kid, but you need more automotive knowledge."
	return
    elif auto_point > 20 and auto_point < 40:
	"Shopkeep" "Sure, kid. Why don't you go and sweep up in the back?"
	"You sweep the floors around the shop..."
	$ money_point+=7
	$ energy_point-=10
	return
    elif auto_point > 40 and auto_point < 60
	"Shopkeep" "Yeah, all right. We need some help out on the front register."
	"Shopkeep" "Go on, get to it."
	"You rang up a few customers, but it was a pretty slow day."
	$ money_point+=10
	$ energy_point-=10
	return

label autostore:
	"Shopkeep" "What do you want to buy?"
	menu:
        	"mufflers":
            		call mufflers
            	"nothing":
            		call autoshop
	return

label mufflers:
	menu:
    		if not sport_muffler:
        		"Sport Muffler - $200":
        			if performance_muffler == True:
        				"Shopkeep" "Are you sure you wish to trade the Performance Muffler for the Sport Muffler, kid?"
        				"Shopkeep" "You'll still have to pay full price if you want to switch back..."
        				menu:
        					"Yes.":
        						pass
        					"No.":
        						return
        				"Shopkeep" "Suit yourself..."
        			if money_point >= 200:
            				$ money_point -= 200
	           			$ hp_point += 10
            				$ sport_muffler = True
            				return
            			else:
            				"Shopkeep" "...What are you trying to pull?"
            				"Shopkeep" "You can't afford that, kid..."
            				call mufflers
		if not performance_muffler:
        		"Performance Muffler - $300":
        			if money_point >= 300:
					$ money_point -= 300
	            			if sport_muffler == True:
        	        			$ hp_point += 5
        	        			sport_muffler = False
            				else: 
                				$ hp_point += 15
	            			$ performance_muffler = True
                			return
                		else:
                			"Shopkeep" "...What are you trying to pull?"
                			"Shopkeep" "You can't afford that, kid..."
                			call mufflers
                else:
                	"Other Items":
                		call autostore
	return ### In case you don't return naturally for some reason

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]