Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
computer Namespace Reference

Functions

def runBountyMenu
 
def runComputer
 

Function Documentation

def computer.runBountyMenu (   cp = -1)

Definition at line 5 of file computer.py.

References dialog_box.button_row(), pydoc.callback, dialog_box.dialog(), dialog_box.fromValues(), server.getDirector(), sre_parse.max, server_lib.placeBounty(), custom.respond(), and locale.str().

5 
6 def runBountyMenu(cp=-1):
7  if cp==-1:
8  cp=VS.getCurrentPlayer()
9  un = VS.getPlayerX(cp)
10  id=None
11 
12  def callback(dialog,result):
13  print 'id is: ',id
14  action,inputs = dialog_box.fromValues(result)
15  if action=='Cancel':
16  dialog.undraw()
17  custom.respond(['close'],None,id)
18  return False
19  if action=='OK':
20  dialog.undraw()
21  custom.respond(['close'],None,id)
22 
23  callsign = inputs['logged_in_users']
24  if callsign=='' or callsign=='OR, Type in a user:':
25  callsign = inputs['callsign']
26 
27  print 'I would now place a bounty on '+str(callsign)+' for '+str(float(inputs['credits']))+' credits.'
28  print 'User value IS: '+str(inputs['logged_in_users'])
29  server_lib.placeBounty(callsign,float(inputs['credits']))
30  return False
31  return True
32 
33  items=['width', 1.5,
34  'text', "Place a bounty on someone's head",
35 ]
36  items+=['height',0.05,
37  'row',
38  'textwidth','Credits:',0.3,
39  'textinput','credits',('%g'%max(1000.,un.getCredits()/100.)),
40  'endrow',
41  'height',0.05]
42  if VS.isserver():
43  import server
44  logged_in_users=server.getDirector().getCallsignList()
45  logged_in_users.append('OR, Type in a user:')
46  items+=['text','Select a player in this system:',
47  'list','logged_in_users',len(logged_in_users)]+logged_in_users
48  items+=['row',
49  'textwidth','Other Player:',0.3,
50  'textinput','callsign','',
51  'endrow']
52  else:
53  items+=['list','logged_in_users',15,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o']
54  items += dialog_box.button_row(1.5,'OK','Cancel')
55  id = dialog_box.dialog(items,callback)
56 
def computer.runComputer (   local,
  cmd,
  args,
  id,
  cp = -1 
)

Definition at line 57 of file computer.py.

References custom.add(), pydoc.callback, dialog_box.dialog(), dialog_box.fromValues(), custom.respond(), and runBountyMenu().

57 
58 def runComputer(local,cmd,args,id,cp=-1):
59  #def a():
60  # print "A() called"
61  # def b(result):
62  # print result
63  # if not result:
64  # result='NOT'
65  # def c(result):
66  # dialog_box.alert(result)
67  # dialog_box.confirm("Test message 2 "+str(result),c)
68  # dialog_box.confirm("Test message",b,buttons=('A','B','C','D','E',"F",'G','H','I','J'))
69  #dialog_box.alert("TEST\nALERT\nBox",callback=a)
70 
71  def callback(dialog,result):
72  print 'id is: ',id
73  action,inputs = dialog_box.fromValues(result)
74  if action=='Test':
75  print 'test clicked!!!!'
76  if action=='Bounty Hunt':
77  print 'hunting bounty'
78  runBountyMenu(cp)
79  if action=='OK' or action=="Exit Menu" or action=="Cancel":
80  dialog.undraw()
81  custom.respond(['close'],None,id)
82  return False
83  return True
84 
85  items=['width', 1.0,
86  'text', 'Public Computer Menu',
87  'space', 0., .1,
88  'button', 'Test',
89  'button', 'View Score',
90  'button', 'Bounty Hunt',
91  'button', 'Exit Menu']
92  id = dialog_box.dialog(items,callback)
93  print 'id is set to: ',id
94 
95 custom.add("computer",runComputer)
96