|
|
@ -371,12 +371,12 @@ function GetRaceToken(p) --actually gets token...
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function BuildNameTable()
|
|
|
|
function BuildNameTable()
|
|
|
|
local rtbl={}
|
|
|
|
local rtbl={}
|
|
|
|
local vec=df.world.raws.creatures.all
|
|
|
|
local vec=df.global.world.raws.creatures.all
|
|
|
|
--print(string.format("Vector start:%x",vec.st))
|
|
|
|
--print(string.format("Vector start:%x",vec.st))
|
|
|
|
--print(string.format("Vector end:%x",vec.en))
|
|
|
|
--print(string.format("Vector end:%x",vec.en))
|
|
|
|
--print("Creature count:"..vec.size)
|
|
|
|
--print("Creature count:"..vec.size)
|
|
|
|
for k,v in iter(vec) do
|
|
|
|
for k=0,#vec-1 do
|
|
|
|
local name=v:deref().creature_id
|
|
|
|
local name=vec[k].creature_id
|
|
|
|
--print(k.." "..tostring(name))
|
|
|
|
--print(k.." "..tostring(name))
|
|
|
|
rtbl[name]=k
|
|
|
|
rtbl[name]=k
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -468,29 +468,29 @@ function ParseNames(path)
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function getSelectedUnit()
|
|
|
|
function getSelectedUnit()
|
|
|
|
local unit_indx=df.ui_selected_unit
|
|
|
|
local unit_indx=df.global.ui_selected_unit
|
|
|
|
if unit_indx<df.world.units.other[0].size then
|
|
|
|
if unit_indx<#df.global.world.units.other[0]-1 then
|
|
|
|
return df.world.units.other[0][unit_indx]:deref()
|
|
|
|
return df.global.world.units.other[0][unit_indx]
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function getxyz() -- this will return pointers x,y and z coordinates.
|
|
|
|
function getxyz() -- this will return pointers x,y and z coordinates.
|
|
|
|
local x=df.cursor.x
|
|
|
|
local x=df.global.cursor.x
|
|
|
|
local y=df.cursor.y
|
|
|
|
local y=df.global.cursor.y
|
|
|
|
local z=df.cursor.z
|
|
|
|
local z=df.global.cursor.z
|
|
|
|
return x,y,z -- return the coords
|
|
|
|
return x,y,z -- return the coords
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function getCreatureAtPos(x,y,z) -- gets the creature index @ x,y,z coord
|
|
|
|
function getCreatureAtPos(x,y,z) -- gets the creature index @ x,y,z coord
|
|
|
|
--local x,y,z=getxyz() --get 'X' coords
|
|
|
|
--local x,y,z=getxyz() --get 'X' coords
|
|
|
|
local vector=df.world.units.all -- load all creatures
|
|
|
|
local vector=df.global.world.units.all -- load all creatures
|
|
|
|
for i = 0, vector.size-1 do -- look into all creatures offsets
|
|
|
|
for i = 0, #vector-1 do -- look into all creatures offsets
|
|
|
|
local curpos=vector[i]:deref().pos --get its coordinates
|
|
|
|
local curpos=vector[i].pos --get its coordinates
|
|
|
|
local cx=curpos.x
|
|
|
|
local cx=curpos.x
|
|
|
|
local cy=curpos.y
|
|
|
|
local cy=curpos.y
|
|
|
|
local cz=curpos.z
|
|
|
|
local cz=curpos.z
|
|
|
|
if cx==x and cy==y and cz==z then --compare them
|
|
|
|
if cx==x and cy==y and cz==z then --compare them
|
|
|
|
return vector[i]:deref() --return index
|
|
|
|
return vector[i] --return index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print("Creature not found!")
|
|
|
|
print("Creature not found!")
|
|
|
|