mrskortch / missionscriptingtools Goto Github PK
View Code? Open in Web Editor NEWMission Scripting Tools for Digital Combat Simulator
License: GNU General Public License v3.0
Mission Scripting Tools for Digital Combat Simulator
License: GNU General Public License v3.0
mist.getNextUnitId() keeps giving me the number "14000" over and over, I did a quick and dirty replacement by putting in math.random(100000000,200000000) for _unitId in CTLD and it worked.
What was happening is I was spawning crates. and everytime I respawn the same crate the previous one dissappeared, this is due to the ID being the same number
Mist mult-sound but for radio transmissions.
mist_4_4_90.lua"]:2652: attempt to call method 'isActive' (a nil value)
mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'Alpha_Zone'})
As in title, Tarrain instead of Terrain :
local validTerrain = {'LAND', 'ROAD', 'SHALLOW_WATER', 'WATER', 'RUNWAY'}
if vars.anyTarrain then
-- do nothing
The getLeadPos
does some error-checking to make sure that the group lead exists. If a group lead doesn't exist, the function returns a nil value and functions like groupToRandomPoint
will fail.
For some reason, getUnits
of a DCSGroup instance might in some rare cases return a list of units that are actually "non-existing"/destroyed, which will make groupToRandomPoint
throw an error. This happened very frequently when group units were killed off (so the list of group units should be empty) in my mission until I figured out I have to double-check that the group actually has existing units before calling groupToRandomZone
.
I suggest to add a condition to functions invoking getLeadPos
to check the returned value.
Here are more details, I used the two latest versions of MIST, can't get it to work.
Was working a long time (it's a CSAR POW Mod for DCS that I added using MIST)
Line that Errors out:
POW1MARKER.pos = Unit.getByName("NameOfUnit"):getPoint() -- This is the line that errored out, used to work
or
POW1MARKER.pos = Group.getByName("NameOfUnit"):getPoint() -- This is the line that errored out, used to work
I narrowed my error to this last line above either of the two.
Error from dcs.log:
2022-08-14 04:56:46.250 ERROR SCRIPTING: Error while handling event [string "C:\Users\username\AppData\Local\Temp\DCS.openbeta/~mis00003EE0.lua"]:1060: attempt to index a nil value
Full Code Sample:
----create a orange marker for POW when released!
local myLog = mist.Logger:new('PRISONLOG')
POW1MARKER = {} ---this table is instantiated at the top of the code
csar.enableCSAROrangeCircles = True
csar.enableCSARForVIP = True
if csar.enableCSAROrangeCircles then
if csar.enableCSARForVIP then
myLog:msg("D1")
POW1MARKER.pos = Unit.getByName("POW1"):getPoint() -- this is the line that errors out, worked b4
--POW1MARKER.pos = _unit.getByName("POW1"):getPoint() -- tried this as well, doesn't work
--POW1MARKER.pos = _unit:getByName("POW1"):getPoint() -- tried this as well, doesn't work
--POW1MARKER.pos = Group.getByName("POW1"):getPoint() -- tried this as well, doesn't work
myLog:msg("D2")
POW1MARKER.id = mist.marker.getNextId()
myLog:msg("D3")
POW1MARKER.mType = 0
myLog:msg("D4")
POW1MARKER.readOnly = 0
myLog:msg("D5")
POW1MARKER.text = "POW1 Located Here!"
myLog:msg("D6")
mist.marker.add(POW1MARKER)
myLog:msg("D7")
POW1MARK_check = "YES"
myLog:msg("D8")
POW1DEAD_check = "YES"
myLog:msg("D9")
end
end
myLog:msg("E")
dcs.log file messages:
2022-08-14 04:56:46.250 INFO SCRIPTING: PRISONLOG|1056: D1
2022-08-14 04:56:46.250 ERROR SCRIPTING: Error while handling event [string "C:\Users\username\AppData\Local\Temp\DCS.openbeta/~mis00003EE0.lua"]:1060: attempt to index a nil value
In https://github.com/mrSkortch/MissionScriptingTools/blob/master/mist.lua#L6530, shouldn't it be:
vars.disableRoads = not useRoads
rather than:
vars.disableRoads = useRoads
?
Respawning a unit to regain full ammunition for AAA firing at a point using the "fire at point" advanced waypoint option is useless at the moment.
per the changelog and the hoggit wiki, it looks like respawn should return a string of the group name, instead when I try to use I get a "attempt to concatenate local 'newGroup' (a table value)
Hi, I'm having some issues with getUnitsInZones. It's returning a table with different format than expected or documented (as best I can make out from the documentation).
I have a simple mission with a few named units. Upon execution and evaluation of the debug output I'm seeing the following:
mist.makeUnitTable({'[blue][vehicle]'})
is returning: { [1] = FARP 1 BLUE VEH 1,[2] = FARP 1 BLUE VEH 2,[3] = FARP 1 BLUE VEH 3,[4] = FARP A RED VEH 1-1-1,[5] = FARP 1 RED VEH 1-1-1,[6] = FARP 1 BLUE VEH 4,["processed"] = 1.801,}
which seems to make sense - apart from the last value, which I can live with.
However:
mist.getUnitsInZones(mist.makeUnitTable({'[blue][vehicle]'}), zone_names)
is returning: { [1] = { ["id_"] = 16779264,} ,[2] = { ["id_"] = 16780032,} ,[3] = { ["id_"] = 16780288,} ,[4] = { ["id_"] = 16780544,} ,}
I can't see anything obviously wrong with my code, albeit I'm fairly new to Lua and finding it somewhat obnoxious to work with. Could be it an issue with the function returning the unit IDs instead of the names?
There's a missing nil check in removeMark() when id is not a table, resulting in an error when manually removing a named marker and trying to re-add it.
local function removeMark(id)
--log:info("Removing Mark: $1", id
local removed = false
if type(id) == 'table' then
for ind, val in pairs(id) do
local r = getMarkId(val)
if r then
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
end
end
else
local r = getMarkId(id)
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
end
return removed
end
Fixed:
local function removeMark(id)
--log:info("Removing Mark: $1", id
local removed = false
if type(id) == 'table' then
for ind, val in pairs(id) do
local r = getMarkId(val)
if r then
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
end
end
else
local r = getMarkId(id)
if r then
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
end
end
return removed
end
DCS seems to need the static units heading in radians.
I'm not sure weither it's only for statics or if it's the same for all units, but reading the code here could lead to thinking that the parameter should be in degrees, whereas it's not.
Just my two cents, ร magnificent builder of worlds ;)
Mission2= mist.marker.drawShape('ellypse') => working
mist.marker.remove(Mission2) => working with polygons
Mission1= mist.marker.drawShape('line') => working
mist.marker.remove(Mission1) => not working with a line
I think the f10 menu is now broke because of this...
Line 980 in mist, its throwing this error:
01526.775 ERROR DCS: Mission script error: : [string "C:\Users\andre\AppData\Local\Temp\DCS/~mis000058E4"]:980: Group doesn't exist
stack traceback:
[C]: ?
[C]: in function 'getName'
[string "C:\Users\andre\AppData\Local\Temp\DCS/~mis000058E4"]:980: in function 'f'
[string "C:\Users\andre\AppData\Local\Temp\DCS/~mis000058E4"]:1534: in function 'onEvent'
[string "Scripts/World/EventHandlers.lua"]:13: in function <[string "Scripts/World/EventHandlers.lua"]:11>
I think in the patch notes this has something to do with it:
" * MP. Wingman of client will take off "
if not unitData.playerCanDrive then
unitData.playerCanDrive = true
end
If unitData.playerCanDrive
is false explicitly, then it will evaluate as if not false then
so playerCanDrive is always true.
I'll submit a PR shortly for this.
Message.add is spamming the new message history feature of DCS
Tested against MIST 4.3.74 and 4.4.90
DCS version: 2.7.3.8494
Groupname= "REDCON1" defined in Mission Editor
Using the following condition;
if not Group.getByName('REDCON1') then
<mist function here>
end
mist.respawnGroup, mist.respawnInZone both fail with the attached exceptions in the teleport element. It seems like the groupName value is failing to return a group object.
I'm not sure if this is an issue in the code, or a gap in the documentation that misses any pre-requisite steps not already taken.
mist.cloneInZone is cloning only the first element of a group of static objects and switching unit side.
The DB doesn't retain the "Hidden on MFD" or "Cold at Start" values for groups and units respectively. This means that groups and units spawned with MIST will not retain these options.
Simply add these two lines of codes to their appropriate places in initDBs() function to fix:
mist.DBs.units[coa_name][countryName][category][group_num].hiddenOnMFD = group_data.hiddenOnMFD
units_tbl[unit_num].coldAtStart = unit_data.coldAtStart
So I was fiddling around in Mission editor and wanted to do a mission where I destroy a bridge. However using mist.flagFunc.mapobjs_dead_zones just returns error when used and callback seems to be empty or blank.
To investigate further I loaded up a old mission basedon MIST 4.3 that previously worked and ran it, but it just craps out when activated. So something has changed in DCS later releases, using latest open beta.
Codesnip I used was
mist.flagFunc.mapobjs_dead_zones{
zones = {'BridgeZone'},
flag = 10
}
The current implementation does not return anything, despite the docs saying so:
--- Removes a scheduled function.
-- @tparam number id function id
-- @treturn boolean true if function was successfully removed, false otherwise.
function mist.removeFunction(id)
local i = 1
while i <= #scheduledTasks do
if scheduledTasks[i].id == id then
table.remove(scheduledTasks, i)
else
i = i + 1
end
end
end
The function should look like this:
--- Removes a scheduled function.
-- @tparam number id function id
-- @treturn boolean true if function was successfully removed, false otherwise.
function mist.removeFunction(id)
local i = 1
local removedFunction = false
while i <= #scheduledTasks do
if scheduledTasks[i].id == id then
table.remove(scheduledTasks, i)
removedFunction = true
else
i = i + 1
end
end
return removedFunction
end
Test if spawning effects works. I mean it should but you never know. If not thats a bug for ED then. :)
Probably also requires me to update the DB code anyways. Ugh. There goes getting slmod and mist ready for initial 2.5 release.
If it works make a wrapper function for mist.dynAddStaticObject.
One of the recent DCS updates has broken the functionality of 'mist.respawnGroup' on ground units in my missions, only. Air units respawn normally. Script reference:
`if not
Group.getByName('GROUP')
then
mist.respawnGroup('GROUP', true)
end`
Thank you for the great tool, happy to provide any more information as needed.
I am not completely positive about it but I reviewed the code and it seems this way.
Also what do we need separate "ME" databases for on top of regular ones if it's regular DBs that are being regularly updated?
in mist.teleportToPoint
, I had to add 'RUNWAY' as a valid terrain type for vehicles :
local validTerrain = {'LAND', 'ROAD', 'SHALLOW_WATER', 'WATER', 'RUNWAY'}
if string.lower(newGroupData.category) == 'ship' then
validTerrain = {'SHALLOW_WATER' , 'WATER'}
elseif string.lower(newGroupData.category) == 'vehicle' then
validTerrain = {'LAND', 'ROAD', 'RUNWAY'}
end
I've Narrowed it down further ...
Note: Yes there is a unit and group name with "POW1" in mission editor.
--Simplistic Version of problem
marker= {}
name = "POW1"
marker.pos = Unit.getByName(name):getPoint() <-- marker.pos cannot receive position from unit name point
Can you verify this works on your end?
Or tell me how this might have changed and how it should be used?
I have verified that it's not that Unit.getByName("xyz") that's having the issue.
I know this works because I got it to work elsewhere.
It's position marker trying to receive the position point that's having the issue.
Error from dcs.log:
2022-08-14 04:56:46.250 ERROR SCRIPTING: Error while handling event [string "C:\Users\username\AppData\Local\Temp\DCS.openbeta/~mis00003EE0.lua"]:1060: attempt to index a nil value
Full Code:
----create a orange marker for POW when released!
POW1MARKER = {}
csar.pow1name = "POW1"
POW1MARKER.pos = Unit.getByName(csar.pow1name):getPoint() <-- This is where I get the dcs.log error
POW1MARKER.id = mist.marker.getNextId()
POW1MARKER.mType = 0
POW1MARKER.readOnly = 0
POW1MARKER.text = "POW1 Located Here!"
mist.marker.add(POW1MARKER)
I used Hoggit's example: (at the very bottom)
https://wiki.hoggitworld.com/view/MIST_markerAdd
local v = {}
v.pos = Unit.getByName('update'):getPoint()
v.id = 5
v.markForCoa = 2
v.mType = 0 <-- 0 for orange circle markers ... was '2'
v.radius = 10000
mist.marker.add(v)
I am trying to understand why there are duplicate entries in mist.DBs.const.shapeNames
Specifically for version 4.5.107
"FARP Fuel Depot" and "Fuel tank" are referred to twice.
Hello,
I've noticed that functions invoked by mist.scheduleFunction
are "lost" somewhere. Consider this script:
local function throwSomeError()
local obj = {}
print(obj.x.y.z)
end
throwSomeError()
Running this code will give me a popup error like this
However, the following code yields no such error:
local function throwSomeError()
local obj = {}
print(obj.x.y.z)
end
mist.scheduleFunction(throwSomeError,nil,timer.getTime()+1)
But of course, the function is erroneous, and in my opinion I should get an error (somewhere) so I can fix it.
Cheers!
From the mist.groupToPoint documentation:
... point can be a zoneTable or zoneName. If not specified a
random distance between 300 and 1000 meters will be defined. form is the def ...
This "random distance" should be documented, is it computing a random point from the point specified (by som radius)?
I'd fix it myself but I don't have Microsoft Office at home
Please add to line 126 if you don't mind and perhaps to other tables as well, so neutral units can be handled. Thank you!
if (coa_name == 'red' or coa_name == 'blue' or coa_name == 'neutrals') and type(coa_data) == 'table' then
Whenever we use password-protected Game Master slots in missions containing MIST, we get a mission script error for line 5291 in the MIST script.
This is the part of MIST that seems to cause the error:
local caSlots = false
local caMSGtoGroup = false
if env.mission.groundControl then -- just to be sure?
for index, value in pairs(env.mission.groundControl) do
if type(value) == 'table' then
for roleName, roleVal in pairs(value) do
for rIndex, rVal in pairs(roleVal) do
if env.mission.groundControl[index][roleName][rIndex] > 0 then
caSlots = true
break
end
end
end
elseif type(value) == 'boolean' and value == true then
caSlots = true
break
end
end
end
Attached is the error message. Do I have to change something in these lines to prevent the error?
At initiating I get the error referring to line 5291: attempt to compare number with string and will not load this version.
Add mark panels in a similar way as message functionality.
When called, this produced two errors that I managed to troubleshoot and resolve so it worked for me as intended.
the first parameter is called unit_names but unitNames is referenced in the body.
an error that you are trying to do arithmetic on a table is shown, caused on line 2520:
inZoneUnits[inZoneUnits + 1] = units[i]
I fixed it by changing it to:
inZoneUnits[#inZoneUnits + 1] = units[i]
Thanks
Using the latest dev branch, the teleport function does not work for static objects.
I placed a bunker named BunkerA, used teleport command. Instead of teleporting, it cloned the object, leaving the original in place. Using triggers to test the name, the original object triggered, the new object didn't. So this indicates that it clones a new object, and the original maintains its name and all properties.
I am trying to randomize the spawn location of aircraft groups. I can make them spawn at a random location or move them to a random location after spawning (using respawnInZone() or teleportInZone(), respectively), but after this they "go dumb." They slowly descend to ~200' agl and eventually crash into the ground if there's a terrain rise. They don't follow flight plan, and don't engage.
The same groups work fine if I spawn them at their ME-specified starting point with respawnGroup(). Is there any fix or workaround for this?
Thanks!
Since JSON is a more common dataformat (generally speaking), is it possible to add export LUA table to JSON feature to MIST?
Updated mist from version 4.5.107 to 4.5.121 and launching the mission with the new version of mist returns an error
excerpt from my logs with the updated mist version (and no other changes).
2023-11-22 04:14:30.582 INFO SCRIPTING (Main): Chaos Log: Loading: mist.lua
2023-11-22 04:14:30.616 ERROR SCRIPTING (Main): Mission script error: [string "C:/Users/Chaos/Downloads/DCS LUA scripts/mist.lua"]:133: attempt to index field 'unitsByName' (a nil value)
I could make a web-based documentation for mist. Using the .pdf as a encyclopedia is a bit cumbersome imo
I'm trying to create a mission, in which a plane controlled by a bot respawns in its initial position when a set of conditions is met.
At first, I did this with mist.respawnGroup(groupName, true)
. This worked, however, after multiple respawns (~500) the planes started to drift. I.e. the respawn location was not the same as the initial location when the mission started.
I then tried to use mist.getGroupData(groupName)
to save the initial position of the planes and then used mist.teleportToPoint
to set them back to this position. However, I observed very inconsistent behavior when using teleportToPoint
, such as:
getGroupData
only returns coordinates x
and y
, z
is not included for some reason).What is the recommended way to respawn a unit to exactly their initial location without forgetting their tasks?
function mist.getUnitsInPolygon(unit_names, polyZone, max_alt)
local units = {}
for i = 1, #unit_names do
units[#units + 1] = Unit.getByName(unitNames[i])
end
local inZoneUnits = {}
for i =1, #units do
if units[i]:isActive() and mist.pointInPolygon(units[i]:getPosition().p, polyZone, max_alt) then
inZoneUnits[inZoneUnits + 1] = units[i] -- HERE !!!
end
end
return inZoneUnits
end
MissionScriptingTools/mist_4_5_107.lua
Line 95 in 67f2c5f
data then bullsye should be
should be
data then bullseye should be
Cheers!
Chuck
Steps to reproduce:
mist_4_5_122.lua is in use
Oil well or Gas platform static object is killed
Error on line 1546 when calling Object.getPosition in function addDeadObject
I noticed a typo that is preventing the getGroupsByAttribute
and getUnitsByAttribute
from working correctly:
MissionScriptingTools/mist_4_5_107.lua
Line 2834 in 67f2c5f
MissionScriptingTools/mist_4_5_107.lua
Line 2884 in 67f2c5f
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.