Forum

> > CS2D > Scripts > Table and map lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Table and map lua

12 replies
To the start Previous 1 Next To the start

old Table and map lua

Forever Alone
User Off Offline

Quote
Hi. I want ask you for help. I read all cs2d lua tutorials and i dont find soulution.

First problem-
How to read the current map info eg.
Spoiler >

How to read those map info?

Second problem
How to read this values eg.
Spoiler >

I want to read from this table a first value [1]


I want the final script looks like:
Spoiler >

Thank you for reading
edited 2×, last 11.08.14 03:20:56 pm

old Re: Table and map lua

Bounty Hunter
BANNED Off Offline

Quote
I forgot a command, but I think it should be like this:
game('sv_map')

parse('map '..my_map)

You can read it like this:
tablemaps[1].name

Code >

old Re: Table and map lua

Rainoth
Moderator Off Offline

Quote
Why'd you need to store information in multiple tables if it's just name? Wouldn't it be easier to just do
1
tablemaps = {"de_dust","de_dust2","de_inferno"}
or if you prefer it a bit more neat
1
2
3
4
tablemaps = {
	[1] = "de_dust",
	[2] = "de_dust2",
	[3] = "de_inferno"}
Then you just access them as
1
tablemaps[1],tablemaps[2],tablemaps[3]

P.S. it's probably more clear to use
1
map("name")
than game('sv_map')

old Re: Table and map lua

Avo
User Off Offline

Quote
Dunno whether it will work properly (note: not tested) but try it. If you start with the first map, it will work fine, I guess.
More >

old Re: Table and map lua

Avo
User Off Offline

Quote
So it's simple to edit my script. When time of a map expires, script should loop the list and find another map after the current one. I think it's easy to be done.

old Re: Table and map lua

Bounty Hunter
BANNED Off Offline

Quote
Android work can do not work
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mapList = {
	{
		name = 'de_dust';
		time = 10;
	};
	{
		name = 'de_dust2';
		time = 10;
	};
	{
		name = 'de_inferno';
		time = 10;
	};
}

timer = 0

function setMap()
	for _, i in pairs(mapList)
		if i == game('sv_map') then
			return _
		end
	end
	return 1
end

map = setMap()

addhook('minute','_minuteHook')
function _minuteHook()
	timer = timer + 1
	if timer >= mapList[map].time then
		timer = 0
		map = map + 1
		if map > #mapList then map = 1 end
		parse('map "'..mapList[map].name..'"')
	end
end

old Re: Table and map lua

Forever Alone
User Off Offline

Quote
Guys you are so bosses. Thank you for all the scripts

#edit
LUA ERROR: sys/lua/autorun/nextmap.lua:20: 'do' expected near 'if'

old Re: Table and map lua

Bounty Hunter
BANNED Off Offline

Quote
@user Forever Alone: Replace setMap function to this one:
1
2
3
4
5
6
7
8
function setMap()
     for _, i in pairs(mapList) do
          if i == game('sv_map') then
               return _
          end
     end
     return 1
end
I forgot about do to for loop.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview