MIssion Scripting Tools (Mist)- enhancing mission scripting Lua - Page 135 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 01-22-2018, 12:20 PM   #1341
Zarma
Member
 
Join Date: Oct 2014
Location: Switzerland
Posts: 797
Default

Quote:
Originally Posted by Johnny_Rico View Post
DCS engine only has facilities to read fuel status, sadly you cannot write values
Damn !

Thx.
__________________
i7 6700k, 16 Go RAM, GTX 1080, Warthog HOTAS Throttle & Stick, Saitek Combat Rudder, (MFD Cougar) (Trackir 5 Pro) Oculus Rift CV1

http://www.twitch.tv/zarma4074 / https://www.youtube.com/user/Zarma4074
Zarma is offline   Reply With Quote
Old 02-17-2018, 06:16 PM   #1342
shnicklefritz
Junior Member
 
Join Date: Feb 2018
Posts: 8
Default MIst units in zone flag function

Any help is appreciated, my apologies if this is not the appropriate thread.
I'm trying to accomplish: When Troops dropped via CTLD are in zone, flag is set to true. This works fine with ME units active or late activated however, when "Dropped Group #" is in zone, nothing is returned. Can anyone please advise, I would appreciate it greatly.

Thank you.

blueZoneUnits = mist.makeUnitTable({'[blue][vehicles]'})

trainStation1 =
{
units = blueZoneUnits,
zones = {"9_TrainStation1"},
flag = 901,
zone_type = "sphere",
req_num = 1,
interval = 5,
toggle = false,
unitTableDef = blueZoneUnits,
}

mist.flagFunc.units_in_zones(trainStation1)
shnicklefritz is offline   Reply With Quote
Old 02-17-2018, 06:31 PM   #1343
ESAc_matador
Senior Member
 
Join Date: Aug 2007
Posts: 1,524
Default

Most probably because the list of units with makeunittable only takes the initial units. Dropped, spawned, cloned units, can have the same name, but different ID.

Unless you redo the list after dropping units it won't work.

You can make a loop repeating the script every minute to ensure it takes into account all units
ESAc_matador is offline   Reply With Quote
Old 02-18-2018, 09:00 AM   #1344
Vatikus
Member
 
Join Date: Aug 2016
Location: Slovenia
Posts: 355
Default

mist.groupToRandomZone and others in this group of functions do not have parameter to set if AI should use roads or not.
Wiki page does not reflect what is in code! Code should be fixed asap ...
Vatikus is offline   Reply With Quote
Old 02-19-2018, 08:09 PM   #1345
Scatoogle
Junior Member
 
Join Date: Feb 2018
Posts: 2
Default

Hopefully someone smarter than me can tell me why I am getting this error?



Here is the script:

Quote:
local grpTemplate = {
units = Group.getByName("Insurgent BTR-80"):getUnits(),
country = 17,
category = "GROUND_UNIT",
groupName = nil,
groupId = nil,
clone = true,
route = nil
}

mist.dynAdd(grpTemplate)
Scatoogle is offline   Reply With Quote
Old 02-19-2018, 10:49 PM   #1346
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,415
Default

Group.getByName("Insurgent BTR-80"):getUnits() returns a group of unit objects, its not in the same format that mist.dynAdd() is expecting for the units table.

You can just grab the data directly from mist.DBs, for example:
Code:
units = mist.DBs.groupsByName["Insurgent BTR-80"].units
More specifically you can just add the clone value to a table that is grabbed from the DB itself, for example:
Code:
local grpTemplate = mist.getGroupData("Insurgent BTR-80")
grpTemplate.clone = true
mist.dynAdd(grpTemplate)


Quote:
Originally Posted by Vatikus View Post
mist.groupToRandomZone and others in this group of functions do not have parameter to set if AI should use roads or not.
Wiki page does not reflect what is in code! Code should be fixed asap ...
It automatically forces roads if the group is more than 1.3x the radius of the zone away from the center. If you want more control over it just feed the data you want into mist.groupToRandomPoint()
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 02-20-2018, 10:35 PM   #1347
maverickturner
Junior Member
 
Join Date: Jul 2016
Posts: 20
Default

I'm having a hard time trying to figure out a simple script with MIST. I'm looking to simply set a Flag value if a player destroys another player
Code:
(RED team killed member of BLUE), set flag 7001,1
Can anyone help me with this? I've been searching most of the day and can't seem to figure it out in my rookie stages. Apologies if this isn't the appropriate thread.

Last edited by maverickturner; 02-21-2018 at 07:11 PM. Reason: thread / not threat
maverickturner is offline   Reply With Quote
Old 02-21-2018, 07:18 AM   #1348
Grimes
ED Testers Team
 
Grimes's Avatar
 
Join Date: Jan 2006
Location: Black Mesa
Posts: 7,415
Default

You have to use an event handler. A really basic example could be something like...

Code:
local lastHit = {}
local function score(event)
    if event.id ==  world.event.S_EVENT_HIT then
        if event.target and mist.DBs.humansByName[Unit.getName(event.target)] then
            if event.initiator and mist.DBs.humansByName[Unit.getName(event.initiator)] then
                lastHit[Unit.getName(event.target)] = Unit.getName(event.initiator)
            end
        end
    elseif  event.id ==  world.event.S_EVENT_DEAD then
        if event.initiator and mist.DBs.humansByName[Unit.getName(event.initiator)] and lastHit[Unit.getName(event.initiator)] then 
            if mist.DBs.humansByName[Unit.getName(event.initiator)].coalition == 'red' then
                trigger.action.setUserFlag(7001, 1)
            else
            
            end
        end
    end
end
mist.addEventHandler(score)
__________________
You can only tie the world record for lowest flight.
Current Projects: Scripting Wiki, Something...
Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD for DCS 1.5/2.0, IADScript, Mission Editing Wiki!, Mission Building Forum
Grimes is offline   Reply With Quote
Old 02-21-2018, 07:12 PM   #1349
maverickturner
Junior Member
 
Join Date: Jul 2016
Posts: 20
Default

Quote:
Originally Posted by Grimes View Post
You have to use an event handler. A really basic example could be something like...

Code:
local lastHit = {}
local function score(event)
    if event.id ==  world.event.S_EVENT_HIT then
        if event.target and mist.DBs.humansByName[Unit.getName(event.target)] then
            if event.initiator and mist.DBs.humansByName[Unit.getName(event.initiator)] then
                lastHit[Unit.getName(event.target)] = Unit.getName(event.initiator)
            end
        end
    elseif  event.id ==  world.event.S_EVENT_DEAD then
        if event.initiator and mist.DBs.humansByName[Unit.getName(event.initiator)] and lastHit[Unit.getName(event.initiator)] then 
            if mist.DBs.humansByName[Unit.getName(event.initiator)].coalition == 'red' then
                trigger.action.setUserFlag(7001, 1)
            else
            
            end
        end
    end
end
mist.addEventHandler(score)


Grimes, this is absolutely perfect. Just what I was looking for. I'll test it out when I get home today. Thanks for the help!
maverickturner is offline   Reply With Quote
Old 02-21-2018, 09:12 PM   #1350
maverickturner
Junior Member
 
Join Date: Jul 2016
Posts: 20
Default

Quote:
Originally Posted by Grimes View Post
You have to use an event handler. A really basic example could be something like...
To use this code in conjunction with say CTLD, would I identify the medical helos like this:

Code:
if event.target == ctld.transportPilotNames and mist.DBs.humansByName...
I'm getting the overall idea but missing something due to my lack of experience with .lua.
maverickturner is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 09:55 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.