pakfront Posted May 8, 2013 Posted May 8, 2013 The addGroup function takes an argument 'data' that is quite cumbersome to define. http://forums.eagle.ru/showpost.php?p=1738368&postcount=2 Is it possible to get this table from an existing group via scripting? How would you increment the unique ids to prevent id collisions, assuming this is needed? Am asking because I imagine it would be much easier to define the group in 'data' in the ME as deactivated group, sort of like a template, then use addGroup to spawn a copy of it at one or more various locations. If so, it seems that a wrapper function could be written that would make spawning groups much easier. Or is this already possible by serializing a group as in the 'data' table format from the ME in some way? Thanks.
pakfront Posted May 8, 2013 Author Posted May 8, 2013 Ah, looking through the contents of the mission .miz file, it appears that the 'data' field is actually just a group object, which is great. Am I correct? Then the only outstanding issue is how to assign unique IDs?
Grimes Posted May 8, 2013 Posted May 8, 2013 Yes the groupData table needs to basically match what is in the miz. The route and spans data is not used if I recall. Unique names and unique Ids are a different matter. I'm working on a function for Mist that can create em if needed taking into account other existing group and unit Ids. 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
pakfront Posted May 10, 2013 Author Posted May 10, 2013 I'm not that familiar with lua, so I may be making a rookie mistake, but it seems but it seems that simply doing a Group.getByName(), trying to alter the result, then passing it to addGroup does not work. thre result of getByName is immutable or protected somehow, probably to prevent modification at runtime. local data = Group.getByName('ToSpawn01') data.name = 'AfterSpawn' -- this is not allowed and throws a runtime error coalition.addGroup(country.id.USA, Group.Category.GROUND, data)I tried using a simple deepcopy function to recreate the object as a table, but my limited knowledge of lua made that a waste of time. I think what has to happen is something like: newdata = deepcopy(Group.getByName('ToSpawn01')) as an aside, is this the 'lua'way to adjust the positions of the units in the new data or should I be using some other type of iterator? for unit in data.units do unit['x'] = pos.x + math.random(-8, 8 ) unit['y'] = pos.z + math.random(-8, 8 ) end
Grimes Posted May 10, 2013 Posted May 10, 2013 The final entry for the addGroup() function doesn't match the same format as the Group class that is created by Group.getByName(). The correct format is what is found in the mission editor and in that first link of the post. You can use Group.getByName() and the corresponding group class functions to get some of the data, but its not the table that addGroup accepts. 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
pakfront Posted May 10, 2013 Author Posted May 10, 2013 Ah, thanks. I'll try to write a function that can map the Group object into the table that addGroup wants, along with a translation Vec2 to allow repositioning of the group. If I can get it working, would you considering adding it to MIst?
Grimes Posted May 10, 2013 Posted May 10, 2013 Ah, thanks. I'll try to write a function that can map the Group object into the table that addGroup wants, along with a translation Vec2 to allow repositioning of the group. If I can get it working, would you considering adding it to MIst? Like I said in the 3rd post of this thread, I am working on functions that deal with respawning, teleporting, etc for Mist. However if your function doesn't match something I've already made, it might prove useful to be added. 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
Puddlemonkey Posted May 12, 2013 Posted May 12, 2013 if you want to use lua to achieve the same as as late activate and group activate trigger, would you use late activation and coalition.addGroup?
Grimes Posted May 12, 2013 Posted May 12, 2013 I'm not sure what the exact parameters are that make up the "late activation" feature, but I'd imagine you could just set a time that won't likely be reached via an entry like ["start_time"] = 10000000000 and then using Group.getByName(groupName'):Activate() when you want em to start. Alternatively you can just create the group when you want it to activate. For some reason Group.Activate() doesn't seem to be documented... 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
Puddlemonkey Posted May 12, 2013 Posted May 12, 2013 ah yes, I didn't realise Group.Activate existed! Thanks.
Recommended Posts