[STRUCTURE] How to stock text properly?

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
Therozin
Newbie
Posts: 5
Joined: Mon May 02, 2016 4:46 am
Github: Therozin
Contact:

[STRUCTURE] How to stock text properly?

#1 Post by Therozin » Tue May 03, 2016 2:34 pm

Good evening,

A simple question about how one should structure the renpy code. I'm kind of a purist and I like when a code is clean and easily readable. The point is that with visual novels, a lot of text will eventually appears. So here's my question, how do you stock the text of your game? Do you simply put it in the renpy files as expected? Or do you use another way?

I had the idea of using json files to stock every dialogues, menus and choices in them. Does anyone have already done it? Has it more pro or cons? Is there any other solutions suitable?

Thanks in advance for your answers!
Last edited by Therozin on Tue May 03, 2016 3:04 pm, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: [STRUCTURE] How to do stock text properly?

#2 Post by xela » Tue May 03, 2016 2:46 pm

Ren'Py files are very clean, I heavily rely on json to store data for items/locations/characters and etc. but I doubt that you'll be able to come up with something cleaner than Ren'Py script for VN mode itself.
Like what we're doing? Support us at:
Image

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: [STRUCTURE] How to do stock text properly?

#3 Post by drKlauz » Tue May 03, 2016 3:01 pm

I fail to see point in json with RenPy/Python. Python is scripting language which can be editer by simple text editor. If you add json layer over python, why you using python at all? Why not use more performant/widespread language?
Only more or less good reason i see is if you use some kind of automatic testing/authoring tools. Otherwise i would simple split core mechanics (game specific layer on top of RenPy) and data (dialogues, descriptions, definitions). Both parts done fully in RenPy/Python.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
Therozin
Newbie
Posts: 5
Joined: Mon May 02, 2016 4:46 am
Github: Therozin
Contact:

Re: [STRUCTURE] How to stock text properly?

#4 Post by Therozin » Tue May 03, 2016 3:11 pm

Indeed, maybe I'm seeking problems where I shouldn't be.

I must say that Renpy is very clean when it comes to coding, I doubt it could be clearer. The idea was, for example, having a code looking like this.

Code: Select all

Character "[DialogueManager("Id_of_dialogue")]"
That would have made the code shorter, hence less dense prima facie. Maybe you could point me to some game codes that might be a good example to follow in the general practice? The point is that I really want to do something clean if I am to work with people one day. ^^

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: [STRUCTURE] How to do stock text properly?

#5 Post by xela » Tue May 03, 2016 3:27 pm

drKlauz wrote:I fail to see point in json with RenPy/Python..
It's cleaner, no interim variables, no checking for errors every time the engine starts and etc. It'll make sense with large amounts of data.
Therozin wrote:

Code: Select all

Character "[DialogueManager("Id_of_dialogue")]"
You'll go crazy looking for lines you wish yo fix :D But it's an option.
Like what we're doing? Support us at:
Image

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: [STRUCTURE] How to stock text properly?

#6 Post by drKlauz » Tue May 03, 2016 3:31 pm

If you have lots of dialogues with very close structure then you can call label with arguments or write python function.
But i really miss point why at all you want to use any DialogueManager? To make localization easier? Or you got special authoring tools/semi-automated game editor? Don't create complex things when you can use simple ones.
I believe for most cases of RenPy games, you should simple write as supposed. If you have complex game structure and RenPy feel restricting, then perhaps you shouldn't fight engine block, but try other tools, as, let's speak honestly, RenPy is not perfect, especially in performance area.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: [STRUCTURE] How to stock text properly?

#7 Post by drKlauz » Tue May 03, 2016 3:40 pm

It's cleaner, no interim variables, no checking for errors every time the engine starts and etc. It'll make sense with large amounts of data.
I usually use something like:

Code: Select all

class Goblin(NPC):
  Name='Goblin'
  HP=50
  Str=5
  Int=1
...
StartCombat([Game.PC],[Goblin,Goblin,Goblin])
This way i can use metaclasses, autoregistration, autochecking etc. With json you have to write code what reconstruct json into python object/class/data. Some time ago i made fully custom gui system (freepascal+python, windows, buttons, rich text, etc), tried using xml for controls/form/windows definition, it's simple extra work without much profit. It really useful with compiled language (with freepascal only or c) json/xml justified greatly, but with python... If i can write things in one language, i usually do.
But perhaps it's more of personal choice.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: [STRUCTURE] How to stock text properly?

#8 Post by xela » Tue May 03, 2016 4:04 pm

drKlauz wrote:But perhaps it's more of personal choice.
It is.
drKlauz wrote:I usually use something like:

Code: Select all

class Goblin(NPC):
  Name='Goblin'
  HP=50
  Str=5
  Int=1
...
StartCombat([Game.PC],[Goblin,Goblin,Goblin])
And we use:

Code: Select all

    {
        "name": "Goblin",
        "desc": "A small carnivore creature with razor sharp teeth.",
        "front_row": 1,
        "battle_sprite": "content/npc/mobs/w.png",
        "portrait": "content/npc/mobs/w1.png",
        "race": "Goblinoid",
        "locations": [],
        "min_lvl": 1,
        "basetraits": [
            "Trickster"
        ],
        "stats": {
            "attack": 7,
            "defence":4,
            "magic": 0,
            "agility": 6,
            "luck": -50,
            "charisma": 0,
            "constitution": 10,
            "intelligence": 5
        },
        "skills": {},
        "traits": ["Monster", "Neutral"],
        "attack_skills": [
            "ClawAttack"
        ],
        "magic_skills": [
        ]
    },
it all works well at the end.
Like what we're doing? Support us at:
Image

drKlauz
Veteran
Posts: 237
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: [STRUCTURE] How to stock text properly?

#9 Post by drKlauz » Tue May 03, 2016 4:15 pm

Well, python offer some nice options like inheritance, in-place calculations and some other mentioned things. More flexibility. I remember spidweb games (geneforge i believe) used some kind of ini files for descriptions, each item had ID number, inheritance was simple "ParentID=123". Crude in my opinion.

But yes, if it works, it's good enough.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: [STRUCTURE] How to stock text properly?

#10 Post by xela » Tue May 03, 2016 4:41 pm

Well... the parent class is about 2k lines of python code long. Mobs child is smaller, child for advanced character is another 2k on top of the parent. This is raw data, some of it are properties, some conditions. JSON has a nice lint and most online editors will format your file so it looks pretty. Loading it into a dict is very easy.

You don't really loose any functionality. It feels really clean to me but this would have worked as python dict just as well.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]