[Solved] Python to Ren'Py Translation

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
AceQueenKimu24
Newbie
Posts: 19
Joined: Mon May 08, 2017 5:17 am
Projects: Blooming Romance | Marionette
Deviantart: 24WildHeart
itch: 24_wildheart
Contact:

[Solved] Python to Ren'Py Translation

#1 Post by AceQueenKimu24 » Fri Nov 20, 2020 10:24 pm

Good day! I just started studying Python and I have a little trouble translating this code into one that renpy accepts:

Code: Select all

 _history_list = [ "last dialogue" , "2nd to the last dialogue" , "3rd to the last dialogue" , "4th to the last dialogue" ]
hisnum = 0

for h in _history_list :
    hisnum += 1
    if hisnum <= 3:
        print(h)
    else :
        break

##the goal was to print/display three lines of text/dialogue and three only.
I wanted to make a little area where a snippet of the current gameplay is showed, like a mini history screen. If there are any ideas or opinions I'm open to them ^^ thank you for your time.
Last edited by AceQueenKimu24 on Wed Nov 25, 2020 7:39 pm, edited 1 time in total.
Image

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

Re: [Question] Python to Ren'Py Translation

#2 Post by drKlauz » Sat Nov 21, 2020 12:40 am

Code: Select all

screen test_history():
  frame:
    vbox:
      for entry in _history_list[-3:]:
        text str(entry.who)+": "+str(entry.what)

label start:
  show screen test_history
  ...
Works even if there is less that 3 history entries or it is empty.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
AceQueenKimu24
Newbie
Posts: 19
Joined: Mon May 08, 2017 5:17 am
Projects: Blooming Romance | Marionette
Deviantart: 24WildHeart
itch: 24_wildheart
Contact:

Re: [Question] Python to Ren'Py Translation

#3 Post by AceQueenKimu24 » Wed Nov 25, 2020 7:36 pm

Works like a charm! Many thanks drKlauz ^^
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot]