Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit be4568a

Browse files
committed
lots of fixes
1 parent a6317ce commit be4568a

File tree

1 file changed

+109
-60
lines changed

1 file changed

+109
-60
lines changed

VAIIYA terminal.py

Lines changed: 109 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -127,40 +127,26 @@ def message_of_the_day(): #or per boot
127127
MOTD = random.randint(1,6)
128128

129129
if MOTD == 1:
130-
with open("assets/text_lines/MOTD/MOTD_1.txt") as f: # The with keyword automatically closes the file when you are done
131-
print(f.read())
132-
f.close()
130+
game.printfile("assets/text_lines/MOTD/MOTD_1.txt")
133131

134132
elif MOTD == 2:
135-
with open("assets/text_lines/MOTD/MOTD_2.txt") as f: # The with keyword automatically closes the file when you are done
136-
print(f.read())
137-
f.close()
133+
game.printfile("assets/text_lines/MOTD/MOTD_2.txt")
138134

139135
elif MOTD == 3:
140-
with open("assets/text_lines/MOTD/MOTD_3.txt") as f: # The with keyword automatically closes the file when you are done
141-
print(f.read())
142-
f.close()
136+
game.printfile("assets/text_lines/MOTD/MOTD_3.txt")
143137

144138
elif MOTD == 4:
145-
with open("assets/text_lines/MOTD/MOTD_4.txt") as f: # The with keyword automatically closes the file when you are done
146-
print(f.read())
147-
f.close()
139+
game.printfile("assets/text_lines/MOTD/MOTD_4.txt")
148140

149141
elif MOTD == 5:
150-
with open("assets/text_lines/MOTD/MOTD_5.txt") as f: # The with keyword automatically closes the file when you are done
151-
print(f.read())
152-
f.close()
142+
game.printfile("assets/text_lines/MOTD/MOTD_5.txt")
153143

154144
#remove this MOTD on the next update PAST christmas, maybe new years or when the snow melts.
155145
elif MOTD == 6:
156-
with open("assets/text_lines/MOTD/MOTD_xmas.txt") as f: # The with keyword automatically closes the file when you are done
157-
print(f.read())
158-
f.close()
146+
game.printfile("assets/text_lines/MOTD/MOTD_6.txt")
159147

160-
elif MOTD == 7:
161-
with open("assets/text_lines/MOTD/MOTD_6.txt") as f: # The with keyword automatically closes the file when you are done
162-
print(f.read())
163-
f.close()
148+
# elif MOTD == 7:
149+
# game.printfile("")
164150

165151
def timefetch():
166152
#time fetch for login
@@ -177,7 +163,8 @@ def timefetch():
177163
def terminal_start_message():
178164
print(" for a list of commands, please type 'commands' ")
179165
print("""|""")
180-
166+
167+
181168
#TERMINAL BEHAVIOR NOTES! make sure to use `elif` instead of `if`. this will prevent the error string from printing if we return from the EEs or logins.
182169
#ANOTHER NOTE: exit() AND quit() COUNT AS DEBUGGING, SO A TRACKBACK WILL CALL. USE `raise SystemExit` FROM NOW ON!
183170
#
@@ -199,9 +186,7 @@ def open_terminal():
199186

200187
#the credits for the game!
201188
elif text == 'credits':
202-
with open("assets/text_lines/commands_lines/line_credits.txt") as f: # The with keyword automatically closes the file when you are done
203-
print(f.read())
204-
f.close()
189+
game.printfile("assets/text_lines/commands_lines/line_credits.txt")
205190

206191
elif text == 'version':
207192
print("|")
@@ -250,9 +235,7 @@ def open_terminal():
250235

251236
#the COMMANDS directory, DO NOT REMOVE!
252237
elif text == 'commands':
253-
with open("assets/text_lines/commands_lines/line_commands.txt") as f: # The with keyword automatically closes the file when you are done
254-
print(f.read())
255-
f.close()
238+
game.printfile("assets/text_lines/commands_lines/line_commands.txt")
256239

257240

258241
#this solves the space command issue. leave blank
@@ -267,14 +250,13 @@ def open_terminal():
267250

268251
#error response
269252
else:
270-
print("VAIIYA Engine did not detect that as a valid command.")
271-
print("please check spelling, spaces, or other. or use 'commands'")
253+
game_errs.Vengine_nocmd_found()
272254

273255
# PLEASE PUT ALL 2ND DEF(S) BELOW THIS NOTE!
274256

275257
#MAKE SURE THIS IS DISABLED BEFORE RELEASE!!!
276258
def DEBUG_COMMANDLINE():
277-
if DEBUG_ENABLE() == True:
259+
if DEVsettings.DEBUG_ENABLE() == True:
278260

279261
while True:
280262
text = prompt('DEBUG COMMANDLINE >>> ')
@@ -300,8 +282,8 @@ def DEBUG_COMMANDLINE():
300282

301283
else:
302284
print("use COMMANDS if you forgot")
303-
if DEBUG_ENABLE() == False:
304-
print("hahaha good try ( ̄y▽, ̄)╭ ")
285+
if DEVsettings.DEBUG_ENABLE() == False:
286+
game_errs.debug_disabled()
305287

306288

307289

@@ -328,7 +310,7 @@ def CNS_EE_HAKED():
328310
time.sleep(1)
329311
print("1")
330312
time.sleep(1)
331-
raise SystemExit
313+
game.quit()
332314
#if the `result` has a bool of False, then it will run this part of code. and again will return to menu and exit the program.
333315
if result == False:
334316
message_dialog(
@@ -344,7 +326,7 @@ def CNS_EE_HAKED():
344326
time.sleep(1)
345327
print("1")
346328
time.sleep(1)
347-
raise SystemExit
329+
game.quit()
348330
#the idea above from smashel!
349331

350332

@@ -584,48 +566,115 @@ def VRRALSA_COMMAND_PANEL():
584566
print(f.read())
585567
f.close()
586568

587-
588-
589569
elif VRRALSA_TEXT == 'exit':
590570
return
591571

592572
else:
593573
print("|")
594574
print("V.R.C.L. ERROR; KEYWORD DOES NOT LINK TO RECORD OR LOG. CHECK SPELLING, CAPS, OR OTHER.")
595575
#END OF THE VRCL COMMAND SYSTEM
576+
class game:
577+
#the game class is for very often used tasks (eg the file printer)
578+
579+
#make sure that the filepath is an actual filepath with "" otherwise it WILL break
580+
def printfile(txtfilepath = ""):
581+
try:
582+
with open(txtfilepath) as f: # The with keyword automatically closes the file when you are done
583+
print(f.read())
584+
except FileNotFoundError():
585+
print_formatted_text(HTML('<red>ERR! FILEPRINT FAILURE</red>'))
586+
587+
#the game.quit() event is to make the rase systemexit look a bit better :3
588+
def quit():
589+
raise SystemExit
590+
591+
592+
593+
# setting are ova here dude
594+
class DEVsettings:
596595

597596
#BELOW IS THE DEBUG COMMANDLINE ENABLE, SET TO TRUE FOR IT TO WORK. FALSE FOR RELEASE
598-
def DEBUG_ENABLE():
599-
return True
597+
def DEBUG_ENABLE():
598+
return True #set to TRUE to enable the debug commandline
599+
600+
def DEBUG_STARTUP_DISABLE():
601+
return True #set to TRUE to disable the startup part of VT
600602

601-
def DEBUG_STARTUP_DISABLE():
602-
return True
603+
def STARTUP_DEBUG_CHECK():
604+
if DEVsettings.DEBUG_STARTUP_DISABLE() == False:
605+
startup_screen_ascii_roll()
606+
startup_shortcuts.loading_bars_combined_startup()
607+
608+
if DEVsettings.DEBUG_STARTUP_DISABLE() == True:
609+
pass
610+
611+
612+
class DEVtools:
603613

604-
def STARTUP_DEBUG_CHECK():
605-
if DEBUG_STARTUP_DISABLE() == False:
606-
startup_screen_ascii_roll()
607-
loading_bars_combined_startup()
614+
def debug_enabled_reminder():
615+
# a simple reminders system that the debug system is turned on
616+
if DEVsettings.DEBUG_ENABLE() == True:
617+
print_formatted_text(HTML('<red>THE DEBUG COMMANDLINE IS ENABLED!!</red>'))
608618

609-
if DEBUG_STARTUP_DISABLE() == True:
610-
pass
619+
if DEVsettings.DEBUG_ENABLE() == False:
620+
pass
621+
622+
if DEVsettings.DEBUG_STARTUP_DISABLE() == False:
623+
pass
624+
625+
if DEVsettings.DEBUG_STARTUP_DISABLE() == True:
626+
print_formatted_text(HTML('<red>THE STARTUP IS DISABLED!!</red>'))
627+
628+
629+
class startup_shortcuts:
630+
def terminal_startup_combined():
631+
main_menu()
632+
message_of_the_day()
633+
timefetch()
634+
terminal_start_message()
635+
DEVtools.debug_enabled_reminder()
636+
open_terminal()
637+
638+
def loading_bars_combined_startup():
639+
loading_bars_intro_1()
640+
loading_bars_intro_2()
641+
loading_bars_intro_3()
642+
643+
class game_errs:
611644

645+
def Vengine_nocmd_found():
646+
print("VAIIYA Engine did not detect that as a valid command.")
647+
print("please check spelling, spaces, or other. or use 'commands'")
612648

613-
def terminal_startup_combined():
614-
main_menu()
615-
message_of_the_day()
616-
timefetch()
617-
terminal_start_message()
618-
open_terminal()
649+
def debug_disabled():
650+
print("VAIIYA Engine did not detect a VAIIYA granted systems card.")
651+
print("If you are a VAIIYA employee, please contact your district supervisor for more info.")
652+
653+
654+
655+
656+
# BELOW THIS NOTE IS ONLY RAISE ERRORS!!! DO NOT REMOVE ANY OF THIS!!!!!
657+
class this_broke:
658+
pass
659+
# this class is for errors outside of normal use, like the file printer not finding the file
660+
661+
# class fileprintfail(FileNotFoundError):
662+
# # this error is used to be user friendly, and debug friendly. while also giving it a keen eye
663+
# def __init__(self, *args):
664+
# super().__init__(*args)
665+
666+
# try:
667+
# raise fileprintfail
668+
# except fileprintfail as e:
669+
# print_formatted_text(HTML('<red>ERR! FILEPRINT FAILURE</red>', e.strerror ))
670+
671+
619672

620-
def loading_bars_combined_startup():
621-
loading_bars_intro_1()
622-
loading_bars_intro_2()
623-
loading_bars_intro_3()
624673

625674
# Main system loop
626675
def game_loop():
627-
STARTUP_DEBUG_CHECK()
628-
terminal_startup_combined()
676+
DEVsettings.STARTUP_DEBUG_CHECK()
677+
startup_shortcuts.terminal_startup_combined()
629678

630679
while True:
631680
#there is no code to run right before startup so there is a `pass` here.

0 commit comments

Comments
 (0)