Page 1 of 1

Making a new preference?

Posted: Fri Sep 28, 2012 1:57 pm
by Joey
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!

Re: Making a new preference?

Posted: Fri Sep 28, 2012 4:31 pm
by Levrex
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 ( ... 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: ... nit_blocks

Re: Making a new preference?

Posted: Sat Sep 29, 2012 1:44 pm
by Joey

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!

Re: Making a new preference?

Posted: Sat Sep 29, 2012 4:35 pm
by Levrex
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)
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)".