- Sep 8, 2018
- 10
- 31
I'm going to try and explain this as best I can, so bare with me as I botch this; there's also going to be abysmal pseudocode here, but hopefully you'll understand....
Is it possible in Ren'Py to store a string as a variable, and then use a jump/goto instruction (call, maybe? I dunno - something to go to another scene!) to jump to the function stored in the variable?
Psuedo:
Forgive the awful pseudocode, I really do hope it makes sense! Thing is, I don't know if I can combine variables in Ren'Py like that to build a target that I want to jump to. Fundamentally, I believe I'm going to need a central single section of the game code that will act as a hub and a "calculate which bit to send them to next." I've simplified it a bit here, but because I use a standardized (for me) naming convention for everything, I should be able to predict what a code section will be called based on it's features.
I know there's a fudgey way to do it by basically creating an If case (So if JumpTarget$="AliceBedroomMorning1" then Goto AliceBedroomMorning1 and so on - but that could get huge and messy and calling straight from the variable name would be a lot tidier.
Can anyone offer me a suggestion as to wether I'm thinking the right way and I can do this in Ren'Py, or if I'm barking up the wrong tree? Thank you all!
I'll covert to actual code once the main parts have been Pseudocoded![Big grin :D :D](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Is it possible in Ren'Py to store a string as a variable, and then use a jump/goto instruction (call, maybe? I dunno - something to go to another scene!) to jump to the function stored in the variable?
Psuedo:
Code:
MainGameLoop:
rem Set TargetPerson and Room for start of Jump
If TargetPerson = "Alice" and Room = "Bedroom" then JumpTarget$ = "AliceBedroom"
If TargetPerson = "Betty" and Room = "Bedroom" then JumpTarget$ = "BettyBedroom"
rem Add TimeOfDay to JumpTarget$
If TimeOfDay < 12 then JumpTarget$ = JumpTarget$ & "Morning"
If (TimeOfDay > 12) and (TimeOfDay < 18) then JumpTarget$ = JumpTarget$ & "Afternoon"
rem Add StoryArcCode to JumpTarget$
JumpTarget$ = JumpTarget$ & StoryArcCorde
rem Jump to next segment
End MainGameLoop
AliceBedroomMorning1:
rem First story arc for Alice in the bedroom in the morning.
End AliceBedroomMorning1
AliceBedroomAfternoon1:
rem First story arc for Alice in the bedroom in the afternoon.
End AliceBedroomAfternoon1
I know there's a fudgey way to do it by basically creating an If case (So if JumpTarget$="AliceBedroomMorning1" then Goto AliceBedroomMorning1 and so on - but that could get huge and messy and calling straight from the variable name would be a lot tidier.
Can anyone offer me a suggestion as to wether I'm thinking the right way and I can do this in Ren'Py, or if I'm barking up the wrong tree? Thank you all!
I'll covert to actual code once the main parts have been Pseudocoded