- Sep 13, 2017
- 79
- 644
So I'm working on a semi open-world game, but am extremely new to coding in general. After doing some initial research, I figured using variables to keep track of certain scenes would be a good way. And initially it worked out great, but it's now getting to a point where I get lost in if/elif ladders. This is an example of how it's starting to look:
This is the code that's being run when clicking on a specific location (The house of Helena in this case) on a worldmap callscreen. The if/elif lines are just becoming longer and longer. And this is just one of many locations... Is there any way you could point me in the direction of something more efficient yet not too complex for a beginner like me? Or maybe I'm just using the variables in an inefficient way?
Thank you for taking your time helping beginners like me. This is truly a great community.
Python:
label start:
#variables
$ alleyvisit = 0
$ helenavisit = 0
$ lilithvisit = 0
$ yogavisit = 0
$ farmvisit = 0
$ maxfound = 0
######################
label helenahouse:
if alleyvisit == 0:
scene 00helenahouse01
"I have no reason to go here at this time"
menu:
"Return to map":
call worldmap
"Cheat skip alley (Remove later)":
$ alleyvisit += 1
call worldmap
elif alleyvisit == 1 and helenavisit == 0:
jump helenaintro
elif alleyvisit == 1 and helenavisit == 1:
scene 00helenahouse01
ys "I should probably visit Lily in the alley again, before coming back here"
call worldmap
elif alleyvisit == 2 and helenavisit == 1:
jump helenaintru
elif alleyvisit ==2 and helenavisit ==2 and lilithvisit == 0:
scene 00helenahouse01
y "I should consult with Lilith on what to do next"
call worldmap
elif alleyvisit ==2 and helenavisit ==2 and lilithvisit == 1:
jump helenalily1
"(First spying)"
call worldmap
elif helenavisit ==3 and farmvisit ==0:
scene 00helenahouse01
ys "I should come back later to see what [h] and [l] are up to"
ys "Maybe exploring the downtown area for my next projects?"
call worldmap
elif helenavisit ==3 and farmvisit ==1:
jump helenalily2
elif helenavisit ==4 and maxfound ==0:
scene 00helenahouse01
ys "I should probably try to find Helena's dog Max before coming back here"
call worldmap
Thank you for taking your time helping beginners like me. This is truly a great community.