LFCChameleon_Silk Posted October 9, 2014 Posted October 9, 2014 checkunits = { groupName = DefensesName, flag = 101, percent = 80, } mist.flagFunc.group_alive_less_than(checkunits)what am I doing wrong? flag 101 never is true, even when i kill the units that are in the string DefensesName I literally spent 8 hours on this last night and tried many different ways and still nothing.
Stonehouse Posted October 9, 2014 Posted October 9, 2014 looking at Mist 3.5.37 the table is: local type_tbl = { [{'group', 'groupname', 'gp', 'groupName'}] = 'string', percent = 'number', flag = {'number', 'string'}, stopflag = {'number', 'string', 'nil'}, interval = {'number', 'nil'}, toggle = {'boolean', 'nil'}, } I doubt it matters as I assume the reference to a table element is used to address it rather than the position but in case it does I notice that the percentage and flag are swapped around compared to your table. There is also a call to mist.utils.typeCheck on the table elements that would stop it working if you passed a wrong data type. Are you seeing any errors like that in your log? I guess the other thought is to add a debug line in Mist to see what values are arriving in Mist in case you aren't passing something correctly?
LFCChameleon_Silk Posted October 9, 2014 Author Posted October 9, 2014 (edited) 00098.132 ERROR SCRIPTING: [string "E:\Users\Gamer\AppData\Local\Temp\DCS\/~mis00001594"]:3196: attempt to call method 'isActive' (a nil value) stack traceback: [C]: in function 'isActive' [string "E:\Users\Gamer\AppData\Local\Temp\DCS\/~mis00001594"]:3196: in function 'group_alive_less_than' [string "E:\Users\Gamer\AppData\Local\Temp\DCS\/~mis00001A54"]:1769: in function <[string "E:\Users\Gamer\AppData\Local\Temp\DCS\/~mis00001A54"]:1608> Edited October 9, 2014 by =LFC=Chameleon_Silk
Grimes Posted October 9, 2014 Posted October 9, 2014 (edited) I accidentally used a Unit function that doesn't work with group objects. Will release a hotfix soon. You can replace "isActive" with "isExist" and it will fix the problem. https://github.com/mrSkortch/MissionScriptingTools/tree/development download the mist file from there. Edited October 9, 2014 by Grimes 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
LFCChameleon_Silk Posted October 10, 2014 Author Posted October 10, 2014 (edited) there was a problem with the MIST function or the SSE has changed. mist.flagFunc.group_alive_less_than_modified = function(vars) local type_tbl = { [{'group', 'groupname', 'gp', 'groupName'}] = 'string', percent = 'number', flag = {'number', 'string'}, stopflag = {'number', 'string', 'nil'}, interval = {'number', 'nil'}, toggle = {'boolean', 'nil'}, } local err, errmsg = mist.utils.typeCheck('mist.flagFunc.group_alive_less_than_modified', type_tbl, vars) assert(err, errmsg) local groupName = vars.groupName or vars.group or vars.gp or vars.Groupname local flag = vars.flag local percent = vars.percent local stopflag = vars.stopflag or -1 local interval = vars.interval or 1 local toggle = vars.toggle or nil if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then if Group.getByName(groupName) then if Group.getByName(groupName):getSize()/Group.getByName(groupName):getInitialSize() < percent/100 then if trigger.misc.getUserFlag(flag) == 0 then trigger.action.setUserFlag(flag, 1) end else if toggle then trigger.action.setUserFlag(flag, 0) end end else if trigger.misc.getUserFlag(flag) == 0 then trigger.action.setUserFlag(flag, 1) end end end if (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then mist.scheduleFunction(mist.flagFunc.group_alive_less_than_modified, {{groupName = groupName, flag = flag, stopflag = stopflag, interval = interval, toggle = toggle, percent = percent}}, timer.getTime() + interval) end end this is the modified function by me, hence why its called mist.flagFunc.group_alive_less_than_modified, it instead of true and false sets flag to 0 or 1, I find that easier to work with... this function has the isActive part removed and does work. so anyone trying to make the default function work... if you do please tell me how you did it! but for now I will use my modified version... maybe grimes can comment about this issue (and then give me back my 8 hours last night) I kid of course, MIST library is very helpful. EDIT: awesome glad to see the problem has been found and resolved, but I gotta wonder... am I the only one using these MIST functions surely someone must have had this problem in the past, also a heads up in the wiki you have units = when that is not accepted type, this is also in the documentation for MIST. Edited October 10, 2014 by =LFC=Chameleon_Silk
LFCChameleon_Silk Posted October 10, 2014 Author Posted October 10, 2014 yea grimes I'm actually watching that on github, as my mission/script is also on github now, I even referenced older versions of the same function in hopes that something changed to break it but they were all the same. thanks for the quick response.
LFCChameleon_Silk Posted October 15, 2014 Author Posted October 15, 2014 does this not work with a static object? if you want to mirror the ME trigger you should add support for statics to be counted.
Grimes Posted October 15, 2014 Posted October 15, 2014 Static objects, groups, and units have different functions available. It can be done it would just require me go in and make a separate if statement for statics. The thing is each static object is its own "group", so group_alive_less_than and group_dead would both return true under the same circumstances because only 1 object is being checked. 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
ESAc_matador Posted June 23, 2016 Posted June 23, 2016 (edited) hello all. What is wrong with this??? I am always finding the same problem... getName, getByName... I dont know!!! local redGroupFirstLine = {'rus101','rus102','rus103','rus104'} for k, v in pairs(redGroupFirstLine) do local _group = redGroupFirstLine[k] local _groupname = _group:getName() mist.flagFunc.group_alive_less_than { units = tostring(_groupname), flag = 3100, percent = 99, toggle = true, } if trigger.misc.getUserFlag(3100) == true then trigger.action.outText("yeahh!", 5) --mist.groupToRandomZone(_group), {'4','5','6'}) end end nothing happen... error message "attempting call a method for a nil value." EDIT: Ok, I did it this way...and works... now I see why.thanks anyway. local redGroupFirstLine = {'rus101','rus102','rus103','rus104'} local redGroupSecondLine = {'rus201','rus202','rus203','rus204'} local redGroupthirdLine = {'rus301','rus302','rus303','rus304'} for k, v in pairs(redGroupFirstLine) do local _group = v mist.flagFunc.group_alive_less_than { groupName = _group, flag = 3100, percent = 99, toggle = true, } if trigger.misc.getUserFlag(3100) == 1 then trigger.action.outText("yeahh!", 5) --mist.groupToRandomZone(_group), {'4','5','6'}) end end Edited June 23, 2016 by ESAc_matador
Recommended Posts