Jump to content

Recommended Posts

Posted

following situation: i have a variable, which contains an ID

 

how can i get the coalition of this id?

( Note: this id wont be the same all the time )

 

 

i dont understand very much about lua, i hope someone can help me.

 

i've tried lots of ways, but some of them didnt work, other caused big error messages and other fraged my lock on :doh:

 

 

i hope some of you understand lua and can help me to get the coalition of ids.

by the way: can i find it out only by the ID it self?!?

Posted

yes, i know this site/forum.

 

i was not shure if the luaforum could help me (because this here is lock on specific) - so im here (3rd forum now :( )

Posted

The question is, which ID do you have and what do you want to do with it? Are you searching for a solution to differ between friend and foe?

Posted
Are you searching for a solution to differ between friend and foe?
partial yes, but its not the only thing..
Posted

If you want to get your own coalition side:

 

for k,v in pairs(LoGetWorldObjects()) do

if string.find(v.Name, "(Me)", 1, true) then

-- return value = "Allies" or "Enemies"

_coal = v.Coalition

end

end

 

The return value is a string value.

Posted

thank you balu!

 

but is there a way to find out the coalition of various id's?

maybe if you find out which country belongs to which coalition...

Posted

local o = LoGetWorldObjects()

for k,v in pairs(o) do

socket.try(c:send(string.format("t = %.2f, ID = %d, name = %s, country = %s(%s), LatLongAlt = (%f, %f, %f), heading = %f\n", t, k, v.Name, v.Country, v.Coalition, v.LatLongAlt.x, v.LatLongAlt.Long, v.LatLongAlt.Alt, v.Heading)))

end

 

With this statment you should receive ID, country and coalition.

 

I think that you know this site, there are same useful examples:

http://lockon.co.uk/index.php?end_pos=567&scr=default〈=en

  • Like 1
Posted

i tried this some days before...

 

how i say the function which id it should use?

 

 

 

PS. yes, i know this site (most of it are also available in the export.lua)

Posted

sorry, for doublepost, but your first code didnt export :(

for testing the export i placed this

io.write(string.format("PCoalition= %s", _coal))

 

below

_coal = v.Coalition

 

the export of other things worked before...hm.. no idea why not now

(in the error log there is nothing about lua)

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...