Making a new preference?

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
User avatar
Joey
Regular
Posts: 123
Joined: Tue Aug 02, 2011 4:51 am
Projects: Water's Edge
Organization: Etoranze
Contact:

Making a new preference?

#1 Post by Joey » Fri Sep 28, 2012 1:57 pm

I have a new preference-type thing where you can choose to enable or disable pauses after punctuation. I have something like this for the code:

Code: Select all

        hotspot (853, 321, 180, 41) action SetField(persistent, "pausing", True)
        hotspot (1031, 321, 180, 41) action SetField(persistent, "pausing", False)
but I realize that doesn't behave the same way a preference does i.e. when you change it in the middle of gameplay it doesn't change unless you reload. What's a way to get around this? Thanks in advance!
Image
Image (devblog) || devtwitter | devtumblr

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: Making a new preference?

#2 Post by Levrex » Fri Sep 28, 2012 4:31 pm

Would you like to tell me how it works? I mean, "pausing after punctuation".
Because my tester seems to desire it.

And about your question - you can either use my method (http://lemmasoft.renai.us/forums/viewto ... 15#p220059) or write your own action based on the detailed examination of 00screen.rpy - its SetVariable, ToggleField and SetField portions, to be precise. By examining them and then, knowing that SetVariable... oh well, my way seems totally easier.

=======

But wait, there is something better:

http://www.renpy.org/wiki/renpy/doc/coo ... nit_blocks
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

User avatar
Joey
Regular
Posts: 123
Joined: Tue Aug 02, 2011 4:51 am
Projects: Water's Edge
Organization: Etoranze
Contact:

Re: Making a new preference?

#3 Post by Joey » Sat Sep 29, 2012 1:44 pm

Code: Select all

    $ x = 0.1
    $ y = 0.3
    
    $ persistent.pausing = True

    if persistent.pausing == False:
        $ x = 0
        $ y = 0    
I put a text tag {w=[x]} or {w=[y]} after each comma and period respectively. So if persistent.pausing is set to False, there will be no pause after punctuation.

Trying to make sense of your method now but I'm still an amateur at this and it's very advanced and confusing O.O;; Any further help will be appreciated!
Image
Image (devblog) || devtwitter | devtumblr

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: Making a new preference?

#4 Post by Levrex » Sat Sep 29, 2012 4:35 pm

If you want to use my method, well, don't do it.

You'll need to define your own action.

The following is a sketch.

Code: Select all

        class Pausing(Action):
            
            def __init__(self, object, x, y, xvalue, yvalue):
                self.object = object
                self.x = x
                self.xvalue = xvalue
                self.y = y
                self.yvalue = yvalue
                
            def __call__(self):
                setattr(self.object, self.x, self.xvalue)
                setattr(self.object, self.y, self.yvalue)
                renpy.restart_interaction()
It takes two something in "object" (persistent is persistent and store stores simple variables) and assigns them some values. Note that you'll need to put "somethings" in quotes.
Basically it's the same as "ToggleField".

Pause will look like "{w=[persistent.x]}".
ScreenAction will look like "action Pausing(persistent, "x", "y", 0.0, 0.0)".
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

Post Reply

Who is online

Users browsing this forum: auger