Getting Highlighted Reference Points (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


bearhunter007 -> Getting Highlighted Reference Points (3/19/2020 10:07:57 PM)

The code below works as far as getting the number of Reference points and whether they are highlighted. It fails on the logic test of whether zz='Yes'. What am I missing?



--Get all Highlighted Reference Points
local u = VP_GetSide({Side ='Vietnam'}) -- a side object
--print(u.rps)

tbl={}
tbl=u.rps
--print(tbl)
local count = 0
for _ in pairs(tbl) do
count = count + 1
end
print(count)


for i=1, count do
if u.rps~=nil then
local zz=u.rps.highlighted
print(zz)
if zz=='Yes' then
print(u.rps) -- ***This is not getting printed***
end
end
end




Eboreg -> RE: Getting Highlighted Reference Points (3/20/2020 12:49:10 AM)

Change "if zz == 'Yes'" to "if zz == true"




bearhunter007 -> RE: Getting Highlighted Reference Points (3/20/2020 2:28:03 AM)

Eboreg

Thanks for the reply. I initially tried 'true' but it did not work.





michaelm75au -> RE: Getting Highlighted Reference Points (3/20/2020 3:27:19 AM)

Simple test to validate
quote:

local a = ScenEdit_GetReferencePoint({side='1',name='rp-7'})
print(a.highlighted)
if a.highlighted == true then
print('Highlighted')
end




michaelm75au -> RE: Getting Highlighted Reference Points (3/20/2020 3:29:25 AM)

BTW, when printing 'boolean' types, they usually come out 'Yes' or 'No'. But you test them against proper values (true/false)




bearhunter007 -> RE: Getting Highlighted Reference Points (3/20/2020 6:15:35 PM)

Thanks Michael I realized I had several syntax errors.

Here is the corrected code that works:

--Get all Highlighted Reference Points
local u = VP_GetSide({Side ='Vietnam'}) -- a side object
--print(u.rps)

tbl={}
tbl=u.rps
--print(tbl)
local count = 0
for _ in pairs(tbl) do
count = count + 1
end
print(count)


for i=1, count do
if u.rps~=nil then
local z=u.rps.highlighted==true
if z==true then print(u.rps) end
end
end




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.125