Jump to content

ajax

Members
  • Posts

    491
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ajax

  1. I wouldn't say it was a game breaker, but it certainly is annoying and aggravating to no end.
  2. "Mine is not to reason why..." This code builds a function on-the-fly with a programmatically generated name: [font=Courier New]-- build the name local i = 1 local fname = "BlueHandler"..i -- define function as string, making substitutions into string local funcStr = fname..[[ = function(txt) ]]..[[ env.info("function name = ]]..fname..[[ passed text = "..txt) end ]] f = loadstring(funcStr) f() if f then env.info("f is loaded") _G[fname]("called function") -- call the new function else env.info("f did not load") end [/font]Tested in DCS -- works fine. DCS.log output: [font=Courier New]03150.082 INFO SCRIPTING: f is loaded 03150.082 INFO SCRIPTING: function name = BlueHandler1 passed text = called function[/font] Here is a test mission with the script. Edit: Added a little bit more to prove it accepts "BlueHandler1": Inserted this line: [font=Courier New]if f then env.info("f is loaded") _G[fname]("called function") [color=Red] _G["BlueHandler1"]("part 2")[/color] else env.info("not f") end [/font]Log output: [font=Courier New]06016.399 INFO SCRIPTING: f is loaded 06016.399 INFO SCRIPTING: function name = BlueHandler1 passed text = called function 06016.399 INFO SCRIPTING: function name = BlueHandler1 passed text = part 2 [/font]Edit2: The f() statement should be moved into the if block. And additional error checking should be done. [font=Courier New]f = loadstring(funcStr) if f then [/font][font=Courier New][font=Courier New][color=Red]f()[/color] [/font] env.info("f is loaded") _G[fname]("called function") -- call the new function else env.info("f did not load") end [/font] dynFunctionNameTest.miz
  3. I understand what you are trying to do, but every event handler you create will receive every, all, and the same events. You don't get to choose that this event handler only receives events from say UnitA and that event handler from UnitB.
  4. These functions are available. Used in combination they can determine group life. i.e. [count of Group.getUnits()]/Group.getSize() * 100 = % alive You could also refine the result by checking the life of each remaining unit. i.e. (Ʃ[unit.getLife()])/(Ʃ[unit.getLife0()] * 100 = avg %life remaining Edit: The above equation only works if all units have the same initial life, which isn't the case. So use this one instead: Ʃ[unit.getLife()/Unit.getLife0()]/n * 100 = avg %life So then for the group: "group health" = (% alive) * (avg %life remaining) The question is: How do you determine how many enemy units the scout "sees"? You could use a probabilistic approach: Assume time spent in zone increases probability of observing every unit. Calculate the result based on time in zone. Would have to think about the math more.
  5. So the Slmod errors are back. The '-- world event hook' phrase is in Slmod's event Lua file (can't remember the exact name). I spent considerable time last night trying to find the 'getPlayerName' function in the Slmod source files, but no luck. I'll look some more tonight.
  6. Also, I don't think event handlers work that way. They are event driven not polling functions.
  7. Wouldn't all the functions used for the various event handlers have to have already been defined before you assign them as event handlers? That is: function BlueHandler1(eventdata) ... end function BlueHandler2(eventdata) ... end etc. must be defined before world.addEventHandler(BlueHandler1) world.addEventHandler(BlueHandler2) etc. It seems to me that you need a single event handler that incorporates a "dispatcher" of sorts that initiates a coroutine or schedules another function to actually do the "tasks". Now, my knowledge of coroutine usage is next to nothing, but from what I've read it might be more suited for what your trying to do.
  8. Okay, good. It looks like the all the Mist and Slmod errors went away. Now I guess the next thing to try is to let the mission run for a while and see if it crashes again.
  9. ajax

    MIST or CTTS

    You guys are quick!!:)
  10. ajax

    MIST or CTTS

    Eno, the Mist file you posted is missing some lines of the fix. The fixed Mist file is attached for anyone who wants it. I'm reluctant to upload CTTS with the fix because there seem to be many versions of it around. If you use a different or modified version it is up to you to find lines 758 and 759 in the attached file and copy them exactly to the corresponding two lines in your version. Furthermore, this fix is only provided as a stop-gap measure to make the script work again. I have no idea what the author's original intention was. This fix will only find the nearest ground enemies. The original would have found the nearest enemy of any type. Does it make a difference? I don't know. Mistv3_3a.zip CTTS_Original_Fixed.zip
  11. ajax

    MIST or CTTS

    I believe so. FubarBundy reports that his mission (with the fixes) is now working fine.
  12. ajax

    MIST or CTTS

    I tried to edit my last post but deleted it instead.:doh: Edit: Sheesh. Can't do anything right. I was going to add that Groups thing too but saw you already took care of it.
  13. ajax

    MIST or CTTS

    I see the problem already. You used Group.Categories.GROUND it should be Group.Category.GROUND in the CTTS file. My fault. My initial fix post had it wrong but later corrected.
  14. If just want a list, there is one posted in the Mission Builders forum. I'd post a direct link but I can't figure out how to do that on my phone. I believe it is on page three. Edit: Link to thread http://forums.eagle.ru/showthread.php?t=124389
  15. ajax

    MIST or CTTS

    First, make sure you modify both Mist and CTTS. Otherwise the fixes won't work. I will post the files later. Can't do it from work. (If you want the Mist file it is already posted in another forum section. DCS World/bugs and problems/game crashes then look for Eno's latest post. I think this path is right but I'm not sure.)
  16. Yes, it's the same. No other changes. My intent here is to try to get rid of the Mist errors first. Then see if you still get slmod errors.
  17. Eno, I noticed the log files are riddled with Mist and Slmod errors. If you don't mind, humor me and try this version of Mist with one of these missions. Run it for a few minutes and repost the dcs.log file. Mistv3_3a.lua
  18. I use the S_EVENT_BIRTH event in my TroopDrop script to ensure that any transport helicopter that enters the sim starts without any troops loaded. (This will happen if a previous client loads troops then gets killed or leaves the game.) In the event handler I iterate through a Lua table that contains the names of "active" transport helicopters, that is those that supposedly have troops loaded. If the unit that triggered the S_EVENT_BIRTH event is in that table then I wipe out that entry. I suppose I could make it more efficient by immediately testing if the unit is a transport helicopter, but I haven't found that to be necessary.
  19. Mission with test scripts is attached. Note: To test the return value from coalition.addGroup() you must enter the sim on the RED side and spawn an OPFOR group using the F10 radio commands. F10-Other... -----> F1-OPFOR Menu... ------------> F2-Spawn There is one group of each category for each side in the mission. (Plus the client aircraft.) Only one RED client aircraft is defined (Ka-50). Another RED airframe can be added if preferred. The included scripts write to the DCS.log file. The following shows the expected output: -- output from coalition.getGroups() 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: SHIP pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: SHIP Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: SHIP Group[1] = Red AI Ship Rezky has 2 units. 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: GROUND pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: GROUND Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: GROUND Group[1] = Red AI Ground SA-13 has 4 units. 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: HELICOPTER pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: HELICOPTER Groups: 2 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: HELICOPTER Bad Group: 1 Group doesn't exist 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: HELICOPTER Bad Group: 2 Group doesn't exist 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: AIRPLANE pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: AIRPLANE Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: RED Category: AIRPLANE Bad Group: 1 Group doesn't exist 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: SHIP pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: SHIP Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: SHIP Group[1] = Blue AI Ship Normandy has 2 units. 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: GROUND pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: GROUND Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: GROUND Group[1] = Blue AI Ground Vulcan has 4 units. 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: HELICOPTER pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: HELICOPTER Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: HELICOPTER Bad Group: 1 Group doesn't exist 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: AIRPLANE pcall Success: true 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: AIRPLANE Groups: 1 02960.277 INFO SCRIPTING: Time: 47.401 Side: BLUE Category: AIRPLANE Bad Group: 1 Group doesn't exist -- output from coalition.addGroup() 02961.505 INFO SCRIPTING: Red Client Helo Ka-50 (aj) spawned OPFOR. 02961.505 INFO SCRIPTING: coalition.addGroup() return value is invalid SSE Bug Test Mission.miz
  20. Will do as soon as I get home from work.
  21. Disclaimer: The following is just my opinion and I will only say it once then shut up.:) How can this bug even remotely compare in importance to fixing the problem where the Ka-50's Doppler or HUD systems cannot be repaired, a bug introduced in one of the Black Shark 2 updates--over two years ago?
  22. I'm always on the look-out for new ways to do things, too. That's why your question intrigued me. To send status messages when a client joins using mostly ME functions, I would: 1. Define and initialize a flag for each client slot in the mission (using a mission start trigger). 2. Create an event handler in a script that sets the appropriate flag whenever a client enters the sim. 3. Create a switched condition trigger for each client using the flag as the condition. 4. If flag is set send status message to that client and then reset the flag. Just thinking out loud, here. I'm sure there are multiple ways of doing this.
  23. What do you have in mind, Eno? I don't think you will be successful trying to capture an event in a Lua predicate simply because the event can fire at any time whereas each trigger condition is checked only once per second (I think). At any rate, there is no guarantee the trigger condition will be checked at the exact same moment that the event fires. You could use an event handler to set various flags which are easily checked using ME trigger functions. Alternatively, the event handler can set various global script variables which can then be read by Lua predicate.
  24. Users of the CTTS (Complete Transport Script) have reported problems since 1.2.8. See http://forums.eagle.ru/showthread.php?t=123987 and http://forums.eagle.ru/showthread.php?t=108523&page=21 . In my opinion its problems are the direct result of the scripting-engine bug already reported. If the temporary fix to CTTS is not used the error will propagate and eventually raise errors in Mist. So you may see references to problems with Mist, which may or may not have anything to do with the scripting engine. In fact, it appears Mist has problems unrelated to the scripting engine, which are not ED Development issues. See http://forums.eagle.ru/showpost.php?p=2066139&postcount=528.
  25. I don't want to belabor the point, but just for clarification, did you report both problematic scripting-engine functions? Function 1 coalition.getGroups() Problem: This function (using the listed arguments) does not return a table of valid group references as it should. [font=Courier New] coalition.getGroups([i] any_side[/i], Groups.Category.AIRPLANE ) coalition.getGroups([/font][font=Courier New][font=Courier New][i] any_side[/i][/font], Groups.Category.HELICOPTER ) coalition.getGroups([/font][font=Courier New][font=Courier New][i] any_side[/i][/font], nil ) [/font] Function 2 coalition.addGroup() Problem: This function (using the listed arguments) does not return a reference to the newly created group as it should. (It does add the group.) [font=Courier New]-- tested and problem confirmed coalition.addGroup( [i]any_country_ID,[/i] Group.Category.AIRPLANE[i], any_group_data ) [/i]-- unconfirmed [/font][font=Courier New]coalition.addGroup( [i]any_country_ID,[/i] Group.Category.HELICOPTER[i], any_group_data )[/i][/font][font=Courier New] [/font]
×
×
  • Create New...