English Table and map lua

12 replies
Goto Page
To the start Previous 1 Next To the start
11.08.14 03:06:54 pm
Up
Forever Alone
User
Offline Off
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
11.08.14 03:30:52 pm
Up
miere
User
Offline Off
1) use cs2d lua cmd map
2) read this

Good luck.
11.08.14 03:58:42 pm
Up
Forever Alone
User
Offline Off
@user miere:
Can u give me sample? I really learn more when i see this code
11.08.14 04:15:07 pm
Up
Bounty Hunter
BANNED
Offline Off
I forgot a command, but I think it should be like this:
Code:
game('sv_map')

Code:
parse('map '..my_map)

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

Code >
11.08.14 04:25:49 pm
Up
Forever Alone
User
Offline Off
@user Bounty Hunter:
Oh thank you! U help me very much. Now i understand the Table function. I lov you
11.08.14 04:44:36 pm
Up
Rainoth
Moderator
Offline Off
Why'd you need to store information in multiple tables if it's just name? Wouldn't it be easier to just do
Code:
1
tablemaps = {"de_dust","de_dust2","de_inferno"}

or if you prefer it a bit more neat
Code:
1
2
3
4
tablemaps = {
     [1] = "de_dust",
     [2] = "de_dust2",
     [3] = "de_inferno"}

Then you just access them as
Code:
1
tablemaps[1],tablemaps[2],tablemaps[3]


P.S. it's probably more clear to use
Code:
1
map("name")

than game('sv_map')
11.08.14 07:29:00 pm
Up
Bounty Hunter
BANNED
Offline Off
@user Rainoth: You be my god.
11.08.14 07:33:48 pm
Up
Avo
User
Offline Off
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 >
11.08.14 09:09:49 pm
Up
Bounty Hunter
BANNED
Offline Off
@user Avo: Nope. The Map var will lost in next map
Work in progress / fixing
11.08.14 09:14:46 pm
Up
Avo
User
Offline Off
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.
11.08.14 09:26:36 pm
Up
Bounty Hunter
BANNED
Offline Off
Android work can do not work
Code:
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
11.08.14 09:40:39 pm
Up
Forever Alone
User
Offline Off
Guys you are so bosses. Thank you for all the scripts

#edit
LUA ERROR: sys/lua/autorun/nextmap.lua:20: 'do' expected near 'if'
11.08.14 09:50:42 pm
Up
Bounty Hunter
BANNED
Offline Off
@user Forever Alone: Replace setMap function to this one:
Code:
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