Label calling messing with python loops?

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
kons
Newbie
Posts: 4
Joined: Sun Oct 08, 2017 12:46 pm
Contact:

Label calling messing with python loops?

#1 Post by kons » Sun Oct 08, 2017 12:58 pm

Hi there,

I've been using ren'py for a while but this is the first time i can't get WTF is going on.

So, this is what i have

Code: Select all

# Draw all clickable elements
label mapElements(mapType):
    python:
    	file_loc = "image"
    	comm_loc = "comm"
    	file_ext = ".png"
    	# for each drawable map
        for p in maps_cycle:
            # for each element in the map
            for i, e in enumerate(p):
            	 renpy.call("mapElement", e=e, file_loc=file_loc, comm_loc=comm_loc, file_ext=file_ext)
            	 narrator("Lol")

Code: Select all

label mapElement(e, file_loc, comm_loc, file_ext, use_comm=True):
	if renpy.loadable(file_loc + file_ext) == True:
        	$file_to_load = file_loc + file_ext
        	show expression "[file_to_load]" as file_loc:
            		pos(e[MapPlaceEntry.x], e[MapPlaceEntry.y])
    	return
What is happening is that, after entering in the label "mapElement" the for loops in mapElements get completely ignored, as if the control flow is not resumed from the renpy.call function.
Moreover the line narrator("lol") is never called.

I can't use call_in_new_context because on return will cancel the shown image (although the loop works with this one).

Any idea of what is happening??

Thanks,
K
Last edited by kons on Sun Oct 08, 2017 2:16 pm, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Label calling messing with python loops?

#2 Post by trooper6 » Sun Oct 08, 2017 1:14 pm

I don't know why you are doing this in this way....but I'm looking at this line here:

Code: Select all

for i, e in enumerate(p):
            	 renpy.call("mapElement", e=e, file_loc=file_loc, comm_loc=comm_loc, file_ext=file_ext)
            	 narrator("Lol")
You are passing e, file_loc, comm_loc, and file_ext in the call. I see where e data comes from, but I don't see where the information file_loc, comm_loc, and file_ext data comes from. It looks like you are just passing in no information for that.

Which means this bit:

Code: Select all

if renpy.loadable(file_loc + file_ext) == True:
Should always end up being false because you didn't actually pass in any content for that information.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

kons
Newbie
Posts: 4
Joined: Sun Oct 08, 2017 12:46 pm
Contact:

Re: Label calling messing with python loops?

#3 Post by kons » Sun Oct 08, 2017 2:16 pm

Thanks for the answer,
i forgot to include a placeholder for those variables.
The renpy.loadable returns always true.

Post Reply

Who is online

Users browsing this forum: No registered users