I built this specially cater to my own writing style. so you might not write like this at all.
I REALLY HATE after i wrote the story, i have to go and edit line by like so renpy can recognize.
This is how i usually write story in renpy:
Code: Select all
label start:
you walked into the tavern. It is full of people
if gold >= 50:
"Hey, do you have a nice room?"
elif gold < 50:
"Hey, do you have cheap room?"
The barmaiden behind the counter looked at you impatiently. "Sorry, we are full today." Somebody already asking her where is their drinks.
You sigh, what to do now?
menu:
"order a drink.":
you sat down and order a drink. "Hey! i need a pint of beer!"
jump sat_and_drink
"Leave the tavern.":
you left the tavern.
jump leave_tavern
label sat_and_drink:
the drink is actually good.
label leave_taverb:
it was a cold night outside.
Code: Select all
label start:
"you walked into the tavern. It is full of people"
if gold >= 50:
"\"Hey, do you have a nice room?\""
elif gold < 50:
"\"Hey, do you have cheap room?\""
"{color = [tcw]}The barmaiden behind the counter looked at you impatiently. {/color}\"Sorry, we are full today.\"{color = [tcw]} Somebody already asking her where is their drinks.{/color}"
"You sigh, what to do now?"
menu:
"order a drink.":
"{color = [tcw]}you sat down and order a drink. {/color}\"Hey! i need a pint of beer!\""
jump sat_and_drink
"Leave the tavern.":
"you left the tavern."
jump leave_tavern
label sat_and_drink:
"the drink is actually good."
label leave_taverb:
"it was a cold night outside."
I need the {color} thing because my character will speak in a color, but the action must be white.
so i made {color = [tcw]} and i put tcw = "#FFFFFF" as text color white
and i have to change the " into \" so renpy can recognize i really need a " in the text
and i need to add a " at the opening and ending of the whole text
so last year i took a few days to build this code/program to help me automatically do all these.
it works nice
but recently i got frustrated again.
If i meet something like "if", "menu", "label", "scene", these "renpy lines", i need to skip them
so i took a few days to get back into the code to ignore all these lines.
now i can just enjoy writing stories and can almost ignore the menial and repetative job! it took a huge burden from me!
So i just want to share this baby to you
How to use this code:
there should be a problem with the "menu"python executor method:
I am using the commandprompt, if you use others, should be the same. i have no idea
copy the below code, paste into notepad or sublime, name it with a .py ending
run the python executor to run this .py file, you will see "write in story"
copy paste ALL of your text wall from renpy, and paste it below "write in story"
enter a new line, and type in "enter"
voila, magic
online python executor method:
i used rep.it, if you have others, should be the same thing, if not, just google "rep.it python 3"
copy the below code, and paste into the middle box, replace the codes you see.
click run
you will see "write in story" at the right box
copy paste ALL of your text wall from renpy, and paste it below "write in story"
below your text, enter a new line, and type in "enter"
voila, magic
after the "menu" in your renpy text, the next line is usually the choice, but sometimes i will put in a a line of text as question before the choice. the program will add " at both sides and change the original " into \", so you have to go check and mannual correct this line if you dont want renpy to show extra " in the game.
if you find any other bugs, please let me know
Enjoy!
Code: Select all
#FUTURE PLANS
#1. MAKE THE PROGRAM IGNORE EXISTING {COLOR = [TCW]} AND {/COLOR}
#2. MAKE THE PROGRAM IGNORE EXISTING \"
#3. MAKE THE PROGRAM REGOCNIZE THE "MENU" , AND WILL NOT ADD THE \" FOR THE ELEMENT/TEXT IN THE NEXT LINE
#4. MAKE THE PROGRAM IGNORE THE NAMES IN FRONT OF SENTENCES
#IF THESE 3 DONE, SHPOLD BE ABLE TO JUST HIGHLIGHT THE WHOLE PAGE AND RUN THE WHOLE PROGRAM
while True:
print("write in story:")
MultiLine = []
while True:
line = input()
if line == 'enter':
print()
break
elif line == '':
MultiLine.append('')
elif line:
MultiLine.append(line)
paragraph = '\n'.join(MultiLine)
import re
sep_para1 = re.split('(\n)',paragraph)
sep_para1 = ''.join(sep_para1)
sep_para2 = [re.split('(".*?")', x) for x in re.split('\n', sep_para1)]
nested_list_location_for_change = 0
nested_list_need_to_add_space = False
nested_list_spaces_to_add = ""
element_to_changed = ""
changed_element = ""
for nested_list in sep_para2:
changed_element = nested_list[0]
for element in nested_list:
space_match_object = re.search('^\s*', element)
space_match_object_string = str(space_match_object)
if space_match_object_string != "<re.Match object; span=(0, 0), match=''>" and space_match_object_string != "<re.Match object; span=(0, 1), match=' '>":
nested_list_need_to_add_space = True
nested_list_spaces_to_add = re.search('^\s*', element).group(0)
element_to_changed = element
changed_element = element.lstrip()
nested_list.insert(0, nested_list_spaces_to_add)
nested_list[1] = changed_element
acc7 = 0
for x in sep_para2:
for y in sep_para2[acc7]:
if sep_para2[acc7][0] == '':
sep_para2[acc7].pop(0)
acc7 += 1
acc8 = 0
for x in sep_para2:
for y in sep_para2[acc8]:
if sep_para2[acc8][-1] == '':
sep_para2[acc8].pop(-1)
acc8 += 1
for nested_list in sep_para2:
if '' in nested_list:
nested_list.remove('')
var = [(index1,index2) for index1,value1 in enumerate(sep_para2) for index2,value2 in enumerate(value1) if '"' not in value2]
acc11 = 0
pre_i = 0
now_i = 0
for i,j in var:
now_i = i
if now_i > pre_i:
acc11 = 0
sep_para2[i].insert(j+acc11, '{color = [tcw]}')
acc11 += 1
pre_i = i
for nested_list in sep_para2:
if nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ' or nested_list[1] == ' ':
del nested_list[0]
var2 = [(index1,index2) for index1,value1 in enumerate(sep_para2) for index2,value2 in enumerate(value1) if '"' not in value2 and 'tcw' not in value2]
var2_2 = [(x,y+1) for x,y in var2]
acc12 = 0
pre_i2 = 0
now_i2 = 0
for i,j in var2_2:
now_i2 = i
if now_i2 > pre_i2:
acc12 = 0
sep_para2[i].insert(j+acc12, '{/color}')
acc12 += 1
pre_i2 = i
for nested_list in sep_para2:
if nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ' or nested_list[0] == ' ':
del nested_list[1]
#now only up to 10 four spaces
#joining the nested list, so now we only have a list of sentences
sep_para3 = [''.join(sentences) for sentences in sep_para2]
#deleting the extra "{color = [tcw]}" and "{color}" thing from sentences that don't have ""
a, b, c = '{color = [tcw]}', '', '{/color}'
for i, v in enumerate(sep_para3):
if '"' not in v:
sep_para3[i] = v.replace(a, b)
for i, v in enumerate(sep_para3):
if '"' not in v:
sep_para3[i] = v.replace(c, b)
for i, v in enumerate(sep_para3):
if "==" in v:
sep_para3[i] = v.replace(a, b)
for i, v in enumerate(sep_para3):
if "==" in v:
sep_para3[i] = v.replace(c, b)
for i, v in enumerate(sep_para3):
if "!=" in v:
sep_para3[i] = v.replace(a, b)
for i, v in enumerate(sep_para3):
if "!=" in v:
sep_para3[i] = v.replace(c, b)
for i, v in enumerate(sep_para3):
if v.endswith(':{/color}'):
sep_para3[i] = v.replace(a, b)
for i, v in enumerate(sep_para3):
if v.endswith(':{/color}'):
sep_para3[i] = v.replace(c, b)
# print("adding the strokes")
for index, x in enumerate(sep_para3):
special_character_end = False
if x.endswith(':'):
special_character_end = True
if '==' not in x and '!=' not in x and special_character_end == False:
sep_para3[index] = x.replace('"','\\"')
sep_para4 = sep_para3
# NEED TO MAKE ALL THE ELEMENT INTO ANOTHER LIST, THEN CHANGE THEM WITHIN THE LIST
sep_para4_4 = []
nted_list = []
for element in sep_para4:
nted_list= [element]
sep_para4_4.append(nted_list)
nested_list_location_for_change = 0
nested_list_need_to_add_space = False
nested_list_spaces_to_add = ""
element_to_changed = ""
changed_element = ""
for nested_list in sep_para4_4:
changed_element = nested_list[0]
for element in nested_list:
space_match_object = re.search('^\s*', element)
space_match_object_string = str(space_match_object)
if space_match_object_string != "<re.Match object; span=(0, 0), match=''>" and space_match_object_string != "<re.Match object; span=(0, 1), match=' '>":
nested_list_need_to_add_space = True
nested_list_spaces_to_add = re.search('^\s*', element).group(0)
element_to_changed = element
changed_element = element.strip()
nested_list.insert(0, nested_list_spaces_to_add)
nested_list[1] = changed_element
list_of_quotation_index_to_be_deleted = []
#NEED TO DELETE EXTRA '' that will be added when nothing can add
for nested_list_index, nested_list in enumerate(sep_para4_4):
for element_index, element in enumerate(nested_list):
if element == '':
index_to_be_deleted = [nested_list_index,element_index]
list_of_quotation_index_to_be_deleted.append(index_to_be_deleted)
for nested_list in list_of_quotation_index_to_be_deleted:
del sep_para4_4[nested_list[0]][nested_list[1]]
for nested_list in sep_para4_4:
for i, v in enumerate(nested_list):
if v.startswith('{color = [tcw]}#'):
nested_list[i] = v.replace(a, b)
for i, v in enumerate(nested_list):
if v.startswith('#'):
nested_list[i] = v.replace(c, b)
for nested_list in sep_para4_4:
for i, v in enumerate(nested_list):
if v.startswith('{color = [tcw]}$'):
nested_list[i] = v.replace(a, b)
for i, v in enumerate(nested_list):
if v.startswith('$'):
nested_list[i] = v.replace(c, b)
#adding the ""
list_to_change_sep_para4_4 = []
for nested_list_index, nested_list in enumerate(sep_para4_4):
special_character_start = False
for elemnt_index,element in enumerate(nested_list):
if element.startswith('menu'):
special_character_start = True
if element.startswith('label'):
special_character_start = True
if element.startswith('if'):
special_character_start = True
if element.startswith('call'):
special_character_start = True
if element.startswith('scene'):
special_character_start = True
if element.startswith('show'):
special_character_start = True
if element.startswith('hide'):
special_character_start = True
if element.endswith(':'):
special_character_start = True
if element.startswith('#'):
special_character_start = True
if element.startswith('$'):
special_character_start = True
if element.startswith('jump'):
special_character_start = True
if ' ' not in element and '==' not in element and '!=' not in element and special_character_start == False:
changed_element = '"' + element + '"'
index_to_change = elemnt_index
list_to_chage = [nested_list_index, index_to_change, changed_element]
list_to_change_sep_para4_4.append(list_to_chage)
#using index to find and change the element that need to add the ""
for nested_list in list_to_change_sep_para4_4:
sep_para4_4[nested_list[0]][nested_list[1]] = nested_list[2]
#Findout the \" in the list to delete it if starts wth $
list_to_change_sep_para4_4 = []
for nested_list_index, nested_list in enumerate(sep_para4_4):
special_character_start = False
for elemnt_index,element in enumerate(nested_list):
if element.startswith('$'):
changed_element = element.replace('\\"', '"')
index_to_change = elemnt_index
list_to_chage = [nested_list_index, index_to_change, changed_element]
list_to_change_sep_para4_4.append(list_to_chage)
for nested_list in list_to_change_sep_para4_4:
sep_para4_4[nested_list[0]][nested_list[1]] = nested_list[2]
#deleting the extra spaces in front of lines that starts with 'label'
list_to_change_sep_para4_4 = []
for nested_list_index, nested_list in enumerate(sep_para4_4):
special_character_start = False
for elemnt_index,element in enumerate(nested_list):
if element.startswith('label'):
index_to_change = elemnt_index-1
nested_list_index = nested_list_index
list_to_chage = [nested_list_index, index_to_change]
list_to_change_sep_para4_4.append(list_to_chage)
list_to_delete_listtochange = []
for index_of_nested_list, nested_list in enumerate(list_to_change_sep_para4_4):
if -1 in nested_list:
list_to_delete_listtochange.append(index_of_nested_list)
for element in list_to_delete_listtochange:
list_to_change_sep_para4_4.pop(element)
for nested_list in list_to_change_sep_para4_4:
del sep_para4_4[nested_list[0]][nested_list[1]]
sep_para4_5 = [''.join(sentences) for sentences in sep_para4_4]
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
print() #just an empty line to separate last run
for element in sep_para4_5:
print(element)
print()
print() #just an empty line to separate new run
print() #just an empty line to separate new run