Jump to content

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua


Recommended Posts

So has anyone come up with a work around for re-spawning ground units?

 

I tried with no luck or I'm using it wrong.

 

if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then
           return true
       end
       return false
   end

Link to comment
Share on other sites

Grimes,

 

I put the 57 build in one of my scripts and now when I try to use the RespawnGroup function I get a global value is nil error. is this a known issue right now or something new.

 

thanks

 

Falcon

MSI Creator X299 - INTEL i9 - 10900X 3.7 GHZ - 32 GB Corsair Dominator DDR4 - EVGA GTX 1080 FTW AC2

Link to comment
Share on other sites

I put the 57 build in one of my scripts and now when I try to use the RespawnGroup function I get a global value is nil error. is this a known issue right now or something new.

 

Whats the global variable? respawning is working for me.

 

 

Hi Guys!

 

Is it possible to get the Coordinates of the SPI?

 

Unfortunately avionics data like that is not accessible to the scripting engine.

 

redunits = Group.getSize (mist.getUnitsInZones('[figthers][red]' , zone1))

blueunits = Group.getSize (mist.getUnitsInZones('[figthers][blue]' , zone1))

If blueunits <= 1/2×redunits then
trigger.action.setAITask(blueunits, number taskIndex ) 
number taskIndex= this would be return to base.... i dont know how to put this.
End

 

I know that my code its a mess but... i guess you get my point. And the idea is interesting for me.

 

Group.getSize() doesn't work like that since mist.getUnitsInZones doesnt return a group object, it returns a list of units that are within the zone. You can check the size of the tables with something like : redUnits = #mist.getUnitsInZones('[figthers][red]' , zone1)

 

So has anyone come up with a work around for re-spawning ground units?

 

I tried with no luck or I'm using it wrong.

 

if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then
           return true
       end
       return false
   end

 

Should be working without issue.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Grimes

I had the function call like mist.respawn('groupName',True) then I tried mist.respawn('groupName') both failed so I assumed it can not get the groupname for some reason. I will have to look deeper into this unless you have some suggestions.

thanks

76th Falcon

MSI Creator X299 - INTEL i9 - 10900X 3.7 GHZ - 32 GB Corsair Dominator DDR4 - EVGA GTX 1080 FTW AC2

Link to comment
Share on other sites

Grimes

I had the function call like mist.respawn('groupName',True) then I tried mist.respawn('groupName') both failed so I assumed it can not get the groupname for some reason. I will have to look deeper into this unless you have some suggestions.

 

Is there actually a group in your mission with the name 'groupName' ? Because that is what the function is expecting.

 

Also true/false statements need to all be lower case. If you are using notepad++ and set the language to lua you will notice that the word true will be highlighted blue while True won't be.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Well you put it in quotes which makes it a string of literally 'groupName', which is why I pointed it out.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Help please to get some units params via MIST.

I use this code, which is work perfect

 

local current_Unit = Unit.getByName(Units_to_fly_table[i])
local current_nickname = Unit.getPlayerName(current_Unit)
local current_UnitType = current_Unit:getTypeName()
local myPos = current_Unit:getPosition().p
local XX = myPos.x
local YY = myPos.y
local ZZ = myPos.z

 

But how can I extrack radio altitude of unit?

Link to comment
Share on other sites

I believe that the y component of your position is your ASL and if you want to get your AGL then you need to use land.getHeight at your x,z co-ords to get the height of the land at that position. Note that it's all in metres.

 

eg AGL = myPos.y - land.getHeight(myPos.x,myPos.z)

 

So ASL - ground height at unit position to get radar alt or AGL.

  • Like 1
Link to comment
Share on other sites

Stonehouse, not works.

got this error

 

From ED wiki

 

Distance function land.getHeight(Vec2 point)

 

what vec2 point correct format?

 

 

Ps Fix it

 

local XX = myPos.x

local YY = myPos.y

local ZZ = myPos.z

MyVec2 = { x = XX, y = ZZ }

local AGL = myPos.y - land.getHeight(MyVec2)

 

Many thanks!

930096499_.png.f66f821edf7f558771267855ad4be390.png


Edited by BR=55=Sevas
Link to comment
Share on other sites

Sorry if this already known or intended, but I think I found a bug in mist.getNorthCorrection. If called with a Vec2, the first thing it does is turn it into a Vec3:

 

	
if not point.z then --Vec2; convert to Vec3
point.z = point.y
point.y = 0
end

 

But because Lua passes tables around by reference, it's changing the coordinates in the caller's scope.

 

I just thought I was going crazy, as my code worked without the getNorthCorrection call, but didn't work with it. But I wasn't even using the returned value!

Link to comment
Share on other sites

Thanks. I'll have a look through the code to see if this happens for anything else. I have a feeling it might...

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Is it possible to create tcp or udp connection with mission`s scripts like export.lua do?

I tried add

package.path = package.path..";.\\LuaSocket\\?.lua"

package.cpath = package.cpath..";.\\LuaSocket\\?.dll"

socket = require("socket")

 

StatUDP = socket.udp()

StatUDP:setsockname("127.0.0.1", 8095)

StatUDP:setpeername("127.0.0.1", 8090)

StatUDP:settimeout(0)

socket.try(StatUDP:send(string.format("STATA_START")))

 

But got error

 

img-2015-11-22-00-07-34.png?etag=BD332EC1E96905DCFF9942AE706BFC5F78CD4D2B

Link to comment
Share on other sites

The Lua environment for mission scripts is limited by design (to prevent malicious mission scripts from messing with your files, turning your PC into a spam bot, etc). You can get around that by editing Scripts\MissionScripting.lua in your DCS installation directory (sometimes referred to as the "sanitation module").

 

If you publish anything that requires editing that file, make sure to warn your users about the increased risk or keep the existing sanitation code intact, load your own code before that and make sure that nothing you expose to the global namespace can be used to cause harm (e.g. keep a file-local copy of the "require" function etc. and expose a global function that only lets you write to a predetermined file / network port / whatever).

 

I'd suggest posting any follow-up questions in a new thread, as this is not a MiST-specific issue.

 

Edit: On a completely unrelated note, I just noticed that my post count is my phone number (without area code) right now *g*


Edited by [FSF]Ian
Link to comment
Share on other sites

  • 2 weeks later...

What is the license of this project? I couldn't find one in the github repo or the guide. Or is it not licensed under any open source license?

 

I'm asking because I wanted to fork it and change some stuff and send you a pull request. But in the case you don't want to merge my changes back into the main project I don't want to have to trash them (= not releasing them on github under any OS license). So I'm asking beforehand. :)

Link to comment
Share on other sites

Never added a proper license to it on github, but see the first post in the thread:

 

Community Contributions

The purpose of Mist is to provide a set of scripts for the DCS community, by the DCS community. We are open to people contributing their own scripts into Mist, but we reserve the right to edit your script in any way we see fit before “officially” including it into Mist. Also, feel free to contribute ideas as for what scripts to develop next.

 

Usage Rights

Feel free to modify or redistribute Mist in any way you see fit (even including it in paid content is OK by us), AS LONG AS you don’t try claim that our work is your own.

 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • 2 weeks later...

That looks to be a mission editor issue, would need the mission file to see if I can reproduce the issue.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Hi Grimes,

 

In the update 1 changelog today there is some mention of lua scripting. Does that mean that some of the scripting bugs you have been keeping track of have been squashed?

[sIGPIC][/sIGPIC]

 

Intel Core I7 4820K @4.3 GHz, Asus P9X79 motherboard, 16 GB RAM @ 933 MHz, NVidia GTX 1070 with 8 GB VRAM, Windows 10 Pro

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...