CREATE YOUR AI CUM SLUT ON CANDY.AI TRY FOR FREE
x

I need some displaying a python variable in ren'py navigation screen

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,009
16,295
[Note: don't mind my presence, it's just some brain works because its already 4AM and I need to stay awake.]

Uhm.... remove the -> () <- in the method I gave you and it works....
Code:
    @property
    def weekday(self):
Because it's a property, not a method. I assume that the person who wrote the code did it because Ren'py don't deal with callable in its text substitution.

With @Epaddder you both saw part of the problem. He the missing quotes, you the "=". So in the end, this will also works:
Code:
text "[clock.weekday]" size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
same for this :
Code:
    text clock.weekday size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
and this :
Code:
     [...]
#    @property
     def weekday( self ):
    [...]

    text clock.weekday() size 36 color "#ffffff" font "agencyb.ttf" xpos 20 ypos 50
But here a problem with the last two solutions, because the day and time are numbers and not strings. So they need to be forced as string. Either at the source :
Code:
   [...]
   @property
   def time(self):
       return str( self.time_of_day[0] )
   @property
   def today( self ):
       return str( self.day )
Or at the end point :
Code:
    text str( clock.day ) size 32 color "#ffffff" font "agencyb.ttf" xpos 120 ypos 90
Finally, @EvilUser , there's no need to go full styling. The common part can be a defined style :
Code:
style ngui_text is default:
   size = 32
   color = "#fff"
   font = "agencyb.ttf"

   [...]
    text "[clock.weekday]" style "ngui_text" xpos 20 ypos 50
Or :
Code:
style ngui_text is default:
   size = 32
   color = "#fff"
   font = "agencyb.ttf"

screen ngui:
   style_prefix "ngui"
   [...]
    text "[clock.weekday]" xpos 20 ypos 50
is a screen property that will define the prefix for the style of all the elements of the screen. The style need to be formatted like this "[prefix]_[name of the screen statement]" ; so, here "ngui_text". Then Ren'py will automatically apply the right style to the elements of the screen, or the default style if there's no specific style.
By example, if you add a "vbox" in the screen, either you create a "ngui_vbox" style that Ren'py will use, or Ren'py will use the default style for the vbox (style.vbox).
 
  • Like
Reactions: Palanto and Epadder

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,064
*Slams head into desk repeatedly* :oops:
I can't believe I overlooked the '=' ... The thing that popped in my head after looking over my own code, was the missing quotes :coldsweat:
 

EvilUser

Member
Game Developer
Mar 29, 2018
309
984
As you may realized I am pretty dummy when it comes to python coding, I was trying to solve my new gui for like 35+ hours. Tried everything I have found on other forums (it's from where the original python code comes)... Last thing to do was trying F95 brothers, and I am very thankful for your help. I didn't wanted to ask here because my game can be found here and I didn't wanted someone to say "look at this dev, can't solve an easy problem" or something like that :)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,009
16,295
*Slams head into desk repeatedly* :oops:
I can't believe I overlooked the '=' ... The thing that popped in my head after looking over my own code, was the missing quotes :coldsweat:
To be honest, I didn't see it before I copy/paste one of the "text =" line in my editor.


I didn't wanted to ask here because my game can be found here and I didn't wanted someone to say "look at this dev, can't solve an easy problem" or something like that :)
Saying that there's no one like this here is probably wrong. But what I see, and I know that I'm far to be the sole in this case, is the opposite of that. I see a dev who acknowledge his limits, try to find solutions and don't hesitate to ask for help. If you take a look at this section of the forum, you'll see that you are far to be the only one, and that they all found an answer without being shamed ; and you'll find way more if you take a look at the discord.
So, never hesitate to ask for help. There's no dumb question, no "please help me" that will make you look like a fool. And, because being awake since more than 30 hours now tend to change me in a philosopher (in addition to messing with my English): Being smart isn't knowing everything, it's not fearing to ask whatever you don't know ; it's like this, and like this only, that you end knowing a little more at the end of the day.
 
  • Like
Reactions: Palanto

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
Saying that there's no one like this here is probably wrong. But what I see, and I know that I'm far to be the sole in this case, is the opposite of that. I see a dev who acknowledge his limits, try to find solutions and don't hesitate to ask for help. If you take a look at this section of the forum, you'll see that you are far to be the only one, and that they all found an answer without being shamed ; and you'll find way more if you take a look at the discord.
So, never hesitate to ask for help. There's no dumb question, no "please help me" that will make you look like a fool. And, because being awake since more than 30 hours now tend to change me in a philosopher (in addition to messing with my English): Being smart isn't knowing everything, it's not fearing to ask whatever you don't know ; it's like this, and like this only, that you end knowing a little more at the end of the day.
So true... we all get to a point where we can't figure out what we did wrong. So in a way you proofed yourself to be a good dev, since you didn't just say: "fuck it I'm going to do it alone and if it takes me hundreds of hours" you, as a lot of us, acknowledged the fact that you need a little help there. Sure this one might seem simple after you got the right answer. But after looking at it for hours it makes it even more difficult to find the answer. So a set of fresh eyes might find something a lot faster than yours after hours of searching. Besides, sometimes it's easier to find a bug someone else wrote than your own ;)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,009
16,295
Besides, sometimes it's easier to find a bug someone else wrote than your own ;)
Oh yes... It's your code, if you wrote it, it's because you thought that it must be wrote like this ; no one goes, "well, I'll randomly type some keyword and see if it works" :D
And like you said, you've looked at this for hours. It mean that, many times, you had your eyes right on the error, and still thought that "this is correct". It's now deeply print in your mind, "this line is not the one with the error". Unless you do something else for few days, or rewrite everything from scratch, it's too late. You'll never found this error by yourself.
 

Gecko_

"Project x"
Donor
Game Developer
May 30, 2017
108
392
Nice post. Could anyone tell me how can I implement this so instead of text I show an image based on the time, and how to make events locked only for one day e.g. Monday?
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
Well, instead of "Text bla bla" you use
Code:
add "imageLocation/imageName.imageExtension"
or
Code:
add preDefinedImage
The locking works with if else statements...
Code:
if day == "monday":
    event thing
 
Last edited:

Gecko_

"Project x"
Donor
Game Developer
May 30, 2017
108
392
Got it thanks I used:
Code:
label name:
    if clock.weekday == "Monday":
        jump labelname1
    if clock.weekday == "Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday":
        jump labelname2
But still can't figure it out how to show time of day with images.
Managed it somehow
Code:
if clock.time == "timeofday":
                add "imagelocation/timeofdayimage.png"
Thanks again for the help, I wish this help people in the future.
Cheers.
 
Last edited:
  • Like
Reactions: Palanto

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
11,009
16,295
Code:
label name:
    if clock.weekday == "Monday":
        jump labelname1
    if clock.weekday == "Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday":
        jump labelname2
Like there's only one exception, this :
Code:
label name:
    if clock.weekday == "Monday":
        jump labelname1
    else:
        jump labelname2
is probably better since it remove height possible cause of error ; the object name, the attribute name, plus six for the day names.
 
  • Like
Reactions: Palanto and Gecko_