Jump to content

Random Airtraffic Script (with MIST2.0)


SNAFU

Recommended Posts

Can it be that there is one parameter missing?

 

 

Spawntimer = mist.scheduleFunction(generateAirplane, {}, timer.getTime() + 2, intervall)

 

 

NewSpawntimer = mist.scheduleFunction(mist.groupToRandomZone, {'myGroup', 'myZone'}, timer.getTime() + 10, 900, timer.getTime() + 3600)

 

:noexpression:


Edited by HiJack
Link to comment
Share on other sites

Just for correct understanding...

 

After an hour DCS logs into the log

 

00033.291 INFO SCRIPTING: mist.scheduleFunction, error in scheduled  function: [string  "C:\Users\Jack\AppData\Local\Temp\DCS\/~mis00..."]:4254: Parameter #1  (unit name string) missed

 

At the same time you get the scripting error message in game on the screen, therefore you know it is line 2561 or 2682?

 

Where is the function NewSpawntimer coming from?

 

From my understanding mist.scheduleFunction (function, arguments of function, starting time, intervall, cycles) is not correctly described in the MIST manual, as far as I remember. Maybe you switch 900 with time.getTime() + 3600, but only a wild gues.

 

In my next testing version I would include a kind of scripted debugging message as you see in (t8) to find out in which area of the script it stops.

This is a further development version of the t7 and not tested.

 

I don´t know when I find the time to test this one at home... :cry:

MIST3_2_RandAirtraffic_t8.lua

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Thank you SNAFU. script error registers at once after the script starts. I have had server crash after one hour that results in DCS just quits, I don't know why and cannot say it's because of this script error. I'm just looking to find a possible explanation. I will do more testing. Again, thank's :)

Link to comment
Share on other sites

The script error seems to log when players loging on and off to the server.

 

00094.210 INFO    NET: spawning client[2]
00094.211 INFO    NET: client[2] started
00105.002 INFO    NET: Lua: Client [2] "Jack" joined Blue in "F-15C"(97)
00108.335 INFO    SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Jack\AppData\Local\Temp\DCS\/~mis00..."]:4254: Parameter #1 (unit name string) missed
00135.399 WARNING LOG: 13 duplicate message(s) skipped.
00135.399 INFO    NET: Lua: Disconnected client: [2] "Jack"
00135.399 INFO    NET: remove: client 2
00136.389 INFO    SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Jack\AppData\Local\Temp\DCS\/~mis00..."]:4241: Object doesn't exist

Link to comment
Share on other sites

Ok, the modification with adding the debugging messages didn´t work I guess... I have issues with the debugging function in another script too, have to look....

 

The reference to line 4254 is leading to the MIST script. Maybe you can see what function in MIST is called up in this lines and find out who this could be related to a group spawn and despawning as client?

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

This is line 4243 to 4255:

 

if #groupsToAdd > 0 then -- if groups are expected
for groupId, groupData in pairs(groupsToAdd) do -- iterate through known groups to add
	if (type(groupData) == 'string' and groupData == eventData:getGroup():getName()) or (type(groupData) == 'table' and groupData.name == eventData:getGroup():getName()) then -- already added, do nothing
		match = true
		break
	end
end
if match == false then -- hasn't been added
	groupsToAdd[#groupsToAdd + 1] = Unit.getByName(eventData):getGroup():getName()
end
else -- no groups added by mist
groupsToAdd[#groupsToAdd + 1] = Unit.getByName(eventData):getGroup():getName()
end

The line referenced in the log is:

groupsToAdd[#groupsToAdd + 1] = Unit.getByName(eventData):getGroup():getName()

Link to comment
Share on other sites

Ok, that appears to be part of a MIST function, which lists all new groups into a table, if they are not already in the table.

 

The error seems to appear when a client takes control or leaves the control of a plane and seems to be related to the group name. I guess the MIST function is regularly called to check for new events or groups with the mist.schedule, maybe Grimes knows?

 

It could be rather a general MIST issue, maybe you try an older version of MIST or another? Sometimes I find in several versions of scripts in the compressed *.miz file, which I actually long deleted in the mission editor, but they somehow stuck in the compressed file. Then I have to delete them manually in the *.miz.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Yes, the script error comes when just running the Mist 3.3 also. So this may not be a problem then as there are many using Mist 3.3 I guess.

 

EDIT: But the log also contain this on the next line to the script error:

WARNING LOG: 391 duplicate message(s) skipped.

 

So It may be something to look into after all.


Edited by HiJack
Link to comment
Share on other sites

Is it possible to rewrite the code for these random aircrafts to use a suffix also? You have the prefix on the name to "A-" but I would like a suffix like "R" (for Random) to preserve the possibility to have other aircrafts to end on 11 and 151. Just asking ;)

Link to comment
Share on other sites

The string "A-" is just a variable string. You can also replace "A-" by "AnotherRandomAICreated or whatever you like".

 

The semicolon is a leftover, shouldn´t do anything so you can delete it. It just separates statements in LUA as far as I know.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 3 months later...

Been a few months since anyone posted here- I've tried to get this working in 128 with MIST 3.4 and I'm wondering if anyone else has had success?

 

I keep getting this error...

 

00051.412 INFO SCRIPTING: Mist version 3.4.23 loaded.

00063.489 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2370: attempt to index global '_spawnairplane' (a nil value)

00063.691 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2582: attempt to index global '_destination' (a nil value)

00078.951 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2358: attempt to index global '_spawnairplane' (a nil value)

00079.092 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2589: attempt to index global '_destination' (a nil value)

00090.562 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2358: attempt to index global '_spawnairplane' (a nil value)

00090.641 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2582: attempt to index global '_destination' (a nil value)

00098.802 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2370: attempt to index global '_spawnairplane' (a nil value)

00098.937 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:2582: attempt to index global '_destination' (a nil value)

 

 

Looks like each time it wants to spawn a plane... something is missing.

 

Anyone able to put their finger on what needs to be adjusted (if anything?)

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

The GCICAP script - which is closely related to this one - still has issues as well and while it runs it doesn't reliably do what it's meant to do although I haven't yet tried it with Mist v3.4.

 

So it will be interesting to see if anything bugwise is found for this one as it may also apply to the cap script.

Link to comment
Share on other sites

I think I see the problem.

 

From the script:

--Following trigger zones need to be placed in the ME:

--1: Zone called 'AF1', which defines location of airfield 1

--2: Zone called 'AF2', which defines location of airfield 2

--3: Zone called 'AF3', which defines location of airfield 3

--4: Zone called 'airlanehub1', which defines the entry/exit point of the airfield the planes are set to land or takeoff

 

Variable names AF1, AF2, and AF3 are also used for different purposes.

 

The zone names are strings, so the code need to be changed from _spawnairplane = trigger.misc.getZone(AF1) to _spawnairplane = trigger.misc.getZone('AF1') at line 2356. Likewise AF2 and AF3 need to be changed to 'AF2' and 'AF3' at lines 2368 and 2380, respectively. (Also, AF1 is mistakenly used at line 2368 -- it should be 'AF2').

 

They need to be changed at lines 2573, 2580, and 2587, too, where _destination is set.

 

 

Link to comment
Share on other sites

Okay! Thanks Ajax... I can implement that fix tonight and post it provided SNAFU doesn't mind. (SNAFU just let me know either way. I've posted it but can very easily take it down.)

 

 

(Anyone know how much rep needs to be spread? It keeps $#%#$^ telling me "must spread rep" but it never tells you how much you need to spread.)

 

Edit:

THANKS AJAX! Confirmed it works like a charm.

MIST3_2_RandAirtraffic_r5a.lua


Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

I appreciate it, Eno, but I should have read the whole thread. It seems Highwayman-Ed came up with the solution back in post #27.

 

I should point out that the fix (his and mine) may not be doing things the way Snafu intended. I believe it would work without the changes if you named your zones exactly like the strings assigned to the variables AF1, AF2, and AF3.

 

For example, instead of naming the zones 'AF1', 'AF2', and 'AF3', name them like this:

 

Whatever you define your airfield names to be:

AF1 = 'XXXXXX'

AF2 = 'YYYYYY'

AF3 = 'ZZZZZZ'

 

In the mission editor, name your zones the same thing:

Zone 1 name = 'XXXXXX'

Zone 2 name = 'YYYYYY'

Zone 3 name = 'ZZZZZZ'

 

If you do this, then the script should work as written.


Edited by ajax
Link to comment
Share on other sites

I see what you're saying... I ran into this problem before but this time it seemed different. Yeah, that's my bad...

 

I went back and re-read my posts / issues (again... I'd done it before but after the group issue we had before figured it had something to do with 128 and didn't read it closely enough).

 

It got confused the same way this time as I had before back in March... thinking when he said "zone called 'AF1" I created a zone called AF1- thinking the name of the base was the identifier for the script to spawn at the right airbase.

 

I totally just clicked in.

 

 

SORRY GUYS!

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

I've run into some trouble with the landings- I'm pretty sure it's an issue that extends beyond the script- but in my hunt for solutions I went browsing for the landing speed of the aircraft and I think I found it in the spoiler.

 

Just wondering if that speed actually affected the final approach? Is it in kph? Mph? kts?

 

I'm going to start messing with it out of curiosity, but any insights on it would also be appreciated.

 

 

 

 

 

 

 

 

landingpoint =

{

["alt"] = 600,

["type"] = "LAND",

["action"] = "Landing",

["alt_type"] = "RADIO",

["formation_template"] = "",

["ETA"] = 0,

["y"] = _destinationpos.z,

["x"] = _destinationpos.x,

["speed"] = 250,

["ETA_locked"] = false,

["task"] =

{

["id"] = "ComboTask",

["params"] =

{

["tasks"] =

{

 

}, -- end of ["tasks"]

}, -- end of ["params"]

}, -- end of ["task"]

["speed_locked"] = true,

}

 

 

if (waypointType == 'plane')

then

waypoints[#waypoints+1] = mist.fixedWing.buildWP(turningpoint,"Turning Point", 200, 11500, "RADIO")

waypoints[#waypoints+1] = mist.fixedWing.buildWP(landingpoint, "LAND", 200, 600, "RADIO") --string type, number speed, number altitude, string altitudeType

 

 

 

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

  • Recently Browsing   0 members

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