If we can complete this, I think it'd make a worthy addition to the cookbook.
Code: Select all
#this formula will create a statistics menu on the left and a command menu on the right. It is suitable for classic location-based adventure games (with move and use commands, etc.) or for training sims. The statistics will be numerical instead of a bar under this formula.
#For the sake of argument, you could call these stats HP, MP, etc.
$ stat1 = 0
$ stat2 = 0
$ stat3 = 0
Python:
#first window
#forces size of frame to not exceed stated pixel width.
#Also sets the initial coordinate anchor point for all items to 10 pixels in from the edge.
#Bet you didn't know it could be used like that, huh?
ui.sizer(xpos=10, ypos=10, maxwidth=200)
ui.frame(xpos=0,
ypos=0,
xanchor='left',
yanchor='top',
xfill=True)
ui.vbox(xpos=0,
xanchor='left')
ui.text("Stats") #used for category
ui.text("statname: %(stat1)d" % globals())
ui.text("statname: %(stat2)d" % globals())
ui.text("statname: %(stat3)d" % globals())
ui.close()
#second window
#setting up this one is what made using the x and y pos arguments necessary.
#I kept getting text without a box while the max width was set to 200,
#because it was limiting where the box was capable of being displayed at x200.
ui.sizer(xpos=590, ypos=10, maxwidth=200)
ui.frame(xpos=0,
ypos=0,
xanchor='left',
yanchor='top',
xfill=True)
ui.vbox(xpos=0,
xanchor='left')
#these create menu buttons within the box. They should appear in descending order on the right side of the screen.
ui.textbutton("Option 1", clicked=ui.returns(1))
ui.textbutton("Option 2", clicked=ui.returns(2))
ui.textbutton("Option 3", clicked=ui.returns(3))
ui.close()
#not certain, but I think you can call this "result" variable whatever you want
result = ui.interact()
if result == 1:
#commands go here. submenus, jumps, speech, whatever
if result == 2:
if result == 3:
In any case, if you were to use this script in an adventure game, you'd want to set it up individually for each location so you can set up north, south, east, west commands more easily.
Well, that's enough talk on it. Solutions for the minor flaw are greatly appreciated, as is abject praise. =P


