Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Sun May 19, 2013 11:01 pm

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Mar 18, 2012 12:46 am 
Regular
User avatar

Joined: Sat Jun 12, 2010 11:27 am
Posts: 71
Projects: Rogue Of Heart, Awakened With A Crimson Kiss
is there a way to turn it off? not forever, but I'd like to be able to add a skip toggle into the nav menu so that players can turn it off whenever they want, regardless of whether or not dialogue is currently happening

also, I'm trying to work out how to call a python class as an action, the way it's done in this thread. calling the function seems fine, but how do I pass in a parameter the way actions like Hide and ShowMenu do?

_________________
VNs In Progress:
» Awakened With a Crimson Kiss «
» Rogue of Heart «


Top
 Profile Send private message  
 
PostPosted: Thu Apr 19, 2012 2:34 am 
Regular

Joined: Tue Apr 03, 2012 9:17 am
Posts: 88
Location: Seoul, South Korea
Projects: Dandelion
Organization: Cheritz
1. The preferences Action accepts toggle as an argument. Add a button to the nav screen that uses this

Code:
textbutton "Skip Toggle" action Preference("skip", "toggle")


2. Create a new class that inherits from action and pass whatever data you want to __init__. Here's an example

Code:

init python:
   
    class PetAction(Action):
       
        def __init__(self, doggy_name):
            self.doggy_name = doggy_name

        def __call__(self):         
            renpy.show(self.doggy_name) # Show doggy being petted


Then at your screen you use it like any other action

Code:
textbutton "Pet Fluffy" action PetAction('fluffy')
textbutton "Pet Smelly" action PetAction('smelly')


Of course you name it whatever you want and do whatever actions. This is just a made up example :)
But the way it works is that the __init__ constructor gets called when the screen is first shown and the Action object is "constructed". When the user presses the button, the __call__ function of the Action object gets called and runs any relevant code. So all the variables are passed to the constructor and saved in local members of the object using self.variable_name. you can call these variables whatever you want but you must save the data that gets passed this way, if you want to access it later.

I hope that helps, if anything is unclear or if it's not what you're looking for please say so.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group