Trying to make SAR Scenario

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
Halsey1945
Posts: 21
Joined: Mon May 18, 2015 1:55 pm

Trying to make SAR Scenario

Post by Halsey1945 »

Hello Everyone,

I am trying to make a SAR scenario in the Gulf of Mexico. It has the USCG searching for four randomly placed lifeboats. I am using a neutral side. This is to keep you from knowing where they are. I have gotten the lifeboats to randomly spawn. Now I am trying to have the lifeboats switch sides once they are detected. I have a detection trigger and am trying to use a lua script (SetUnitSide) action. However, I am having trouble using the UnitX script to tell Command which unit needs to change sides. Does anyone have any advice? I am quite new to lua.
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: Trying to make SAR Scenario

Post by Rory Noonan »

Generally I would do something like so:

Unit = ScenEdit_UnitX() --Assigns UnitX table activating the trigger to the variable 'Unit'
UnitID = Unit.name --Assigns the 'name' field from the above table to the variable 'UnitID'
ScenEdit_SetUnitSide({side='Side 1',name=UnitID,newside='Side 2'}) --Changes side

If that doesn't work post your scenario up and I'll have a look [:)]

Bonus tip working with Lua: Use an editor like Notepad++ to check your code before you put it into CMANO, and if you're having trouble try running it line by line to find the error. Also make good use of the print command to check your variables. It gets easier, and the more you use it the more you'll find reasons to use it [:)]
Image
User avatar
Randomizer
Posts: 1497
Joined: Sat Jun 28, 2008 8:31 pm

RE: Trying to make SAR Scenario

Post by Randomizer »

I would advise deleting the life rafts after rescue as they serve no puropose once the people in them are picked up.

See:

Scripting sea rescues

Your call

-C
Halsey1945
Posts: 21
Joined: Mon May 18, 2015 1:55 pm

RE: Trying to make SAR Scenario

Post by Halsey1945 »

Thank you Apache! That worked like a charm.

Good point Randomizer. However, I can't seem to get the reference points to follow the rafts after they teleport. And, I can't seem to create a trigger and event after the scenario is loaded. I can create reference points surrounding the rafts, but not the trigger. That may be because I am a noob to Lua though. As of right now I am just having the user dispatch cutters to the rafts and pick them up.
User avatar
Randomizer
Posts: 1497
Joined: Sat Jun 28, 2008 8:31 pm

RE: Trying to make SAR Scenario

Post by Randomizer »

If you want to get fancy you're going to need to learn Lua. Experiment with the script console, it's a great tool for scenario writing.

Fix the reference points to the raft and they will teleport with the raft to the scene of the sinking. You can test this easily enough but you can demonstrate it by just fixing the reference point, move the raft (using the M=Move command) then run the game for one second and the reference points will teleport as intended. Then write events to delete the raft when the rescue is triggered. Because the raft side is neutral, the Player's map will not become cluttered with dead reference points.

If you examine the test scenario I linked to above, the necessary Lua scripts should all be there and need only be copied and edited according to your requirements and naming conventions.

-C
Halsey1945
Posts: 21
Joined: Mon May 18, 2015 1:55 pm

RE: Trying to make SAR Scenario

Post by Halsey1945 »

Thank you Randomizer. The script console is great. I am currently playing around with it and learning quite a bit. And, you are right Apache. Notepad++ is great.I have used it for other programming, but didn't realize it can help with Lua, too. I just wish it was more accessible. Since, I am legally blind and my magnifier does not follow the cursor. Anyways, I think I'm starting to get the hang of it. And, there is so many uses for it.
Halsey1945
Posts: 21
Joined: Mon May 18, 2015 1:55 pm

RE: Trying to make SAR Scenario

Post by Halsey1945 »

A bit off topic. However, what are the following scripts? I found them in the script console. And, haven't found anything in the forums, wikis, or documentation about them.

VP_GetSide(table)
VP_GetUnit(table)
World_GetCircleFromPoint(table)
World_GetElevation(table)
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Trying to make SAR Scenario

Post by michaelm75au »

ORIGINAL: Halsey1945

A bit off topic. However, what are the following scripts? I found them in the script console. And, haven't found anything in the forums, wikis, or documentation about them.

VP_GetSide(table)
VP_GetUnit(table)
World_GetCircleFromPoint(table)
World_GetElevation(table)

1. VP_GetSide(table) Gives a pointer to the 'side' object. Only use I have seen to date is for the change to the Nav Zones as shown in 1.11 SR1
mySide = VP_GetSide({Name="US"})
myZone = mySide.getnonavzone("AAW Zone 1") [Alternative for excl. zone: myZone = mySide.getexclusionzone("Forbidden Zone 1")]
myZone.isactive = "True"/"False"


2.VP_GetUnit(table) I expect that this is similar except it lets you address a 'unit' to get the 'side'. But you could use ScenEdit_GetUnit() and use the 'side' value of it to feed into VP_GetSide().

3.World_GetElevation(table) Gives you altitude of the location specified
unit=ScenEdit_GetUnit({Name="Cactus #2"});print(unit);
world = World_GetElevation({latitude=unit.latitude, longitude=unit.longitude});print(world) -- altitude of the point Cactus #2 is flying over


4.World_GetCircleFromPoint(table) As it says, it will give you a set of 45 points around a location at a specific radius (in NM)
world = World_GetCircleFromPoint({latitude=unit.latitude, longitude=unit.longitude, radius = 100});print(world)
for i=1,45 do
ScenEdit_AddReferencePoint({
side='LZs',
lat=world.Latitude,
lon=world.Longitude,
name=i,
highlighted="yes"})
end

Michael
Post Reply

Return to “Mods and Scenarios”