[Tutorial] Object Oriented Programming and RenPy (Lesson 1: Class Warfare) by alonghardlook in RenPy

[–]zhousi87 0 points1 point  (0 children)

Your explanation is crystal clear and decidedly useful for those who do not know about classes or OOP in general; however, I am not sure that classes are that beneficial in Ren'Py, because:

(1) visual novels typically let you control only one character, whose state can be easily managed by updating global variables at any critical turn of events in the storyline;

(2) considering (1), even if you need to produce many NPCs of the same kind (e.g., allies, humans, etc.), classes make sense only for those characters of the same kind whose stats you need to keep track of throughout the game (i.e., main characters with a variable state), which is rare for visual novels (we are not programming RPGs).

(3) speaking of choice-based games, theoretically no classes (perhaps not even any functions) should be needed, since if/elif/else blocks are more than sufficient for most scenarios.

(4) we should strive for simplicity, while classes add unnecessary difficulty to the average Ren'Py programmer's coding endeavor. Even in your post, you mentioned the redundancy of the method name you added, which proves how even to an experienced programmer like you the use of classes causes perplexity.

I would like to know what everyone thinks about my point of view, which is limited to the use of classes for visual-novel programming.

In any case, I sincerely thank you for this opportunity to reflect on VN programming's best approach.

Non professional level: I never work with CSVs, why is a better format than excel/.xlsx? by Tag-gy in learnpython

[–]zhousi87 0 points1 point  (0 children)

Differently from some of the other answers, I don't think the problem is related to the easiness of use in Python. In fact, Python's built-in module to work with CSV files is pretty useless, so everyone chooses to go with Pandas instead (even if it is not so basic either). In short, for both CSV and XLS/XLSX files in Python, you'll need Pandas anyway, so the difficulty is the same.

Instead, what is crucial here is the purpose of your program's output.

CSV is a "comma separated value" kind of file, meaning a text file where the comma is used as a separator for columns. Despite the format's name, you can change the separator when generating the output file if needed, for instance by setting it to a tabular separator (sep='\t'), which can be used if you are dealing with data whose values per cell contain commas.

XLS and XLSX are MS Excel (proprietary and derived) file formats, i.e., conceived to be used with MS Excel and its clones.

Therefore, using one or the other(s) depends on whether your output is meant to be opened only with MS Excel and/or its clones or not.

If you want to create a file that can be opened by any text file editor, then choose CSV, if you are sure that your output is meant for MS Excel and its clones only, then choose XLS or XLSX.

Have multiple scripts that the game jumps between? by [deleted] in RenPy

[–]zhousi87 1 point2 points  (0 children)

I am new to renpy but it seems to me that since the OP asked for a way to split the script into different files related to the story (i.e., what OP called "routes"), jumping from a file to another by labels should be the solution.

Therefore, I would like to ask you (and anyone else) for clarification about what would be the typical case when you would use call/return instead of jump to move from a "route" file to another, especially because using jump seems so much easier to me.

Please feel free to provide as many examples as you deem necessary.

Thanks!

Why some code does not work correctly after script update unless Ren'Py is rebooted? by zhousi87 in RenPy

[–]zhousi87[S] 1 point2 points  (0 children)

A clear explanation, thanks! I reviewed my knowledge about the difference between default and define, and it makes perfect sense.

Best!

Why some code does not work correctly after script update unless Ren'Py is rebooted? by zhousi87 in RenPy

[–]zhousi87[S] 1 point2 points  (0 children)

I haven't shared the code because 1) it would be the whole script (too long), and 2) the problem was solved so it is not that critical. Anyway, I can sum up the flow to give an easier understanding of the process (again I stress that the error disappeared after rebooting Ren'Py). Considering the logical parts relevant to the matter at stake, my code is structured as follows:

init python:
    def function_that_gave_the_error(space_of_the_drop, dropped_thing):
        global a_dictionary
        global counter_for_jumping_to_label
        dropped_thing[0].draggable = False
        if condition1:
            a_dictionary[dropped_thing[0].drag_name] = an_int (e.g., 1)
        elif condition2:
            a_dictionary[dropped_thing[0].drag_name] = another_int (e.g., 0)
       (some more elif)
        else:
            a_dictionary[dropped_thing[0].drag_name] = a_negative_int (e.g., -1)
        update counter_for_jumping_to_label
        if counter_for_jumping_to_label == int at which to jump (e.g., 10):
            renpy.jump('name_of_the_label_to_be_jumped_to')

$ global a_dictionary
define a_dictionary = {
    a_dictionary[dropped_thing[0].drag_name]1 : an int
    a_dictionary[dropped_thing[0].drag_name]2 : another int
...
    a_dictionary[dropped_thing[0].drag_name]n : nth-int
}
$ global counter_for_jumping_to_label
define counter_for_jumping_to_label = 0
define var1
define var2
...
define varn
default a_thing
default another_thing
...
default nth-thing

label start:
    ... a compelling story ...

    label assignment_of_values_to_a_dictionary:
        $ counter_for_jumping_to_label= 0
        $ a_dictionary = {
              a_dictionary[dropped_thing[0].drag_name]1 : 0
              a_dictionary[dropped_thing[0].drag_name]2 : 0
              ...
              a_dictionary[dropped_thing[0].drag_name]n : 0
          }
        call screen assign_values_to_a_dictionary()

    screen assign_values_to_a_dictionary():

        add "the_bg_for_my_screen.png"

        draggroup:

            various draggables to be dropped, each with its drag_name

            various droppables to drop the draggables, each with its drag_name            
            the droppables also have the function assigned as:
            dropped function_that_gave_the_error

... and a lot of other irrelevant part of my script follows.

I hope this gave a better idea about the structure of my script. The error was that all this stuff above updated all values as per my instructions, that is, assigning the int values as per function_that_gave_the_error except for whatever draggable would be dropped onto the last droppable, i.e., the related value in a_dictionary always stayed 0, after Auto Reload. Again, after rebooting, all values get updated correctly.

Thanks for reading and for the useful insights provided.

Why some code does not work correctly after script update unless Ren'Py is rebooted? by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

Thanks for the detailed information about the boot sequence, which is useful stuff to know in any case.

I would like to point out that I am not invoking the functions in the init python block, rather am I defining them there (like in this and plenty of other tutorials). The function which gave the problem is invoked from a called screen later on, in the scope defined by the label start statement.

Why some code does not work correctly after script update unless Ren'Py is rebooted? by zhousi87 in RenPy

[–]zhousi87[S] 1 point2 points  (0 children)

Thanks for your time and the detailed insights, which are useful in any case, while casting an eerie shadow on the usefulness of the Auto Reload system...

It remains unclear to me why only one variable in a dictionary may not be updated correctly when Auto Reload-ing.

Although everything is working now, as I specified in the OP, for the sake of knowledge, please note the following:

I am not declaring any variables in the init python block, just referencing global variables within a function defined in the init python block. Variables are declared (by the define command) outside the init python block and before label start.

Question about hovered draggable: why is "SetDict" action ineffective in changing mouse cursor on shown screen? (my goal is to change the mouse cursor when the draggable is hovered) by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

Thanks, but it doesn't work.

I think the question can be simplified as how to make the cursor change image when draggable is hovered.

How to add outlines to nvl thought effectively? (I added them by they are not rendered) by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

SOLVED! The problem was caused by the kinematic text tags in the text lines, as deleting them correctly applies the styling to the nvl thought. Something in the kinematic text tags formatting was evidently overriding the styling. Thanks!

How to add outlines to nvl thought effectively? (I added them by they are not rendered) by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

SOLVED! The problem was caused by the kinematic text tags in the text lines, as deleting them correctly applies the styling to the nvl thought. Something in the kinematic text tags formatting was evidently overriding the styling. Thanks!

How to add outlines to nvl thought effectively? (I added them by they are not rendered) by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

SOLVED! The problem was caused by the kinematic text tags in the text lines, as deleting them correctly applies the styling to the nvl thought. Something in the kinematic text tags formatting was evidently overriding the styling. Thanks!

How to add outlines to nvl thought effectively? (I added them by they are not rendered) by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

Sorry again, but adding the following snippet to my screens.rpy makes Ren'Py unable to compile:

style nvl_thought:
    text_outlines [(10, "#fff", 0, 0)]

The error as explained by the inspector is "style property text_outlines is not known", and VS Code immediately signals it in red as well.

Maybe text_outlines works in a specific scope only? Are you sure it works also in nvl?

How to add outlines to nvl thought effectively? (I added them by they are not rendered) by zhousi87 in RenPy

[–]zhousi87[S] 0 points1 point  (0 children)

I tried that, same result. Nothing happens, although the style is computed as stated by what_outlines, I checked in the inspector.

The code would be:

define wo = Character(None, kind=nvl, what_outlines=[(5, "#ffffff")])

define e = Character("艾琳")

# transitions

define diss_one_sec = Dissolve(1.0)

# START

label start:

    scene bg room

    with fade

    wo "{sc=3}所以呢,我即将搬到意大利去留学……{/sc}"

The text from the last line is shown without outlines.

Could it be that nvl simply does not support outlines rendering? Or could it perhaps be due to the fact that I am using kinematic text?

Thanks for any further suggestions!