Re: Encyclopaedia / Bestiary Framework
Posted: Sun Jan 29, 2017 9:17 pm
Maybe removing the sorting buttons?LabaroDD wrote:Here is the way to disable sorting?
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
Maybe removing the sorting buttons?LabaroDD wrote:Here is the way to disable sorting?
It wasn't enough just remove it... So I commented up parts of "SortingMode" in encyclopaedia.rpy and script.rpy and left this part (in script.rpy either):daikiraikimi wrote:Maybe removing the sorting buttons?LabaroDD wrote:Here is the way to disable sorting?
Code: Select all
screen encyclopaedia_list:
tag menu
use encyclopaedia_navigation
vbox:
style_group "mm_root"
viewport:
scrollbars "vertical"
mousewheel True
draggable True
vbox:
# text encyclopaedia.sortingMode xalign 0.5 #Flavour text to display the current sorting mode.
python:
for x in range(encyclopaedia.entry_list_size):
generateEntryButton(x,encyclopaedia)
Code: Select all
# Define an encyclopaedia object.
encyclopaedia1 = Encyclopaedia(
sorting_mode = Encyclopaedia.SORT_NUMBER,
show_locked_buttons=True,
show_locked_entry=True,
entry_screen="encyclopaedia_entry"
# Define an encyclopaedia object.
encyclopaedia2 = Encyclopaedia(
sorting_mode = Encyclopaedia.SORT_NUMBER,
show_locked_buttons=True,
show_locked_entry=True,
entry_screen="encyclopaedia_entry"
Code: Select all
en1 = EncEntry(
encyclopaedia1,
1,
"First Character",
[
"Character Name. Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
"Vivamus in nisl magna. Fusce nec bibendum magna, sed venenatis erat. ",
"Sed non dapibus augue, quis hendrerit diam. ",
"Quisque bibendum turpis vitae orci iaculis volutpat. ",
"Proin venenatis, nunc quis tempus convallis, lectus eros ultrices sem, eu condimentum tellus nisi sed magna. ",
"Curabitur laoreet posuere orci eu eleifend. ",
"Vivamus sed dui dignissim, egestas lorem eu, lobortis arcu. ",
"Duis venenatis sem eu ipsum condimentum adipiscing. ",
"Ut vel augue ut velit bibendum varius pharetra nec ligula. ",
"Duis eu sollicitudin mauris. ",
"Praesent vestibulum ligula vel ligula condimentum dignissim. ",
"Ut risus velit, laoreet sed pellentesque sed, suscipit in massa. ",
"Etiam posuere fringilla purus.",
],
"Love Interests",
viewed=persistent.new_status["new_01"],
locked=False,
image=en1_image,
)
Code: Select all
screen encyclopaedia_list(enc):
tag menu
modal True
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/enc_data.rpy", line 9: is not terminated with a newline. (Check strings and parenthesis.)
encyclopaedia1 = Encyclopaedia(
Ren'Py Version: Ren'Py 6.99.11.1749
So, in general you will probably have to be really careful about making sure you replace everywhere in the script that uses "encyclopaedia" with "encyclopaedia1" (and that you duplicate those sections for the second encyclopaedia, too.) Regarding your error, that looks to me like it has nothing to do with adding the one and instead is a problem with spaces or parenthesis.LabaroDD wrote:Thanks for advice, I'll try to do it right now!
...Well, I have a first problem here:
Where exactly I should define an encyclopaedia1, etc?Code: Select all
I'm sorry, but errors were detected in your script. Please correct the errors listed below, and try again. File "game/enc_data.rpy", line 9: is not terminated with a newline. (Check strings and parenthesis.) encyclopaedia1 = Encyclopaedia( Ren'Py Version: Ren'Py 6.99.11.1749
Code: Select all
# Define an encyclopaedia object.
encyclopaedia = Encyclopaedia(
sorting_mode = Encyclopaedia.SORT_NUMBER,
show_locked_buttons=True,
show_locked_entry=True,
entry_screen="encyclopaedia_entry"
)
No problem at all, I'm glad I could help. So, regarding what you're describing, it seems like you want the ability to add more text to main entries after they are unlocked in gameplay? I think there is a better way of doing this that doesn't deal with sub-entries, actually. Instead it just adds text onto the end of the main entry block.LabaroDD wrote:Thank you, daikiraikimi, it works!
The last one question and I'll finally leave you: could you help me with sub-entry text? After unlocking sub-entries appears in the next pages by default, but I want them appearing in the end of main entry's text block, without any pages. Like this:
"Main entry, blablabla"
+
"Sub-entry, blablabla"
I have boxes with scrolling, and sub-entries in pages looks pretty strange.
Code: Select all
# Herb Identification vol. 1
en1 = EncEntry(
encyclopaedia,
1,
"Herb Identification vol. 1",
[
"Thistle. Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
"Vivamus in nisl magna. Fusce nec bibendum magna, sed venenatis erat. ",
"Sed non dapibus augue, quis hendrerit diam. ",
"Quisque bibendum turpis vitae orci iaculis volutpat. ",
"Proin venenatis, nunc quis tempus convallis, lectus eros ultrices sem, eu condimentum tellus nisi sed magna. ",
"Curabitur laoreet posuere orci eu eleifend. ",
"Vivamus sed dui dignissim, egestas lorem eu, lobortis arcu. ",
"Duis venenatis sem eu ipsum condimentum adipiscing. ",
"Ut vel augue ut velit bibendum varius pharetra nec ligula. ",
"Duis eu sollicitudin mauris. ",
"Praesent vestibulum ligula vel ligula condimentum dignissim. ",
"Ut risus velit, laoreet sed pellentesque sed, suscipit in massa. ",
"Etiam posuere fringilla purus.",
],
"Herb Identification",
viewed=persistent.new_status["new_01"],
locked=False,
image=en1_image,
)
You can swap out the entire text in an entry by doing:LabaroDD wrote:Thank you, daikiraikimi, it works!
The last one question and I'll finally leave you: could you help me with sub-entry text? After unlocking sub-entries appears in the next pages by default, but I want them appearing in the end of main entry's text block, without any pages. Like this:
"Main entry, blablabla"
+
"Sub-entry, blablabla"
I have boxes with scrolling, and sub-entries in pages looks pretty strange.
Code: Select all
your_entry.text = ["An entirely new set of text for the entry."]
Code: Select all
your_entry._text.append("A new line of text.")
Code: Select all
def unlock_entry(self):
self.locked = False
self.viewed = False
if entry.has_sub_entry:
for subent_data in entry.sub_entry_list:
subent_data[1].locked = False
self.add_entry(subent_data[1])
self.viewed = False
Code: Select all
class UnlockEncEntry(EncyclopaediaAction):
def __init__(self, entry):
self.entry = entry
def __call__(self):
entry.unlock_entry()
Code: Select all
class Item(store.object):
def __init__(self, name, desc, icon=False, value=0, act=Show("inventory_popup", message="Nothing happened!"), type="item", recipe=False):
global cookbook
self.name = name
self.desc = desc
self.icon = icon
self.value = value
self.act = act # screen action
self.type = type # type of item
self.recipe = recipe # nested list of [ingredient, qty]
if recipe:
cookbook.append(self)
cookbook.sort(key=lambda i: i.name) #alpha order
Code: Select all
$ book = Item("Herb Identification Guide", "A book of herbs", "inv/book.png", 5000, act=UnlockEncEntry(en1))
Code: Select all
def unlock_entry(self):
#Changes the locked status of an entry and all sub-entries
self.locked = False
self.viewed = False
if self.has_sub_entry:
for subent_data in self.sub_entry_list:
subent_data[1].locked = False
self.add_entry(subent_data[1])
self.viewed = False
Code: Select all
import enc_code.encentry
Code: Select all
class UnlockEncEntry(EncyclopaediaAction):
#Calls EncEntry.unlock_entry, can be assigned to a button
def __init__(self, entry):
self.entry = entry
def __call__(self):
enc_code.encentry.EncEntry.unlock_entry(self.entry)
Code: Select all
label define_items:
$ import enc_code.encentry
$ import enc_code.actions
"Encyclopaedia Actions have been imported."
######### DEFINE ITEM OBJECTS ##########
### The format is name, description, icon image (if applicable), value (if applicable, selling/buying value), action (screen language action to be performed when icon is clicked on inventory screen), and recipe (if craftable).
Code: Select all
#Books
#This is currently broken. It says UnlockEncEntry is not defined.
#Need to investigate when the action code for encyclopedia runs.
$ herbID1 = Item("Herb Identification vol. 1", "A book of herbs", "inv/book.png", 5000, act=enc_code.actions.UnlockEncEntry(en1))
$ herbID2 = Item("Herb Identification vol. 2", "A book of herbs", "inv/book.png", 5000, act=enc_code.actions.UnlockEncEntry(en2))
$ herbID3 = Item("Herb Identification vol. 3", "A book of herbs", "inv/book.png", 5000, act=enc_code.actions.UnlockEncEntry(en3))
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00gamemenu.rpy", line 173, in script
$ ui.interact()
File "renpy/common/00gamemenu.rpy", line 173, in <module>
$ ui.interact()
File "game/encyclopaedia.rpy", line 298, in __call__
self.enc_dict[self.tag_string + str(x)] = self.enc.all_entries[x][1].status
TypeError: 'NoneType' object does not support item assignment
Code: Select all
$ persistent._clear(progress=True)
Code: Select all
self.enc_dict[self.tag_string + str(x)] = self.enc.all_entries[x][1].status
Code: Select all
init:
whatsabout = "Yes"
kimassen= "Hopefully"
encyguide = Encyclopaedia(showLockedButtons=True, showLockedEntry=False)
encyguide.setPersistentStatus(entries_total=2, master_key="new", name="new")
encyguide.addSubjects("Tutorial")
gd1 = EncEntry(1,"Medicine",whatabout, "Tutorial", status=persistent.new_dict["new_00"], locked=False)
gd2 = EncEntry(2,"Voodoo",whatstime, "Tutorial", status=persistent.new_dict["new_01"],locked=False)
encyguide.addEntries(gd1,gd2)
Code: Select all
Show("encyclopaedia_entry")] )
Code: Select all
Show("extra_encyclopaedia_entry")] )
Code: Select all
init -1 python:
#Function that creates the buttons for each entry.
#It makes one button, based on the value "x", associated to the given encyclopaedia "enc".
#Used in a "for loop" on a screen to generate the correct buttons for every entry
def ExtragenerateEntryButton(x,enc):
ui.hbox()
if enc.showLockedButtons:
if enc.all_entries[x][1].locked == False: #If the entry is unlocked, make the button to go to it. If it's locked, make an inactive "???" button
if enc.all_entries[x][1].status == None or enc.all_entries[x][1].status == False:
ui.textbutton ("{color=#ff0}New!{/color}", xsize=60, color="#f0f", size=16)
else:
ui.null(width=60)
ui.textbutton(enc.all_entries[x][1].name, clicked= [ enc.ChangeStatus(x), enc.SetEntry(x), Show("extra_encyclopaedia_entry")] )
else: #If locked entries should be shown in the list, the "???" button should go to the entry. If not, it's an inactive button
if enc.showLockedEntry:
ui.null(width=60)
ui.textbutton("{color=#666}???{/color}", clicked=[ enc.ChangeStatus(x), enc.SetEntry(x), Show("extra_encyclopaedia_entry")])
else:
ui.null(width=60)
ui.textbutton("{color=#666}???{/color}")
if enc.showLockedButtons == False: #Only showing unlocked entries in this case, no need for the "???" button
ui.textbutton(enc.unlocked_entries[x][1].name, clicked= [ enc.ChangeStatus(x), enc.SetEntry(x), Show("extra_encyclopaedia_entry")] )
if enc.unlocked_entries[x][1].status == None or enc.unlocked_entries[x][1].status == False:
ui.textbutton ("New!")
ui.close()
Code: Select all
screen extra_encyclopaedia_list:
tag menu
use game_menu(_("Guides"), scroll="viewport"):
vbox:
spacing 10
frame:
style_prefix "guide"
xmargin 10
yfill True
xmaximum 400
bottom_margin 10
vbox: #viewport:
#scrollbars "vertical"
#mousewheel True
#draggable True
vbox:
python:
for x in range(len(encyguide.subjects) ):
ui.text(encyguide.subjects[x])
for y in range(encyguide.entry_list_size):
if encyguide.getEntry(y).subject == encyguide.subjects[x]:
ExtragenerateEntryButton(y,encyguide) ### <-notice this!
ui.null(height=16)
######################
### ENC. single entry ##################################################################
# ================== #
######################
screen extra_encyclopaedia_entry():
tag menu
use game_menu(_("Guides"), scroll="viewport"):
vbox:
spacing 10
frame:
id "entry_nav"
style_prefix "guidenavi"
xfill True
hbox:
xfill True
textbutton "Previous Entry" xalign .02 action encyguide.PreviousEntry() #Relative to the sorting mode
$page_indicator = encyguide.getEntryData()[1].getName() # Flavour text to indicate which page we're current on
text page_indicator size 36 color "#c00"
textbutton "Next Entry" xalign .98 action encyguide.NextEntry() #Relative to the sorting mode
hbox:
$ddd = config.screen_width
$dd = config.screen_width/2
$pp = config.screen_height/2
if encyguide.getEntryData()[1].hasImage: #If the entry or sub-entry has an image, add it to the screen
frame:
xmargin 10
yfill True
xfill True
xmaximum dd
ymaximum pp
$current_image = encyguide.getEntryData()[1].getImage()
add current_image crop (0,10,dd-30,pp-10)
window:
id "entry_window"
xmargin 10
xfill True
yfill True
xalign 0.5
xmaximum ddd
ymaximum pp
background None
vbox:
spacing 15
for item in encyguide.entry_text: #entry_text is a list of paragraphs from what whatever the current entry is
text item
frame:
style_group "mm_root"
xfill True
yfill False
xmargin 10
hbox:
xfill True
if encyguide.getEntryData()[1].hasSubEntry: #If there's a sub-entry, add Prev/Next Page buttons
textbutton "Previous Page" xalign .02 action encyguide.PreviousPage()
text "Page %d / %d" % (encyguide.sub_current_position, encyguide.getEntryData()[1].pages) #Flavour text to indicate which sub-page is being viewed
textbutton "Next Page" xalign .98 action encyguide.NextPage()
else:
text("")
hbox:
xfill True
yalign .98
textbutton "Close Entry" id "close_entry_button" xalign .5 clicked [encyguide.ResetSubPage(), Show("extra_encyclopaedia_list")] #<---notice this
daikiraikimi wrote:My friend told me I might need to import EncyclopaediaActions in the code where I define my items and I got it working! Here is the code for anyone else who wants to implement something like this!
Code: Select all
$ herbID1 = Item("Herb Identification vol. 1", "A book of herbs", "inv/book.png", 5000, act=[enc_code.actions.UnlockEncEntry(en1),Show("inventory_popup", message="New Herbs Unlocked"), SetVariable('time_cnt',time_cnt+1), Function(renpy.call, "time_img")])
Code: Select all
File "enc_code/actions.py", line 33, in __call__
ValueError: EncEntry: 02: Herb Identification vol. 2 is not in list