Simple Choice logging system
Forum rules
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
-
- Regular
- Posts: 42
- Joined: Sun Apr 12, 2020 11:50 pm
- Projects: Wind and Spirit
- Organization: Monoway Studios
- Contact:
Simple Choice logging system
[removed]
Last edited by abysswatcher on Wed Jul 01, 2020 8:02 am, edited 2 times in total.
The goal of the revolution is to achieve the people's rights, but during the course of the revolution, we must stress military power - and the two are mutually contradictory.
-Sun Yat-sen
"Become a Visual Novel writer they said, it will be fun" (little did they know they were right)
-Sun Yat-sen
"Become a Visual Novel writer they said, it will be fun" (little did they know they were right)
-
- Regular
- Posts: 111
- Joined: Fri Oct 11, 2013 12:46 am
- Contact:
Re: Simple Choice logging system (don't need to define 1000 variables)
I would advise not to use this.
On a surface level, this implementation is just a wrapper over python's list. It does not add or modify any functionality, but anyone using it will be unable to benefit from all the python list tutorials available online. If you really want this sort of implementation, you can just use a list without the class on top.
On a deeper level, the bigger your list gets, the slower the lookup will be. Finding a value in a list is orders of magnitude slower than checking a variable. If you really want to create variables on the fly, use setattr().
There's also the inevitable typo bug to consider. Using this implementation or similar, a typo when checking if a string is in the list could easily go unnoticed without rigorous testing. Debugging it will be a huge pain. A typo in a variable will cause a crash, which is what you want.
On a surface level, this implementation is just a wrapper over python's list. It does not add or modify any functionality, but anyone using it will be unable to benefit from all the python list tutorials available online. If you really want this sort of implementation, you can just use a list without the class on top.
On a deeper level, the bigger your list gets, the slower the lookup will be. Finding a value in a list is orders of magnitude slower than checking a variable. If you really want to create variables on the fly, use setattr().
There's also the inevitable typo bug to consider. Using this implementation or similar, a typo when checking if a string is in the list could easily go unnoticed without rigorous testing. Debugging it will be a huge pain. A typo in a variable will cause a crash, which is what you want.
-
- Regular
- Posts: 159
- Joined: Fri Jan 04, 2019 3:44 pm
- Contact:
Re: Simple Choice logging system (don't need to define 1000 variables)
Unless I misunderstand, I think the problem being solved here is already supported by Ren'Py proper - check out the menu set functionality (link below). It's implementation (using a set rather than a list) also addresses some of the concerns raised by Human Bolt Diary.
https://www.renpy.org/doc/html/menus.html#menu-set
https://www.renpy.org/doc/html/menus.html#menu-set
-
- Regular
- Posts: 42
- Joined: Sun Apr 12, 2020 11:50 pm
- Projects: Wind and Spirit
- Organization: Monoway Studios
- Contact:
Re: Simple Choice logging system (don't need to define 1000 variables)
I wanted to see if there was a way to raise an error for this. This method is actually part of a custom character class which uses it for traits and special event logging I do realise that it can't be used for a lot of variables due to performance reasons.Human Bolt Diary wrote: ↑Wed Jul 01, 2020 12:23 am I would advise not to use this.
On a surface level, this implementation is just a wrapper over python's list. It does not add or modify any functionality, but anyone using it will be unable to benefit from all the python list tutorials available online. If you really want this sort of implementation, you can just use a list without the class on top.
On a deeper level, the bigger your list gets, the slower the lookup will be. Finding a value in a list is orders of magnitude slower than checking a variable. If you really want to create variables on the fly, use setattr().
There's also the inevitable typo bug to consider. Using this implementation or similar, a typo when checking if a string is in the list could easily go unnoticed without rigorous testing. Debugging it will be a huge pain. A typo in a variable will cause a crash, which is what you want.
The goal of the revolution is to achieve the people's rights, but during the course of the revolution, we must stress military power - and the two are mutually contradictory.
-Sun Yat-sen
"Become a Visual Novel writer they said, it will be fun" (little did they know they were right)
-Sun Yat-sen
"Become a Visual Novel writer they said, it will be fun" (little did they know they were right)
-
- Regular
- Posts: 42
- Joined: Sun Apr 12, 2020 11:50 pm
- Projects: Wind and Spirit
- Organization: Monoway Studios
- Contact:
Re: Simple Choice logging system (don't need to define 1000 variables)
Care to elaborate on this? It doesn't explain much to mestrayerror wrote: ↑Wed Jul 01, 2020 4:43 am Unless I misunderstand, I think the problem being solved here is already supported by Ren'Py proper - check out the menu set functionality (link below). It's implementation (using a set rather than a list) also addresses some of the concerns raised by Human Bolt Diary.
https://www.renpy.org/doc/html/menus.html#menu-set
How is this implemented and what does it do?
The goal of the revolution is to achieve the people's rights, but during the course of the revolution, we must stress military power - and the two are mutually contradictory.
-Sun Yat-sen
"Become a Visual Novel writer they said, it will be fun" (little did they know they were right)
-Sun Yat-sen
"Become a Visual Novel writer they said, it will be fun" (little did they know they were right)
Who is online
Users browsing this forum: No registered users