Jump to content

Recommended Posts

Posted

I'm trying to get a respawn script working with MOOSE, and I'm having no luck with it at all. I'm new to LUA, and MOOSE (beyond the basics). I've combed through the forums for ideas and tried almost every example I've found - every time with no luck.

 

What I need to do is have a group respawn -

 

  • when it lands
  • when it's destroyed

I also need to get a similar script working for ground units (vehicles and SAMs) that will respawn when the group is destroyed.

 

What I've done is create a completely new, fresh mission with nothing else on it. The latest version of MOOSE is loaded first as is required. I then add the do script for my LUA file. These are the scripts I've tried lately:

 

local Group_Spawn = SPAWN:New("MiG29_Grp1")
Group_Spawn:InitLimit(1, 99)
Group_Spawn:SpawnScheduled(10,0)

MiG29_Grp1 = SPAWN:NewWithAlias("MiG29_Grp1")
MiG29_Grp1:InitRepeatOnEngineShutDown()
MiG29_Grp1:InitLimit(1,99)
MiG29_Grp1:SpawnScheduled(30,0)
MiG29_Grp1:SpawnAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Anapa-Vityazevo ), SPAWN.Takeoff.Hot )
MiG29_Grp1:OnSpawnGroup()

The MiG29_Grp1 group has 2 aircraft, and is set to take off from Anapa airfield. The group has Late Activation checked.

 

In both these instances, the trigger that fires the spawn of the MiG group fires after 10 seconds (a basic Time More), the MiGs spawn, take off, and fly into the zone I've created that destroys them (this for testing obviously). Once that happens however the group never respawns.

 

I have no idea what I'm doing wrong here.

Respawn.miz

Posted (edited)

You need to monitor dcs.log when testing scripts, otherwise you'll never know what's going on.

 

As for your second snippet, you're using two different spawn methods, SpawnAtAirbase and SpawnScheduled , they're probably conflicting.

 

Also, the correct airbase enumerator is Anapa_Vityazevo, not Anapa-Vityazevo

 

Also, :OnSpawnGroup() is used to execute predefined functions on spawn, but you didn't define any function, so I don't know why you put it there.

 

Try this instead:

MiG29_Grp1 = SPAWN:NewWithAlias("MiG29_Grp1")
MiG29_Grp1:InitLimit(2 , 99)
MiG29_Grp1:InitRepeatOnEngineShutDown() [color="Blue"]-- I don't think this will work, you'll probably need to script it the hard way[/color]


local function Scheduler()
     
  MiG29_Grp1:SpawnAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Anapa_Vityazevo ), SPAWN.Takeoff.Hot )
  
  return timer.getTime() + 30
end

timer.scheduleFunction(Scheduler, nil, timer.getTime() + 1)

 

Finally, keep in mind that DCS update 2.5.6 introduced several changes that broke core MOOSE functionality, the team is still working on fixes.

Edited by Hardcard
Posted

Okay thanks.

 

 

I'm a complete newbie to MOOSE, and have little LUA scripting experience, so some of those functions I really am not familiar with. The two examples I posted were cut and pasted from other sources with my own variables entered.

 

 

I tried your example, and it still didn't work (both in multiplayer and singleplayer). I suppose it would be best to just wait until MOOSE functionality is restored due to the issues created by 2.5.6?

Posted
Okay thanks.

 

 

I'm a complete newbie to MOOSE, and have little LUA scripting experience, so some of those functions I really am not familiar with. The two examples I posted were cut and pasted from other sources with my own variables entered.

 

 

I tried your example, and it still didn't work (both in multiplayer and singleplayer). I suppose it would be best to just wait until MOOSE functionality is restored due to the issues created by 2.5.6?

 

 

No buddy, you do exactly what was suggested as the opening lines of Hardcards answer! :)

"You need to monitor dcs.log when testing scripts, otherwise you'll never know what's going on."

Let me explain why.

Even if you didnt make any mistakes you can see, the logging DCS gives is very reliably the best way to find out what happened. People link code all the time and expect scripters to be able to read it and spot errors. In fact, computers are for reading code. I don't even bother checking mine, I run it and hey guess what, DCS tells me the line number I screwed up on! :D

 

This is even before considering there is nothing wrong with your code. Honestly, I didn't read it, same as I don't read mine :) I glanced at the methods and I know you are using a SpawnAtAirbase() method which was notoriously screwed by ED's change to airbase ID's and also was announced as fixed internally, but the lesson here is how to improve your troubleshooting skills rather than be a victim of random changes to the game patch on patch :) Be Data driven.... don't guess, just know because it errors. :) :) You will become self sufficient, faster and use your time more effectively.

 

Get a free log tailer, like "Baretail", (https://www.baremetalsoft.com/baretail/) open the dcs.log, set it to tail, put it on another screen, run the mission, and oh look, you see error messages in realtime which teaches you so much! All the mysteries now suddenly come without guesses and what is more you will learn to debug by making your own logging with

env.info("whhhheeeeee, i'm a logging comment whizzing by!") 

And you now are empowered!

  • Like 1

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

  • 3 years later...
Posted
On 3/16/2020 at 1:48 PM, Pikey said:

 

 

No buddy, you do exactly what was suggested as the opening lines of Hardcards answer! 🙂

"You need to monitor dcs.log when testing scripts, otherwise you'll never know what's going on."

Let me explain why.

Even if you didnt make any mistakes you can see, the logging DCS gives is very reliably the best way to find out what happened. People link code all the time and expect scripters to be able to read it and spot errors. In fact, computers are for reading code. I don't even bother checking mine, I run it and hey guess what, DCS tells me the line number I screwed up on! 😄

 

This is even before considering there is nothing wrong with your code. Honestly, I didn't read it, same as I don't read mine 🙂 I glanced at the methods and I know you are using a SpawnAtAirbase() method which was notoriously screwed by ED's change to airbase ID's and also was announced as fixed internally, but the lesson here is how to improve your troubleshooting skills rather than be a victim of random changes to the game patch on patch 🙂 Be Data driven.... don't guess, just know because it errors. 🙂 🙂 You will become self sufficient, faster and use your time more effectively.

 

Get a free log tailer, like "Baretail", (https://www.baremetalsoft.com/baretail/) open the dcs.log, set it to tail, put it on another screen, run the mission, and oh look, you see error messages in realtime which teaches you so much! All the mysteries now suddenly come without guesses and what is more you will learn to debug by making your own logging with

env.info("whhhheeeeee, i'm a logging comment whizzing by!") 
 

 

And you now are empowered!

excellent advice , ill be trying this today .

sig sm.png

walshtimothyWW2 virtual flier - currently playing on 4ya ww2 - youtube channel here

https://www.ww2adinfinitum.blog -  https://projectoverlord.co.uk/

 

  • Recently Browsing   0 members

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