Author Topic: General Discussion  (Read 3821805 times)

0 Members and 27 Guests are viewing this topic.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6060 on: October 13, 2015, 11:03:36 AM »
edit: I corrected my label and it broke my save. When I use a saved game which has spoken to Xeona while her interaction was Under the faulty label then speaking to her again makes an error: cannot find label "find_xenoa".

If you had saved while being inside of that label, changed the name of the label and loaded that old save file, you'll get an error. It's not exactly a feature, it's the very core of the engine saving mechanism:

Ren'Py saves the last finished Ren'Py Script statement, label name where the said statement resides is a part of that save. Basically:

Code: [Select]
$ h = chars["Hinata"] # <== Single Ren'Py Script Statement.
"[h.fullname]" # <==  Single Ren'Py Script Statement.
show expression h.show("profile", resize=(500, 500)) # <==  Single Ren'Py Script Statement.
h.say "My name is Hinata" # <==  Single Ren'Py Script Statement.

Code: [Select]
python:
    # 10 000 000 lines of code...  # <==  STILL A Single Ren'Py Script Statement (meaning that only the previous statement will be saved until python block is finished).


Is that what you were warning me about when you said renaming labels caused problems?

Not at all, everyone who really worked with Ren'Py knows and expect that. What I meant was not usual Ren'Py behavior at all. In PyTFall we track a callback "last_label", it is a tricky way to remember where we came from while jumping labels when calling them is not really the best option for whatever reason. last_label callback is also used in Events and Quests. There is also a label_cache argument to Char.show() method for example, developer can ensure a behavior of a fixed image being returned while calling any constant set of tags from within any specific label. There are also a bunch of labels in interactions that expect specific naming, this has nothing to do with the callback, it's just expected naming rules.

None of that applies to NPCs in general, same for most of the unique content. It's something that is used by Interactions, Events and a couple of screens internally.

In my experience, saves are not a perfectly reliable way to test changes in the code, they don't take into account many things. Usually it's better to start a new game and, if needed, run the label you want to test from the console.

Also, when you change the code a lot, sometimes you have to force recompile the game, there is an option for that in renpy launcher.

You can test changes in the code using save/loading system, problem is that setting such an option in a game this complex requires too much work/concentration when writing code.

Recompiling is usually required when label names/file names have changed and Ren'Py doesn't notice that to trigger an auto-recompile for whatever reason. Those errors are less frequent since 6.18.
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6061 on: October 13, 2015, 11:54:35 AM »
I'd like to create and use in dialogues a random character. Assuming that this is possible at this point. I can create and add one to the hero, but when I try to use her in dialogues like
Quote
    $ new_random_girl = build_rc("Angel")
    new_random_girl "..."
I get an error.

Offline Alex250

  • Newbie
  • *
  • Posts: 11
Re: General Discussion
« Reply #6062 on: October 13, 2015, 01:49:27 PM »
Ren'Py saves the last finished Ren'Py Script statement, label name where the said statement resides is a part of that save.

I don't think this is the problem I had. I had returned to the arena_outside label and to the main menu after saving, plenty of labels had passed. I could use the saved game normally, it only crashed when I tried to speak to Xeona, as if it had memorized that her button was leading to the label that was changed.
French -> please tell me when I make writing mistakes.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6063 on: October 13, 2015, 03:50:34 PM »
I don't think this is the problem I had. I had returned to the arena_outside label and to the main menu after saving, plenty of labels had passed. I could use the saved game normally, it only crashed when I tried to speak to Xeona, as if it had memorized that her button was leading to the label that was changed.

Maybe... there is a chance that Xeonas label is bound to our custom menu system or something.
Like what we're doing?

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6064 on: October 13, 2015, 03:56:15 PM »
I'd like to create and use in dialogues a random character. Assuming that this is possible at this point. I can create and add one to the hero, but when I try to use her in dialogues likeI get an error.

Someone should nuke that python academy thing, it seems useless... You're creating an object like any other character, there is no need to add it to hero, they should explain how to pwn objects in python, since everything in the pl is an object.

You just do the same thing as you've done over 300 times before (see attachment). Other cool stuff that may be useful is:

Code: [Select]
$ nr = new_random_girl.say
nr "..."

You can do that with anything, even with functions:

Code: [Select]
python:
    def start_special_battle_scenario():
        # bla bla bla

$ ssbc = start_special_battle_scenario
$ ssbc()


===
I've seen some of your new scripts btw, you're still using:

Code: [Select]
label some_label:
     # loads of code:
     label another_label:

Please don't and fix the existing script. It will be a nightmare for me to fix otherwise. All labels should be on the base indent.
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6065 on: October 14, 2015, 01:08:55 AM »
Someone should nuke that python academy thing, it seems useless...
All their tasks are about inputting some variables, do some basic math and logic with them and then outputting them using complex strings with %. They also explain how to create classes and functions and use them in the same manner.

We basically never use direct input and output, except a few very specific cases.

In this case, however, I had a moment of retardancy  :)   I often forget about say, but then fix it when get an error. In this case I thought it's not about say, but about random character.

I've seen some of your new scripts btw, you're still using:

Code: [Select]
label some_label:
     # loads of code:
     label another_label:

Please don't and fix the existing script. It will be a nightmare for me to fix otherwise. All labels should be on the base indent.
But I don't share irrational hatred of python developers for freely jumping to labels when needed.
« Last Edit: October 14, 2015, 01:31:50 AM by DarkTl »

Offline Alex250

  • Newbie
  • *
  • Posts: 11
Re: General Discussion
« Reply #6066 on: October 14, 2015, 02:27:39 AM »
But I don't share irrational hatred of python developers for freely jumping to labels when needed.

source: xkcd

Freely jumping to labels doesn't create problems (do you need to delete pointers in python?). The problem is that there are other developers working with you and there will be more coming after you to maintain you code. Jumping to labels everywhere makes their job harder. It is easier for you to take good practices than for us to cleanup after you. (this sounds a bit rash but no offense is intended)


What tool are you using to code? I am using a text editor but I would really like to have a program with helpful features like autocomplete and search trough all files.
French -> please tell me when I make writing mistakes.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6067 on: October 14, 2015, 03:52:08 AM »
Well, I think the most complex script that uses jump to label is sex scene.

At first player selects action from the menu. Then we check if there are pictures available for specific action. If they are, we jump to actual scene with checks. After it finished, we jump to menu of actions again.

I can include scene with checks into functions. But it won't change the whole structure. Instead of jumping to scene labels we'll "jump" to scene functions.
And if I try to avoid jumping to the menu of actions with the help of while, like I can do for short and simple dialogues, it will make stuff even more confusing, because there will be many dozens strings in while, not just 4-5.

What tool are you using to code? I am using a text editor but I would really like to have a program with helpful features like autocomplete and search trough all files.
I use notepad++. It can do anything, providing that you know how to use it.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6068 on: October 14, 2015, 04:17:55 AM »
Why do we def adjust_exp twice?  In classes - characters and functions - characters.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6069 on: October 14, 2015, 04:59:08 AM »
Why do we def adjust_exp twice?  In classes - characters and functions - characters.

Prolly a mistake during refactoring, the one with the highest init/filename will be used.

===
I am not asking you to rewrite your code, just make sure that all label declarations are on the base indent, this has nothing to do with coding practices, just code readability. I've never seen anyone who were serious about developing their game declaring labels in labels because it's pointless and should not carry any advantages while making a mess in code.

Edit (all I am asking is keeping the code clean and readable):

For Python:
https://www.python.org/dev/peps/pep-0008/
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
https://google-styleguide.googlecode.com/svn/trunk/pyguide.html

For Ren'Py:
Example novel and Tutorial that came with the engine.

Code: [Select]
label intro_story_konan_room:
    stop music
    stop world
    $ k = chars["Konan"]
    $ k_spr = chars["Konan"].get_vnsprite()
    $ konan_orig = 0
    $ konan_ling = 0
    $ konan_protector = 0
    $ a = 0
    $ b = 0
    $ c = 0
    $ d = 0
    $ e = 0
    $ f = 0
    $ sc = 0
    hide screen pyt_city_screen
    play world "Dungeon2.ogg" fadein 2.0 loop
    scene bg story dark_room with dissolve
    "This is the place where lived the kunoichi, a small room in a dirty, old hotel. You should examine it, maybe there are some clues left."
    label konan_room_search:
    call screen poly_matrix("library/events/StoryI/coordinates.json", show_exit_button=(1.0, 1.0))

Code: [Select]
label intro_story_konan_room:
    stop music
    stop world
    hide screen pyt_city_screen
    $ k = chars["Konan"]
    $ k_spr = chars["Konan"].get_vnsprite()
    $ konan_orig = konan_ling = konan_protector = a = b = c = d = e = f = sc = 0
   
    play world "Dungeon2.ogg" fadein 2.0 loop
    scene bg story dark_room with dissolve

    "This is the place where lived the kunoichi, a small room in a dirty, old hotel. You should examine it, maybe there are some clues left."

label konan_room_search:
    call screen poly_matrix("library/events/StoryI/coordinates.json", show_exit_button=(1.0, 1.0))
« Last Edit: October 14, 2015, 05:37:40 AM by Xela »
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6070 on: October 14, 2015, 05:41:50 AM »
I am not asking you to rewrite your code, just make sure that all label declarations are on the base indent, this has nothing to do with coding practices, just code readability.
For complex things it's the same thing as rewriting them  :D
Whatever, I'll rewrite all scripts.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6071 on: October 14, 2015, 06:07:44 AM »
There is difference between rewriting and reviewing :D This is not even refactoring, there should be no need to change the code to any significance.
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6072 on: October 14, 2015, 06:27:42 AM »
Btw in your example you looking at my first attempt to use matrix. It's not a good idea, this script is for trying matrix out, it won't be used in the game, since I have a much better idea how to use both matrix and Konan (prison_break.rpy).


In sex scene for example I created at first a label for normal sex options that includes all checks and scenes. Then, much later, added hire fox sex option that uses the same scenes but not the same checks. Thus I jump past normal checks directly to the scenes.

In order to avoid it I'll need to separate all interactions and scenes completely.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6073 on: October 14, 2015, 07:09:57 AM »
Btw in your example you looking at my first attempt to use matrix. It's not a good idea, this script is for trying matrix out, it won't be used in the game, since I have a much better idea how to use both matrix and Konan (prison_break.rpy).


That was the first instance of label declarations I've found.

In sex scene for example I created at first a label for normal sex options that includes all checks and scenes. Then, much later, added hire fox sex option that uses the same scenes but not the same checks. Thus I jump past normal checks directly to the scenes.

In order to avoid it I'll need to separate all interactions and scenes completely.

What file are we talking about?
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6074 on: October 14, 2015, 07:10:45 AM »
GM - sex.rpy