This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - Jim Bauwens
Pages: 1 ... 25 26 [27] 28 29 ... 125
391
« on: June 30, 2012, 03:49:28 pm »
You can not add/remove pages. However, you can run a Lua script in each page and communicate using [lua]var.store[/lua] and [lua]var.monitor[/lua].
392
« on: June 30, 2012, 03:24:14 pm »
Frog, I send you some code in a pm
393
« on: June 29, 2012, 04:06:24 pm »
Hey, it doesn't glitch It does exactly what you ask Here is the code: #!/usr/bin/env python # This program converts 8 bit DEC files to 4 bit import sys
def fixHex(h): res = h.replace("0x","").upper() if len(res) == 1: res = "0"+res return res
if len(sys.argv) < 2: print("python convert.py <filename>") exit(-1)
try: file = open(sys.argv[1], "rb") except: print(sys.argv[1] + " can not be opened!") exit(-1) data = file.read()
out = ""
try: for i in range(len(data)): if i%4 == 0: part1 = (ord(data[i])>>4)<<4 part2 = ord(data[i+3])>>4 out += fixHex(hex(part1+part2)) except: print("Warning, file size odd! Last byte ignored.") print(out[:-1])
Example input data: A1 A1 B2 B2 3C 3C 4D 4D (but in binary form) Output: AB34 (in string) So, what is does is loop 4 bytes a time over all the data. The first byte and the third byte is what I need as the second and fourth are just the same. Then I do there operations each loop: a = (ord(byte1)>>4)<<4 b = (ord(byte3)>>4) output = a + b
394
« on: June 29, 2012, 03:38:48 pm »
Yes, I know it is complex. Luckily I have managed to master it a bit, and will write a tutorial as soon as I get the time. I'll see to post here some examples soon
395
« on: June 29, 2012, 02:36:29 pm »
Normally it showed in big that it was disabled, but did not do that anymore. Fixed it
396
« on: June 29, 2012, 01:53:11 pm »
DOSBox is C++ and uses SDL. So first pSDL and a proper C++ toolchain is needed. But I could be wrong ^^
397
« on: June 29, 2012, 05:01:49 am »
I get an error that global gc has been indexed so I know something isnt working.
Something like, "Attempt to index nil value gc" ? Well, maybe you just forgot to add gc to the function parameter ? Edit: BTW, assert doesn't run a Lua chunk/function. It just checks that it's not nil. So you would need to do assert(chunkname, "chunk is nil")()
398
« on: June 28, 2012, 05:11:36 pm »
Normally if you execute a new lua chunk it should be able to access all the existing variables. I'll take a look at your code tomorrow.
399
« on: June 27, 2012, 02:43:28 pm »
Very nice \o/
400
« on: June 24, 2012, 06:52:50 pm »
They do, but need to be recompiled with the new lua in order to take advantage of new stuff.
401
« on: June 24, 2012, 03:40:08 pm »
Thanks ! Also yay for special character support, it was something that was bugging me
402
« on: June 24, 2012, 11:42:18 am »
Nice Adriweb ! Looks like it will be a fun game (Also, cool that you are using ETK)
403
« on: June 24, 2012, 06:23:26 am »
Depends what you mean with a Matrix.
If you just want a matrix for a map, it's as simple as:
map = { {1,1,1,1,1,1,1,1}, {1,1,0,0,0,0,0,1} {1,0,0,1,1,1,1,1} {1,0,1,1,1,1,1,1} {1,0,0,0,0,0,0,1} {1,1,0,0,0,1,0,1} {1,0,0,1,0,0,0,1} {1,1,1,1,1,1,1,1} }
or however you want to store the data. It's just a combination of tables, and you can access it using map[ x][ y].
If you are talking about mathematical matrices, no Lua does not provide support for the math of it. However, Nspire-Lua does. You can access Matrices in the document using var.recall, var.recallAt and math.eval. You can write to the matrix using math.eval, var.store or var.storeAt. Performing (mathematical) operations is done using math.eval.
So: You can easily have normal data and mathematical matrices in Nspire-Lua. But mathematical matrixes in normal (computer) lua is not possible, hence why 3rik is writting this lib.
404
« on: June 23, 2012, 04:44:58 pm »
Take a look at this:
class = function(prototype) local derived={}
if prototype then derived.__proto = prototype function derived.__index(t,key) return rawget(derived,key) or prototype[nobbc] end else function derived.__index(t,key) return rawget(derived,key) end end function derived.__call(proto,...) local instance={} setmetatable(instance,proto) instance.__obj = true local init=instance.init if init then init(instance,...) end return instance end setmetatable(derived,derived) return derived end
Matrix = class()
function Matrix:init(mat) self.get = function(self, y, x) assert(type(y) == "number" and type(x) == "number", "Invalid input to Matrix:get!") return mat[y][x] end self.set = function(self, y, x, n) local nn = tonumber(n) assert(type(y) == "number" and type(x) == "number" and nn, "Invalid input to Matrix:set!") mat[y][x] = nn end end
function Matrix:someFunction() self:set(whateveryouwant) end
matrix1 = Matrix{{1,2,3},{4,5,6}}
matrix1:set(2,1, "9") print(matrix1:get(2,1))
What do you think ?
405
« on: June 23, 2012, 04:35:56 pm »
Okay, I guess you just need to modify some things to get it working. However, why don't you just make the matrix local to your functions, so only your functions can access it ? That way you could have matrix.getValue and matrix.setValue. Matrix[ y][ x] would not work. That way you don't need to deal with lot's of stuff.
Pages: 1 ... 25 26 [27] 28 29 ... 125
|