Forum

> > CS2D > Scripts > How can I insert a value inside this matrix?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How can I insert a value inside this matrix?

4 replies
To the start Previous 1 Next To the start

old How can I insert a value inside this matrix?

BrunoRZ
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
function CreateBST()
	BSoldier = {}
	for bl = 1,32 do
		BSoldier[bl] = {}
		for bn = 1,2 do
			BSoldier[bl][bn] = 0
		end
	end
end

This is what I do to create the matrix and to set the initial value of it's elements as 0.
And I did this to change the value of one element:
1
2
3
4
5
6
source = 1
b = (string.sub(msg,12))
	if player(b,'exists') then
		BSoldier[b][1] = source
	end
end

The line 4 in the second code results in this error: attempt to call global 'BSoldier' (a nil value).
I used print(source), print(b) and print(BSoldier[b][1]) to make sure that all of them had any integer value before reaching line 4, and they do... What should I do in order to correctly insert the 'source' value in 'BSoldier[b][1]'?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview