Hide/'Image tag' & scripting extensions questions

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
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Hide/'Image tag' & scripting extensions questions

#1 Post by Jake »

Hi...

I've started playing around with Ren'Py over the last week or so, and am taking the opportunity to force myself to learn Python while I'm there. To this end - and because an idea I have for a pie-in-the-sky future project would require it - I've been extending the Character class to collate all the character-related information, mostly in terms of handling images and display for that character. It's not much, but I'm learning stuff and I figure that if I'm going to use that kind of approach in the future, it'd be best to get used to it now...

Anyway, I've come across a couple of things I'm unsure about in the process. I guess these are really just questions and/or bug reports for PyTom - I'm using 5.5.2a here:

Firstly, the way that the renpy.hide function works seems to disagree significantly with the 'hide' Ren'Py command and its reference entry, e.g.:

Code: Select all

    show eileen happy
    
    "Now you see her..."
    
    hide eileen
    
    "Now you don't."
    
    $ renpy.show ( ('eileen', 'happy') )
    
    "Now you see her..."
    
    $ renpy.hide ( ('eileen') )
    
    "Now you... hey, wait!"

    $ renpy.hide ( ('eileen', 'something', 'else') )
    
    "Bizarre..."
    
    
The renpy.hide method claims to only pay attention to the image tag, but unless I actually provide a tuple of equal length to the one the image was shown with, it doesn't disappear. The bizarre part being that it doesn't seem to matter what the other part/s of the tuple are, just so long as there are more than one of them. If I try the same thing with 3-tuple in the renpy.show call, then a 2-tuple in renpy.hide hides it, but a 1-tuple doesn't. Can I assume this is an unintentional bug?


Secondly, and I guess probably a little more unlikely, is it possible at all to extend/replace/overload/add to/etc the RenPy scripting commands? Ideally (at least, for starters... ;-) I'd like to overload the 'show' and 'hide' commands to take Character instances rather than image names, but I'm thinking Python's loose typing probably precludes overloads of any kind anywhere anyway.
I've poked around the various Python scripts - the methods in /renpy/exports.py look most likely, but working on the suspicion that it probably isn't possible in a clean (by which I mean without changing existing engine classes) manner I've not looked into it too deeply.

Thirdly, and least helpfully... while I was messing around testing my class, I was inserting new stuff at the beginning of the demo script. At some point in the middle of my testing, I started to get an error from the following line:

Code: Select all

"Girl" "Hi, and welcome to the %(version)s demo program."
- I think that the error said something along the lines of "str() function could not be executed". This was happening when my own code appeared to be running fine. I figured I'd look at it once I'd finished my class, but when I'd got to a point I was happy with it mysteriously stopped happening.

I figure that it was probably caused by something I was doing wrong, which I stopped doing wrong, but... anyone got any idea what? It'd be useful to know what kind of errors to look for if I ever got it again...



Anyway - all in all, aside from my various objections to Python, I'm really impressed! Hopefully I'll actually get around to finishing something rather than just messing around with the coding part...

(Oh, and if any forum-admin type people were to read this, I accidentally registered under my usual nickname, 'Sar', with an email address that's having problems. I imagine the profile has enough infomation to verify that's also me; I'll likely never get the activation mail, so feel free to delete it)

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Hide/'Image tag' & scripting extensions questions

#2 Post by PyTom »

Jake wrote:

Code: Select all

    $ renpy.hide ( ('eileen') )
This line is buggy. renpy.hide takes a tuple, and you're giving it a string. In Python (and hence Ren'Py), one writes a single-element tuple as:

Code: Select all

('eileen', )
Secondly, and I guess probably a little more unlikely, is it possible at all to extend/replace/overload/add to/etc the RenPy scripting commands? Ideally (at least, for starters... ;-) I'd like to overload the 'show' and 'hide' commands to take Character instances rather than image names, but I'm thinking Python's loose typing probably precludes overloads of any kind anywhere anyway.
In general, the definitions of Ren'Py commands are not particularly user-serviceable. You'd need to edit the parser and the ast, at the very least, to change them,

Your best bet is to simply define a python function that does what you want.

- I think that the error said something along the lines of "str() function could not be executed". This was happening when my own code appeared to be running fine. I figured I'd look at it once I'd finished my class, but when I'd got to a point I was happy with it mysteriously stopped happening.
Without the exact error message (and preferably the contents of traceback.txt), it's hard to tell what could cause this. I don't recognize the error message, anyway.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Hide/'Image tag' & scripting extensions questions

#3 Post by Jake »

PyTom wrote:In Python (and hence Ren'Py), one writes a single-element tuple as:

Code: Select all

('eileen', )
Aha!

That's... a bit weird. But thanks!

Thankfully that part's buried in the class, so it's not something I'll have to do that often...
PyTom wrote: Your best bet is to simply define a python function that does what you want.
Mm... that's what I've done, it just means that 10% of the script is going to end up prefixed with '$' rather than just the odd line here and there. Since the big strength of RenPy over other engines I looked at seems to be the near-natural-language scripting, it just seems a bit of a shame. ;-)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Semrush [Bot]