Im making saving feature the the super hero mod but im getting errors. Is not that errors with lua, the result of the script is not exactly what i wanted.
Here is the script :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
function sh_saveheroes(id) 	local ida = 0 	local i 	for ida = 0,sheroescount[id] do -- I made an array for each time the player selects a hero it adds 1 		-- example, player has 2 heros (flash and superman) it will stop at 2 (for ida,2 do) 		for i = 1,36 do 			if sh_id[(id - 1) * 36 + i] > 0 then -- then it checks all heroes and checks if the player have it (example : sh_id[12] = 1) -- Means the player has the hero with id 12 				file = assert(io.open(sh_dir..'sh_data/'..player(id,"usgn")..'lol.txt','a')) -- writes the player heroes 				file:write('sh_id[(id - 1) * 36] = '..i..'\n') -- continuation 				file:close() 			end 		end 	end end
The problem is that cs2d repeats the heroes of the player in the file. Example of the file usgnlol.txt:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sh_id[(id - 1) * 36] = 1 sh_id[(id - 1) * 36] = 2 sh_id[(id - 1) * 36] = 3 sh_id[(id - 1) * 36] = 6 sh_id[(id - 1) * 36] = 7 sh_id[(id - 1) * 36] = 10 sh_id[(id - 1) * 36] = 1 sh_id[(id - 1) * 36] = 2 sh_id[(id - 1) * 36] = 3 sh_id[(id - 1) * 36] = 6 sh_id[(id - 1) * 36] = 7 sh_id[(id - 1) * 36] = 10 sh_id[(id - 1) * 36] = 1 sh_id[(id - 1) * 36] = 2 sh_id[(id - 1) * 36] = 3 sh_id[(id - 1) * 36] = 6 sh_id[(id - 1) * 36] = 7 sh_id[(id - 1) * 36] = 10
edited 1×, last 21.07.13 01:19:50 pm