yar Posted March 1, 2008 Posted March 1, 2008 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?!?
golfsierra2 Posted March 1, 2008 Posted March 1, 2008 Have you seen this already ? http://www.lua.org/manual/5.1/ Try to ask for help in a Lua-forum: http://www.lua.org/community.html 1 kind regards, Raven.... [sigpic]http://www.crc-mindreader.de/CRT/images/Birds2011.gif[/sigpic]
yar Posted March 1, 2008 Author Posted March 1, 2008 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 :( )
Balu Posted March 1, 2008 Posted March 1, 2008 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?
yar Posted March 1, 2008 Author Posted March 1, 2008 Are you searching for a solution to differ between friend and foe?partial yes, but its not the only thing..
Balu Posted March 2, 2008 Posted March 2, 2008 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.
yar Posted March 2, 2008 Author Posted March 2, 2008 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...
Balu Posted March 2, 2008 Posted March 2, 2008 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 1
yar Posted March 2, 2008 Author Posted March 2, 2008 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)
yar Posted March 7, 2008 Author Posted March 7, 2008 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)
Recommended Posts