Forum

> > CS2D > Scripts > 3darray
Forums overviewCS2D overview Scripts overviewLog in to reply

English 3darray

22 replies
Page
To the start Previous 1 2 Next To the start

old Re: 3darray

Ultimate programmer
BANNED Off Offline

Quote
It also do not works:
1
2
3
4
5
mmpmap={{{}}}
pl=1
x=5
y=7
mmpmap[pl][x][y]=5		--error

I will stop this fucking project-why i need to do not my own game better?
Note:I wrote large part of my game.

old Re: 3darray

DannyDeth
User Off Offline

Quote
it would appear 3D arrays have trouble in Lua as 2D ones work perfectly fine.. perhaps Lua doesn't like large memory consumption and so blocks out multiple dimension arrays large than 2 dimensions..

old Re: 3darray

Flacko
User Off Offline

Quote
Quote
I need 3d array because DC have made stupid way to drow image-createimage->deleteimage.But if he will make drawimage(img,x,y) as in engines.i will not need it

It's not stupid, it's rather convenient.

Now, this WILL work fine:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if not table.unpack then table.unpack = unpack end

function table.copy(t)
	local b = {}
	for k,v in pairs(t) do
		if type(v)=='table' then
			v = table.copy(v)
		end
		b[k] = v
	end
	return b
end

function table.array(v, ...)
	local t = {}
	if arg[2] then
		v = table.array(v,table.unpack(arg,2))
	end
	for i=1,arg[1] do
		if arg[2] then v = table.copy(v) end
		t[i]=v
	end
	return t
end

Usage is the same as before:
1
a = table.array(0,32,20,20)
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview