[M3devel] humor: How to do "math" in quake (or at least add one).

Jay jay.krell at cornell.edu
Sun May 17 05:22:06 CEST 2009



You might find this amusing.


Task:
implement a counter, in order to give
temp files somewhat unique but not excessively
random names


caveats:
it can exhibit "wraparound" behavior, but
it should provide more than just 0-9


solution:

m3cc_ResponseFileCounter0 = "0"
m3cc_ResponseFileCounter1 = "0"
m3cc_ResponseFileCounter2 = "0"

local ShLeaf = "_m3" & m3cc_ResponseFileCounter0 & m3cc_ResponseFileCounter1 & m3cc_ResponseFileCounter2 & ".sh"


Inc is a table/map/hashtable.
Left of colon is key, right of colon is value.


local Inc = { "0":"1","1":"2","2":"3","3":"4","4":"5",
"5":"6","6":"7","7":"8","8":"9","9":"0" }
m3cc_ResponseFileCounter2 = Inc{m3cc_ResponseFileCounter2}
if equal(m3cc_ResponseFileCounter2, "0")
m3cc_ResponseFileCounter1 = Inc{m3cc_ResponseFileCounter1}
if equal(m3cc_ResponseFileCounter1, "0")
m3cc_ResponseFileCounter0 = Inc{m3cc_ResponseFileCounter0}
end
end


- Jay


More information about the M3devel mailing list