Forum

> > CS2D > Scripts > 3darray
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch 3darray

22 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: 3darray

Ultimate programmer
BANNED Off Offline

Zitieren
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.

alt Re: 3darray

DannyDeth
User Off Offline

Zitieren
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..

alt Re: 3darray

Flacko
User Off Offline

Zitieren
Zitat
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)
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht