Would it be the best idea to update code?

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
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Would it be the best idea to update code?

#1 Post by namastaii »

What I mean by this is if I'm currently using a structure like this:

Code: Select all

style.my_button.background
would it make much of a difference to update it to this:

Code: Select all

style my_button:
    background:
One is using Python while the other is using Ren'Py's language, right? Does it really not matter or is one truly better than the other?

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Would it be the best idea to update code?

#2 Post by Donmai »

Although the old syntax is still valid, the changes were made not only to make the code simpler to create and edit, but also to increase its performance.
The new code reduces the amount of time it takes to create a new style to a small fraction of the previous time. Since every displayable creates an associated style, this has the potential to lead to a substantial performance improvement.
Lengthy and redundant code like:

Code: Select all

init python:
    style.quick_button_text.set_parent('default')
    style.quick_button_text.size = 12
    style.quick_button_text.idle_color = "#8888"
    style.quick_button_text.hover_color = "#ccc"
can be replaced with:

Code: Select all

style quick_button_text is default:
    size 12
    idle_color "#8888"
    hover_color "#ccc"
https://www.renpy.org/doc/html/changelo ... en-py-6-17
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Would it be the best idea to update code?

#3 Post by namastaii »

Does it affect performance?

User avatar
theCodeCat
Regular
Posts: 62
Joined: Sun Sep 06, 2015 8:40 pm
Projects: Lucid9, Mystic Destinies: Serendipity of Aeons
Skype: theCodeCat
Contact:

Re: Would it be the best idea to update code?

#4 Post by theCodeCat »

I don't know the details but I pretty sure any performance increase or decrease is negligible. Just use whatever style works for you.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Would it be the best idea to update code?

#5 Post by Donmai »

theCodeCat wrote:I don't know the details but I pretty sure any performance increase or decrease is negligible.
Well, I also don't know he details, but the documentation isn't calling it "negligible".
The new code reduces the amount of time it takes to create a new style to a small fraction of the previous time. Since every displayable creates an associated style, this has the potential to lead to a substantial performance improvement.
But yes, if the old way works and you prefer it, go for it. The Amish prefer to live in houses with no electricity, and their houses still work.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
theCodeCat
Regular
Posts: 62
Joined: Sun Sep 06, 2015 8:40 pm
Projects: Lucid9, Mystic Destinies: Serendipity of Aeons
Skype: theCodeCat
Contact:

Re: Would it be the best idea to update code?

#6 Post by theCodeCat »

The reason I think it's likely negligible is because creating a new style is likely a one-time occurrence that happens during the game's initialization, and it probably takes less than 1/100th of a second even when done inefficiently.
Given those time estimates, even if this new style made the creation process instantaneous, you are saving less than 1/100th of a second when the game initially boots up. With performance differences that small I think you are better off ignoring them completely.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Would it be the best idea to update code?

#7 Post by namastaii »

Less typing is definitely better. Instead of typing out each line starting with style. May be easier to sort through too

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Ocelot