Skip to content
Browse files

started work on the Lua API docs

  • Loading branch information...
1 parent 2e2a147 commit f285c2c86113b68468cbcbaf0a8a25e619749ac4 @iamgreaser committed Jan 10, 2013
Showing with 146 additions and 2 deletions.
  1. +20 −0 genmanual.py
  2. +19 −2 msrc/index.py
  3. +32 −0 msrc/mods/lua/sect/camera.py
  4. +75 −0 msrc/mods/lua/sect/fetch.py
View
20 genmanual.py
@@ -100,4 +100,24 @@ def gen_list(l, pbase="", level=1):
return list_data
+def gen_lua_api_docs(l):
+ list_data = []
+ for rets, name, args, optargs, isimp, tags in l:
+ s = name + "("
+
+ if rets:
+ s = ", ".join(rets) + " = " + s
+ l2 = []
+ for n in args:
+ l2.append(n)
+
+ for n, v in optargs:
+ l2.append(n + " = " + v)
+
+ s += ", ".join(l2) + "):"
+ list_data.append(m_h2(m_tt(s)))
+ list_data += tags
+
+ return list_data
+
mkpage("index")
View
21 msrc/index.py
@@ -26,9 +26,26 @@
]),
("Modding The Game", "mods/", [
("Coding conventions", "conv", None),
- ("Base game API", "basegame", None),
- ("Lua API reference", "lua", None),
("Networking protocol", "network", None),
+ ("Base game API", "base/", [
+ ("Preloader", "preload", None),
+ ("Libraries", "lib", None),
+ ]),
+ ("Lua API reference", "lua/", [
+ ("Notes", "notes", None),
+ ("Sections", "sect/", [
+ ("Function hooks", "hook", None),
+ ("camera", "camera", None),
+ ("fetch", "fetch", None),
+ ("image", "image", None),
+ ("json", "json", None),
+ ("map", "map", None),
+ ("model", "model", None),
+ ("mouse", "mouse", None),
+ ("net", "net", None),
+ ("wav", "wav", None),
+ ]),
+ ]),
]),
("File Formats", "fmt/", [
("[vxl] Ace of Spades Map", "vxl", None),
View
32 msrc/mods/lua/sect/camera.py
@@ -0,0 +1,32 @@
+TITLE = ICEBALL_W_VER + " - Lua API - camera"
+
+SECTIONS = [
+ (None, "client.camera_point", ["dx", "dy", "dz"], [("zoom", "1.0"), ("roll", "0.0")], True,
+ [m_p("points the camera in a direction with zoom factor \"zoom\"",
+ "and roll \"roll\" (in radians, sorry)")]),
+
+ (None, "client.camera_point_sky", ["dx", "dy", "dz"], [("zoom", "1.0"), ("sx", "0.0"), ("sy", "-1.0"), ("sz", "0.0")], True,
+ [m_p("points the camera in a direction with zoom factor \"zoom\"",
+ "and sky arrow sx,sy,sz")]),
+
+ (None, "client.camera_move_local", ["dx", "dy", "dz"], [], True,
+ [m_p("moves the camera in the camera-local direction (dx,dy,dz)")]),
+
+ (None, "client.camera_move_global", ["dx", "dy", "dz"], [], True,
+ [m_p("moves the camera in the world direction (dx,dy,dz)")]),
+
+ (None, "client.camera_move_to", ["px", "py", "pz"], [], True,
+ [m_p("moves the camera to the world position (px,py,pz)")]),
+
+ (["px", "py", "pz"], "client.camera_get_pos", [], [], True,
+ [m_p("gets the camera's position")]),
+
+ (["dx", "dy", "dz"], "client.camera_get_forward", [], [], True,
+ [m_p("gets the camera's forward vector")]),
+]
+
+BODY = m_html(m_head(m_title(TITLE)), m_body(*([
+ m_h1(TITLE),
+ m_hr()] +
+ gen_lua_api_docs(SECTIONS)
+)))
View
75 msrc/mods/lua/sect/fetch.py
@@ -0,0 +1,75 @@
+TITLE = ICEBALL_W_VER + " - Lua API - fetch"
+
+SECTIONS = [
+ (["obj"], "common.fetch_start", ["ftype", "fname"], [], True,
+ [m_p("initiates a file fetch"),
+ m_p("\"ftype\" is one of the following:"),
+ m_ul(
+ m_li(m_b("\"lua\":"), "lua script"),
+ m_li(m_b("\"map\":"), "map (autodetect)"),
+ m_li(m_b("\"icemap\":"), "map (icemap) - in-memory maps are serialised as THIS."),
+ m_li(m_b("\"vxl\":"), "map (vxl) - ", m_b("CANNOT SAVE IN THIS FORMAT.")),
+ m_li(m_b("\"pmf\":"), "pmf model"),
+ m_li(m_b("\"tga\":"), "tga image"),
+ m_li(m_b("\"json\":"), "json data"),
+ m_li(m_b("\"wav\":"), "wav sound")
+ ),
+ m_p("for the server, this just loads the file from the disk."),
+ m_p("for the client, all clsave/* stuff is taken from the disk, ",
+ "but all other files are downloaded from the server."),
+
+ m_p("returns"),
+ m_ul(
+ m_li(m_tt(m_b("true")), " if the fetch has started,"),
+ m_li(m_tt(m_b("nil")), " if there is an error, or"),
+ m_li("the requested object if this was an immediate load.")
+ ),
+
+ m_p("if there is already a file in the queue, ",
+ "this will return ", m_tt(m_b("nil")), ".")
+ ]),
+
+ (["obj", "csize", "usize", "amount"], "common.fetch_poll", [], [], True,
+ [m_p("polls the status of the file being currently tranferred,"
+ "if it exists."),
+
+ m_p("\"obj\" is one of the following:"),
+ m_ul(
+ m_li(m_tt(m_b("nil")), " if transfer aborted or nothing is being fetched"
+ , " - in this case, all other fields will be ",m_tt(m_b("nil"))),
+ m_li(m_tt(m_b("false")), " if still downloading"),
+ m_li("the object you requested"
+ , " - in this case, another poll will just return nil"),
+ ),
+
+
+ m_p("\"amount\" is in the range 0 <= \"amount\" <= 1, ",
+ "and indicates how much is downloaded"),
+ m_p("\"csize\" is the compressed size of the file"),
+ m_p("\"usize\" is the uncompressed size"),
+
+ m_p("the two sizes will be nil while unknown."),
+
+ m_p("note, all vxl maps will be converted to icemap before sending.")]),
+
+ (["obj"], "common.fetch_block", ["ftype", "fname"], [], True,
+ [m_p("fetches a file using common.fetch_*"),
+ m_p("simply returns ", m_tt(m_b("nil")), " on error "),
+ m_p("if there is already something being fetched,",
+ "it will return ", m_tt(m_b("nil")), ", too"),]),
+]
+"""
+obj = common.fetch_block(ftype, fname) @
+ fetches a file using common.fetch_*
+
+ simply returns "nil" on error
+
+ if there is already something being fetched,
+ it will return "nil", too
+"""
+
+BODY = m_html(m_head(m_title(TITLE)), m_body(*([
+ m_h1(TITLE),
+ m_hr()] +
+ gen_lua_api_docs(SECTIONS)
+)))

0 comments on commit f285c2c

Please sign in to comment.
Something went wrong with that request. Please try again.