I just can not figure out how to translate this operator from Lua to C # operator?
--Это некая карта из массива байт --0x0 используется как ничего, а 0x1 как стена local map = { { 0x1, 0x1, 0x1, 0x1 }, { 0x1, nil, nil, 0x1 }, { 0x1, nil, 0x1, 0x1 }, { 0x1, 0x1, 0x1, 0x1 }, } local yMap, xMap = math.floor(player.y / 32), math.floor(player.x / 32) if map[yMap] and map[yMap][xMap] then return map[yMap][xMap] end Well, to the point - I just can not understand how it works in general in Lua?
I'm if map[yMap] and map[yMap][xMap] then about the line with the comparison: if map[yMap] and map[yMap][xMap] then
I tried to understand and write this in C #
if ((map[yMap] != 0x0) & (map[yMap][xMap] != 0x0)) But all is in vain, the compiler of course swears that I am comparing byte [] and byte. I don’t understand why it works on Lua ?! Maybe he takes a byte from the beginning of the array?
And yes, as I correctly understood:
if map[0] then and if map[0] not nil then is this the same thing?
That is, if NOT nil returns true?
-
In Lua, I almost don’t know anything, I just need to transfer the Lua script to C #, please explain to the fool how it works?
falseandnil. "if map [yMap] and map [yMap] [xMap] then" - first the existence ofmap[yMap]is checkedmap[yMap]and empty lines also match), then the existence ofmap[yMap][xMap]- FareakyGnomeif map[0] not nil thencauses an error. The table key can also be false (but in general, everything except nil):if map[0]~=nil then. And in louach arrays, indices with 1 - in the map will always not work. - FareakyGnome