flo57100 Posted December 21, 2017 Share Posted December 21, 2017 Hello there, I started to try things with mist, and I want to have this: if hélicopters or planes from blue coalition enter trigger zone, those air assets become immortal in this zone only. I tried this: if mist.flagFunc.units_in_zones { units = {'[blue][plane]', '[blue][helicopter]'} zones = {'invincible'} flag = 100, stopflag = 200} then SetImmortal = { id = {'[blue][plane]', '[blue][helicopter]'} params = { value = true } } end But it doesn't work, can anyone help me please ? Link to comment Share on other sites More sharing options...
Grimes Posted December 21, 2017 Share Posted December 21, 2017 You are mixing a couple of different concepts together that don't really work how you think it does. The flagFuncs don't actually return anything, they act more like the triggers in game by setting specified flags to true whenever the conditions are met. What you need is more of a scripting function setup to periodically check those units and set them to be invincible once they enter the zone... local units = mist.makeUnitTable({'[blue][plane]', '[blue][helicopter]'}) -- make list of all blue planes and helicopters local zone = trigger.misc.getZone('invincible') -- get the trigger zone local inZone = {} -- table of units inside the zone local function check() for i = 1, #units do -- iterate units if Unit.getByName(units[i]) then -- if returned local u = Unit.getByName(units[i]) if u:getLife() > 0 then -- if it is alive if mist.utils.get2DDist(u:getPosition().p, zone.point) < zone.radius then -- if it is in the zone if not inZone[u:getName()] then -- if it wasn't there before u:getController():setCommand({id = 'SetImmortal', params = {value = true}}) -- set immortal to true inZone[u:getName()] == true -- add it to zone list end else -- if not in zone if inZone[u:getName()] then -- if was previously in zone u:getController():setCommand({id = 'SetImmortal', params = {value = false}}) -- set immortal to false inZone[u:getName()] = nil -- clear from list end end end end end end mist.scheduleFunction(check, {}, timer.getTime(), 5) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
flo57100 Posted December 22, 2017 Author Share Posted December 22, 2017 Hello Grimes and thank you for your script, it's really far far away from what I initially intended :thumbup: I just tried it, but I don't know what's going on I have this error message that pops on screen after the mission, when the script is expected to load [string "local.units = mist.makeUnitTable({'[blue][plane]','[blue][heli..."]:13: '=' expected near '==' What does it mean ? Link to comment Share on other sites More sharing options...
Grimes Posted December 22, 2017 Share Posted December 22, 2017 There is a typo on line 13. I accidentally used == instead of = In lua == means "equals" while a = assigns a value. They have different syntax for when they are used. For example: if whatever == 'hello' then whatEverElse = 'world' end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
flo57100 Posted December 22, 2017 Author Share Posted December 22, 2017 I tried the script by correcting the == issue, no more error message but airplanes/helos are not immortal, I put a shilka into the zone for testing purpose, it didn't end well as my harrier has been torn in pieces ^^ Link to comment Share on other sites More sharing options...
BR55Sevas Posted June 3, 2021 Share Posted June 3, 2021 (edited) How can I extract client nicknames and their position from mission with MIST? I trying this way, starting to enumerate units name. But when I try to print name I have this error local units = mist.makeUnitTable({'[all]'}, {'static','ship','vehicle'}) for i=1,#units do if Unit.getByName(units[i]) then -- if returned local u = Unit.getByName(units[i]).unitName --local testNAME = u.unitName --trigger.action.outText(u, 100) end end Edited June 3, 2021 by BR55Sevas МиГ-29 Fly by wire СДУ Su-27SM second display panel https://www.youtube.com/embed/videoseries?list=PL_2GGwNpWNp_fKXfRtDhIk8s5Jf4a9XHS http://berkuts.ru Пилотажный сервер с роботом | Aerobatic server with PhantomControl Link to comment Share on other sites More sharing options...
Grimes Posted June 3, 2021 Share Posted June 3, 2021 There are a few things wrong there. The units table is a list of unit names. So you already have that information. units[i] is a specific unit name from that table. Unit.getByName(units[i]).unitName is a nil value. That entry simply doesn't exist since Unit.getByName returns a unit object. The equivalent would be Unit.getByName(units[i]):getName(). However that is kind of pointless since you already have the name. If the "u" value was the unit object its not something that can be directly output via outText since its not a string or number. It looks like a table but its a little more complicated than that. I'm guessing you want something more like local u = Unit.getByName(units[i]):getPlayerName() 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
BR55Sevas Posted June 4, 2021 Share Posted June 4, 2021 (edited) Yes, all I want is just to get info (nickname and postion vector) about live units controlled by human only - clients. I have tried your advice Now my code looks like this, I`ve changed u to nickname for better code readability local units = mist.makeUnitTable({'all'}) for i=1,#units do local nickname = Unit.getByName(units[i]):getPlayerName()-- this is 35th line where error is trigger.action.outText(nickname, 100) end But same as before I have error. I suppose I need to check if unit is selected by human, because now if unit exist in list, but if it`s not controlled then playerName is nil value. But what proper way to check if unit under client control? Debug #unit count return 1 even if in mission only server and plane not choosen Edited June 4, 2021 by BR55Sevas МиГ-29 Fly by wire СДУ Su-27SM second display panel https://www.youtube.com/embed/videoseries?list=PL_2GGwNpWNp_fKXfRtDhIk8s5Jf4a9XHS http://berkuts.ru Пилотажный сервер с роботом | Aerobatic server with PhantomControl Link to comment Share on other sites More sharing options...
cfrag Posted June 4, 2021 Share Posted June 4, 2021 (edited) I don't know mist well, but make sure that the units returned in the table from makeUnitTable are really units, not a table that contains the unit and additional data the table itself is an array, not a dictionary Grimes will probably resolve that in a second, but until then I recommend that instead of a for i loop, you use for key, value in pairs() instead. Edited June 4, 2021 by cfrag Link to comment Share on other sites More sharing options...
Grimes Posted June 4, 2021 Share Posted June 4, 2021 If you want to check for clients you can just use the built in DB table for them. for uName, uData in pairs(mist.DBs.humansByName) do if Unit.getByName(uName) then -- unit is alive and exists local nickname = Unit.getByName(uName):getPlayerName() trigger.action.outText(nickname, 100) end end if Unit.getByName(whatever) is required because both the humansByName table and makeUnitsTable function just contain a static table of what the unit names within a given mission and don't keep track if anything is alive. Think of it as a list of units that fit the parameters. humansByName being something that is created by mist with a bunch of other data in there as well like coalition, country, unit type, etc. On the other hand what gets returned by mist.makeUnitsTable is just that, a list of unit names indexed numerically. From your code the " local nickname = Unit.getByName(units[i]):getPlayerName()-- this is 35th line where error is " can fail because Unit.getByName(units[i]) can return a nil value if that unit isn't alive which in turn causes an error because it is effectively nil:getPlayerName(). 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
BR55Sevas Posted June 5, 2021 Share Posted June 5, 2021 (edited) Thanks, Grimes! Everything work as needed. You are the true guru of lua and mist! Edited June 5, 2021 by BR55Sevas МиГ-29 Fly by wire СДУ Su-27SM second display panel https://www.youtube.com/embed/videoseries?list=PL_2GGwNpWNp_fKXfRtDhIk8s5Jf4a9XHS http://berkuts.ru Пилотажный сервер с роботом | Aerobatic server with PhantomControl Link to comment Share on other sites More sharing options...
Aigle2 Posted February 8, 2022 Share Posted February 8, 2022 On 12/22/2017 at 9:13 AM, Grimes said: There is a typo on line 13. I accidentally used == instead of = In lua == means "equals" while a = assigns a value. They have different syntax for when they are used. For example: if whatever == 'hello' then whatEverElse = 'world' end I tested with the correction, but players aren't immortal. Any idea what can go wrong ? ( trigger.action.outText's work fine though) Link to comment Share on other sites More sharing options...
Recommended Posts