MikeSinn Posted February 28, 2016 Posted February 28, 2016 What is the easiest way to identify the name assigned to a newly cloned group? Using a mist.CloneInZone function, I have a simple script that randomly selects a group targets and creates a clone of that group in one several zones. This part of the script works fine. Now the tricky part I can't figure out... Once the cloned group has been created in the starting zone, I want to use the mist.groupToPoint function to have the new group move towards a location. The problem is that I don't know how to get the name for the newly cloned group. Any ideas or pointers on how to look up the name for the most recently created group in SSE or mist?
Steggles Posted February 29, 2016 Posted February 29, 2016 (edited) I can't test it at the moment. But I'm pretty sure if you call it on the right hand side of an assignment, the group info gets placed into the variable. local groupInfo = mist.CloneInZone() groupInfo["name"] -- this will be the name of the cloned group. groupInfo will contain the all group's information. Edited February 29, 2016 by Steggles 1 -16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com EWRS - Early Warning Radar Script Specs: Gigabyte Sniper Z5-S Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler 16GB RAM Gigabyte GTX 1080 TM Hotas Warthog: SN: 06976 Saitek Pro Flight Combat Rudder Pedals TrackIR5 with TrackClipPro & Oculus Rift 2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024
Ignition Posted February 29, 2016 Posted February 29, 2016 I've made the same question and Grimes told me this: ---------------------------------------- mist.cloneInZone() returns a string of the new groups name. If I remember correctly there was an issue with the game where you have to wait a short period of time before issuing an order to a newly spawned group. Basically it can't be assigned instantly, but like a 0.1 second delay is probably enough. The following is an example of how this might work... for i = 1, 10 do local newGroupName = mist.cloneInZone('myCloneGroup', 'zoneX') mist.scheduleFunction(mist.groupToRandomZone, {newGroupName, 'zoneWhatever'}, timer.getTime() + 1) end ------------------------------------------ But I tested it and it didn't work, I don't know what I did wrong. They clone ok but they don't move at all, the name of the zone was ok. I didn't try with mist.groupToPoint. If it works for you could you share the mission so I can see what I did wrong? thanks.
Steggles Posted February 29, 2016 Posted February 29, 2016 I've made the same question and Grimes told me this: ---------------------------------------- mist.cloneInZone() returns a string of the new groups name. If I remember correctly there was an issue with the game where you have to wait a short period of time before issuing an order to a newly spawned group. Basically it can't be assigned instantly, but like a 0.1 second delay is probably enough. The following is an example of how this might work... for i = 1, 10 do local newGroupName = mist.cloneInZone('myCloneGroup', 'zoneX') mist.scheduleFunction(mist.groupToRandomZone, {newGroupName, 'zoneWhatever'}, timer.getTime() + 1) end ------------------------------------------ But I tested it and it didn't work, I don't know what I did wrong. They clone ok but they don't move at all, the name of the zone was ok. I didn't try with mist.groupToPoint. If it works for you could you share the mission so I can see what I did wrong? thanks. The wiki says it returns a string too. In the script I'm working on ATM, I'm not using cloneInZone but using cloneGroup, which apparently returns a string too, but cloneGroup returns a table and the only way I can access the cloned group's name is how I've mentioned above. Looking at the call stack in MIST atm, it does return a table. -16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com EWRS - Early Warning Radar Script Specs: Gigabyte Sniper Z5-S Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler 16GB RAM Gigabyte GTX 1080 TM Hotas Warthog: SN: 06976 Saitek Pro Flight Combat Rudder Pedals TrackIR5 with TrackClipPro & Oculus Rift 2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024
MikeSinn Posted February 29, 2016 Author Posted February 29, 2016 Steggles, Ignition Thank you both for the input and ideas. I did not realize that the Cloneinzone function would pass back the name of the newly created group. Capturing that in a variable should do the trick. <Famous last words...> I wont have a chance to test for a couple of days but will share my script and any success or failures then.
Ignition Posted February 29, 2016 Posted February 29, 2016 Yes the trick was ["name"] Now its working with the code provided by Grimes and Steggles. Thank you very much.
MikeSinn Posted March 5, 2016 Author Posted March 5, 2016 I finally had a chance to try out the suggestions provided in this thread and developed the following simple script to clone a single group (designed eventually to select one of several random groups) and order the group to move towards a zone. local tgt = 'tgt_mov_hard' local tgt_zone = 'mov_zone' local adv_zone = 'adv_zone' local tgtChoice = mist.random(1) local zoneChoice = mist.random(2) tgt = tgt..tgtChoice tgt_zone = tgt_zone..zoneChoice trigger.action.outText(tgt,10) trigger.action.outText(tgt_zone,10) local NewGroup = mist.cloneInZone(tgt,tgt_zone) local NewGroupName = NewGroup["name"] trigger.action.outText(NewGroupName,10) mist.scheduleFunction(mist.groupToPoint,{NewGroupName, adv_zone, 'Diamond', nil, 15}, timer.getTime() + 1) The script is triggered by a F10 radio option and executes without an error. The target group is cloned and placed in the starting zone. However, the final command, "mist.groupToPoint" never seems to execute. The group just sits there forever or until I run out of patience and blow them up :music_whistling: Can anyone see the logic or process error in the script. I have also attached a copy of the scenario file for reference. It is still very incomplete but the radio function to create the cloned group does work. To test, select the A10C client, select F10 then F5. Any insight or thoughts on how to get them to move forward is appreciated.test.miz
Steggles Posted March 5, 2016 Posted March 5, 2016 (edited) Try setting formation etc in a separate command, and use mist.goRoute(). I can't give exact examples, but I've run into trouble trying to do things at once and found I've had better success when assigning things separately when it comes to group's routes, formations etc. EDIT: Try using tostring() when adding the number onto the end of the string. I've run into troubles with LUA and its auto assign variable types when doing stuff like that. EDIT2: Try naming the arguments sent to the function. I haven't used groupToPoint in MIST before. Like in the Valid Inputs types in here: http://wiki.hoggit.us/view/GroupToPoint. I'm not in a position to test the mission atm, or I would get it working for you. Name each one: {group = NewGroupName, table = advZone, form = 'Diamond'} etc... For all your arguments you want to send. Pretty sure this will be your problem. EDIT3: This is the error, from the groupToPoint function. I can't figure out why its coming up. I've tried a few different approaches... mist.scheduleFunction, error in scheduled function: [string "C:\**\**\**\DCS\/~mis0000249C"]:3937: attempt to index local 'point' (a nil value) Edited March 5, 2016 by Steggles -16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com EWRS - Early Warning Radar Script Specs: Gigabyte Sniper Z5-S Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler 16GB RAM Gigabyte GTX 1080 TM Hotas Warthog: SN: 06976 Saitek Pro Flight Combat Rudder Pedals TrackIR5 with TrackClipPro & Oculus Rift 2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024
MikeSinn Posted March 5, 2016 Author Posted March 5, 2016 Try setting formation etc in a separate command, and use mist.goRoute(). I can't give exact examples, but I've run into trouble trying to do things at once and found I've had better success when assigning things separately when it comes to group's routes, formations etc. EDIT: Try using tostring() when adding the number onto the end of the string. I've run into troubles with LUA and its auto assign variable types when doing stuff like that. EDIT2: Try naming the arguments sent to the function. I haven't used groupToPoint in MIST before. Like in the Valid Inputs types in here: http://wiki.hoggit.us/view/GroupToPoint. I'm not in a position to test the mission atm, or I would get it working for you. Name each one: {group = NewGroupName, table = advZone, form = 'Diamond'} etc... For all your arguments you want to send. Pretty sure this will be your problem. EDIT3: This is the error, from the groupToPoint function. I can't figure out why its coming up. I've tried a few different approaches... mist.scheduleFunction, error in scheduled function: [string "C:\**\**\**\DCS\/~mis0000249C"]:3937: attempt to index local 'point' (a nil value) Steggles, thanks for the quick reply and suggestions. I will try your idea in EDIT 2 now. It is odd that I do not get any error message when running the mist.scheduleFunction currently. For reference, I am using Mist 4.41 (I think the most current version). I had an issue originally with the clonetozone function when using an early version of MIST.
Quax456 Posted March 5, 2016 Posted March 5, 2016 Try setting formation etc in a separate command, and use mist.goRoute(). I can't give exact examples, but I've run into trouble trying to do things at once and found I've had better success when assigning things separately when it comes to group's routes, formations etc. EDIT: Try using tostring() when adding the number onto the end of the string. I've run into troubles with LUA and its auto assign variable types when doing stuff like that. EDIT2: Try naming the arguments sent to the function. I haven't used groupToPoint in MIST before. Like in the Valid Inputs types in here: http://wiki.hoggit.us/view/GroupToPoint. I'm not in a position to test the mission atm, or I would get it working for you. Name each one: {group = NewGroupName, table = advZone, form = 'Diamond'} etc... For all your arguments you want to send. Pretty sure this will be your problem. EDIT3: This is the error, from the groupToPoint function. I can't figure out why its coming up. I've tried a few different approaches... mist.scheduleFunction, error in scheduled function: [string "C:\**\**\**\DCS\/~mis0000249C"]:3937: attempt to index local 'point' (a nil value) Dear Steegles, Mist.scheduleFuction(function, {}, timer.getTime(), repeat) Take a closer look to the table brackets. The options mist be a table format! And use getPosition().p instead of getPoint. getPoint seema to be bugged. My Rig: Windows 11 Pro, Intel i7-13700k@5.4GHz, 64GB DDR5 5200 RAM, Gigabyte Z790 AORUS Elite AX, 2TB Samsung 990 PRO, RTX4080, Thrustmaster HOTAS WARTHOG Stick + WINWING ORION 2 + MFG Crosswinds, LG 32" 4K 60FPS, ACER 30" 4K 60FPS GSync Display, HP Reverb G2 V2
Ignition Posted March 6, 2016 Posted March 6, 2016 I finally had a chance to try out the suggestions provided in this thread and developed the following simple script to clone a single group (designed eventually to select one of several random groups) and order the group to move towards a zone. The script is triggered by a F10 radio option and executes without an error. The target group is cloned and placed in the starting zone. However, the final command, "mist.groupToPoint" never seems to execute. The group just sits there forever or until I run out of patience and blow them up :music_whistling: Can anyone see the logic or process error in the script. I have also attached a copy of the scenario file for reference. It is still very incomplete but the radio function to create the cloned group does work. To test, select the A10C client, select F10 then F5. Any insight or thoughts on how to get them to move forward is appreciated. Didn't check with full detail because its really late but I saw in your post mist.scheduleFunction(mist.groupToPoint,{NewGroupN ame, adv_zone, 'Diamond', nil, 15}, timer.getTime() + 1) It has a space in the middle
Quax456 Posted March 6, 2016 Posted March 6, 2016 (edited) Right now I propably have the error.... When you are using mist.groupToPoint try to provide it as table.... {Adv_zone} Edited March 6, 2016 by Quax456 My Rig: Windows 11 Pro, Intel i7-13700k@5.4GHz, 64GB DDR5 5200 RAM, Gigabyte Z790 AORUS Elite AX, 2TB Samsung 990 PRO, RTX4080, Thrustmaster HOTAS WARTHOG Stick + WINWING ORION 2 + MFG Crosswinds, LG 32" 4K 60FPS, ACER 30" 4K 60FPS GSync Display, HP Reverb G2 V2
MikeSinn Posted March 6, 2016 Author Posted March 6, 2016 (edited) Success finally! MY THANKS TO ALL THAT HELPED EDUCATE ME ALONG THE WAY :thumbup: I could not get the mist.schedulefunction to work correctly but by breaking the Clone action and move order action into separate scripts in the same trigger, I got everything to work. Below is a copy of the two scripts I used in the same trigger: --first script to create clone local tgt = 'tgt_mov_hard' local tgt_zone = 'mov_zone' local adv_zone = 'adv_zone' local tgtChoice = mist.random(4) local zoneChoice = mist.random(3) tgt = tgt..tgtChoice tgt_zone = tgt_zone..zoneChoice trigger.action.outText(tgt,10) trigger.action.outText(tgt_zone,10) NewGroup = mist.cloneInZone(tgt,tgt_zone) NewGroupName = NewGroup["name"] trigger.action.outText(NewGroupName,10) --second script to begin move trigger.action.outText('Begin assualt' ,10) trigger.action.outText(NewGroupName, 10) mist.groupToPoint(NewGroupName, 'adv_zone', 'Diamond', nil, 15, 0) Right now I have a bunch of OutText commands in the script just to follow variable assignment and testing. I have no doubt this is not the most efficient solution but it is functional. The script basically selects 1 of 4 possible groups and 1 of 3 possible starting zones. Makes a copy of the group and orders them to begin moving forward to attack a zone. Attached is a copy of the mission as well. WARNING, the mission is by no means complete nor meant for anything other than my learning but thought others could benefit from seeing this. EDIT: Replaced the Test_1.miz with an updated version as the previous one had an error preventing the F10 radio menus from working :doh:test_1.miz Edited March 6, 2016 by MikeSinn
Recommended Posts