Commits

Pierre Surply committed eb1962d

Fix help command

  • Participants
  • Parent commits 7c40d62

Comments (0)

Files changed (6)

 BASIC-RoBots depends on Python2, PyGame and PyOpenGL.
 
 For Debian/Ubuntu Linux:
+
     $ sudo apt-get install python2.6 python-pygame python-opengl
     $ cd /path/to/basic-robots/
     $ make

File src/robot/mothership.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ##
 ## Started on  Sun Jul  1 16:42:11 2012 Pierre Surply
-## Last update Wed Aug  1 18:00:07 2012 Pierre Surply
+## Last update Wed Sep  5 17:01:13 2012 Pierre Surply
 ##
 
 import os
         robot.Robot.__init__(self, new, world, name, env, (x, y), events)
         self.id_sprite = 0
         self.ext_cmd["build"] = (self.build,\
-                                     "Build a robot",\
+                                     "Builds a robot",\
                                      "1 if the robot can be created, 0 otherwise",\
                                      (2, []),\
                                      {"A" : "robot id"})
         self.ext_cmd["robots"] = (self.robots,\
-                                      "List available robots",\
+                                      "Lists available robots",\
                                       "Always returns 0",\
                                       (0, []),\
                                       {})
             r = self.id2robot(id_robot)
             if r != None:
                 r.move_to((x, y))
+                r.real_pos_x = float(x)
+                r.real_pos_y = float(y)
                 self.env.robots.append(r)
                 self.os.terminal.info.write_info(r.name + " built in (" + str(x) + ", " + str(y) + ")", 7)
                 return 1

File src/robot/robot.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Sun Jul  1 15:34:10 2012 Pierre Surply
-## Last update Wed Sep  5 12:28:50 2012 Pierre Surply
+## Last update Wed Sep  5 17:01:02 2012 Pierre Surply
 ##
 
 import os
 import pathfinding
 
 class Robot:
-    items = [(0, "Wood", [0, 1, 2, 3, 4])]
+    items = [(0, "Tree", [0, 1, 2, 3, 4])]
     def __init__(self, new, world, name, env, (x, y), events):
         self.env = env
         self.pos_x = x
         self.mem_stack = []
         self.msg_recv = deque([])
         self.ext_cmd = {"forward" : (self.forward, \
-                                         "Move the robot forward", \
+                                         "Moves the robot forward", \
                                          "1 if the robot can move, 0 otherwise",\
                                          (0, []),\
                                          {}),\
                             "rotleft": (self.rot_left, \
-                                            "Rotate the robot counterclockwise",\
+                                            "Rotates the robot counterclockwise",\
                                             "Always returns 0", \
                                             (0, []),\
                                             {}),\
                             "rotright": (self.rot_right, \
-                                             "Rotate the robot clockwise",\
+                                             "Rotates the robot clockwise",\
                                              "Always returns 0", \
                                              (0, []),\
                                              {}),\
                             "give": (self.give, \
-                                         "Give an item from inventory to other robot",\
+                                         "Gives an item from inventory to other robot",\
                                          "1 if the item is given, 0 otherwise",\
                                          (0, []),\
                                          {"A" : "item id"}),\
                             "sendmsg": (self.sendmsg, \
-                                         "Send a message (1 byte) to all robots in a small area",\
+                                         "Sends a message (1 byte) to all robots in a small area",\
                                          "Number of robots which received the message",\
                                          (0, []),\
                                          {"A" : "message"}),\
                             "recvmsg": (self.recvmsg, \
-                                            "Read a message sent by other robot",\
+                                            "Reads a message sent by other robot",\
                                             "Content of the message if received, 0 otherwise ",\
                                             (0, []),\
                                             {}), \
                             "findpath": (self.findpath, \
-                                             "",\
-                                             "",\
+                                             "Finds the path (using A* algorithm) to given coordinates and put it in the stack",\
+                                             "1 if the path can be found, 0 otherwise",\
                                              (0, []),\
-                                             {}), \
+                                             {"A" : "X coordinate", \
+                                                  "B" : "Y coordinate"}), \
                             "finditem": (self.radar_item, \
-                                             "",\
-                                             "",\
+                                             "Searches coordinates of a given item and put it in the stack (Y first)",\
+                                             "1 if the item is found, 0 otherwise",\
                                              (0, []),\
-                                             {}), \
+                                             {"A" : "item id"}), \
                             "items": (self.ls_items, \
-                                             "",\
-                                             "",\
+                                             "Lists searchable items",\
+                                             "Always returns 0",\
                                              (0, []),\
                                              {})}
         self.os = robotsos.RoBotsOS(self, "saves/"+world+"/robots/"+self.name+"/fs", \

File src/robot/robotsos.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ##  
 ## Started on  Wed May  9 22:56:00 2012 Pierre Surply
-## Last update Sun Aug 19 18:15:44 2012 Pierre Surply
+## Last update Wed Sep  5 17:02:21 2012 Pierre Surply
 ##
 
 import os
         self.mem = mem
         self.terminal = terminal.Terminal(events)
         self.terminal.set_title(self.name)
-        self.set_cmds([("help", "", "show help", lambda o, a:o.help(a)),\
-                           ("info", "", "show some information about the robot", lambda o, a:o.info(a)),\
-                           ("intcmd", "", "show internal commands", lambda o, a: o.show_int_cmd(a)),\
-                           ("extcmd", "", "show external commands", lambda o, a: o.show_ext_cmd(a)),\
-                           ("welcome", "", "print welcome message", lambda o, a: o.welcome(a)),\
-                           ("pwd", "", "print name of current directory", lambda o, a: o.pwd(a)),\
-                           ("ls", "", "list directory contents", lambda o, a: o.ls(a)),\
-                           ("mkdir", "DIRECTORY", "make directory", lambda o, a: o.mkdir(a)),\
-                           ("touch", "FILE", "make file", lambda o, a: o.touch(a)),\
-                           ("cd", "[DIRECTORY]", "change current directory", lambda o, a: o.cd(a)),\
-                           ("cat", "FILE", "print file", lambda o, a: o.cat(a)),\
-                           ("run", "FILE", "execute a BASIC script", lambda o, a: o.execute(a, False)),\
-                           ("debug", "FILE", "debug a BASIC script", lambda o, a: o.execute(a, True)),\
+        self.set_cmds([("help", "", "shows help", lambda o, a:o.help(a)),\
+                           ("info", "", "shows some information about the robot", lambda o, a:o.info(a)),\
+                           ("intcmd", "", "shows internal commands", lambda o, a: o.show_int_cmd(a)),\
+                           ("extcmd", "", "shows external commands", lambda o, a: o.show_ext_cmd(a)),\
+                           ("welcome", "", "prints welcome message", lambda o, a: o.welcome(a)),\
+                           ("pwd", "", "prints name of current directory", lambda o, a: o.pwd(a)),\
+                           ("ls", "", "lists directory contents", lambda o, a: o.ls(a)),\
+                           ("mkdir", "DIRECTORY", "makes directory", lambda o, a: o.mkdir(a)),\
+                           ("touch", "FILE", "makes file", lambda o, a: o.touch(a)),\
+                           ("cd", "[DIRECTORY]", "changes current directory", lambda o, a: o.cd(a)),\
+                           ("cat", "FILE", "prints file", lambda o, a: o.cat(a)),\
+                           ("run", "FILE", "executes a BASIC script", lambda o, a: o.execute(a, False)),\
+                           ("debug", "FILE", "debugs a BASIC script", lambda o, a: o.execute(a, True)),\
                            ("edit", "FILE", "edit a file", lambda o, a: o.edit(a)),\
-                           ("inv", "", "list inventory", lambda o, a: o.ls_inv(a)),\
-                           ("let", "REG VALUE", "set register value", lambda o, a: o.let(a)),\
-                           ("stack", "", "print stack", lambda o, a: o.stack(a)),\
-                           ("tree", "", "", lambda o, a: o.tree(a)),\
-                           ("pulllib", "", "", lambda o, a: o.pulllib()),\
-                           ("pushlib", "", "", lambda o, a: o.pushlib()),\
-                           ("clear", "", "clear screen", lambda o, a: o.clear(a))])
+                           ("inv", "", "lists inventory", lambda o, a: o.ls_inv(a)),\
+                           ("let", "REG VALUE", "sets register value", lambda o, a: o.let(a)),\
+                           ("stack", "", "prints stack", lambda o, a: o.stack(a)),\
+                           ("tree", "", "lists directory contents recursively", lambda o, a: o.tree(a)),\
+                           ("pulllib", "", "Gets the standard library in /lib ", lambda o, a: o.pulllib()),\
+                           ("pushlib", "", "Sets the directory /lib as standard library", lambda o, a: o.pushlib()),\
+                           ("clear", "", "clears screen", lambda o, a: o.clear(a))])
         if self.robot.energy > 0:
             self.welcome(None)
         self.start_prompt()
                     if arg[0] == i.name:
                         self.help_cmd(i.name, False, i.description, i.param)
         else:
-            self.show_int_cmd(None)
-            self.show_ext_cmd(None)
+            self.terminal.write_line("-- Help --", 1)
+            self.terminal.write("intcmd", 1)
+            self.terminal.write_line(": shows internal commands")
+            self.terminal.write("extcmd", 1)
+            self.terminal.write_line(": shows external commands")
 
     def help_cmd(self, name, ext, desc, arg, cost=None, ret=None):
         self.terminal.write("Command", 1)
         self.terminal.write_line("Pulled library")
 
     def pushlib(self):
-        shutil.rmtree("saves/" + self.robot.world + "/lib")
-        shutil.copytree(self.get_path("/lib"), "saves/" + self.robot.world + "/lib")
-        self.terminal.write_line("Pushed library")
+        if os.path.isdir(self.get_path("/lib")):
+            shutil.rmtree("saves/" + self.robot.world + "/lib")
+            shutil.copytree(self.get_path("/lib"), "saves/" + self.robot.world + "/lib")
+            self.terminal.write_line("Pushed library")

File src/robot/thermalpowerstation.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Mon Jul 23 11:55:10 2012 Pierre Surply
-## Last update Thu Aug 16 12:23:48 2012 Pierre Surply
+## Last update Wed Sep  5 17:01:49 2012 Pierre Surply
 ##
 
 import robot
         self.inv.capacity = 500000
         self.id_sprite = 3
         self.ext_cmd["burn"] = (self.burn,\
-                                    "Burn fuel to produce energy",\
+                                    "Burns fuel to produce energy",\
                                     "",\
                                     (0, []),\
                                     {"A" : "item id"})
         self.ext_cmd["fuels"] = (self.fuels,\
-                                     "List all types of fuels",\
+                                     "Lists all types of fuels",\
                                      "Always returns 0",\
                                      (0, []),\
                                      {})
         self.ext_cmd["disten"] = (self.disten,\
-                                     "",\
+                                     "Distributes energy with near robots",\
                                      "Always returns 0",\
                                      (0, []),\
                                      {})

File src/robot/woodcutter.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Tue Jul  3 14:38:15 2012 Pierre Surply
-## Last update Wed Sep  5 12:16:39 2012 Pierre Surply
+## Last update Wed Sep  5 17:01:30 2012 Pierre Surply
 ##
 
 import robot
         self.inv.capacity = 100000
         self.id_sprite = 1
         self.ext_cmd["cuttree"] = (self.cut_wood,\
-                                       "Cut a tree to make wood",\
+                                       "Cuts a tree to make wood",\
                                        "1 if a tree has been cut, 0 otherwise", \
                                        (2, []), \
                                        {})