Including/Scripting A Yes/No Option in a Scenario

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

Including/Scripting A Yes/No Option in a Scenario

Post by butch4343 »

Guys I wonder if I can draw on your knowledge again, lol.
I have two sides in my scenario, I have the RAF Air Defence Commander the player, and I have my V-Force bombers as a separate side. What am wondering, is , Is there a way where I can have CMNAO ask the player “do you wish to launch the V-Force? Yes/No” If they select yes then the V-Force Mission goes active and they launch, if no the mission remains inactive.
Is there a way to do this?
If its via LAU scripting, can anyone point me to a script that works?
I could swear I have played a scenario with a similar function but cant remember which.
Regards
Coiler12
Posts: 1268
Joined: Sat Oct 12, 2013 10:11 pm
Contact:

RE: Including/Scripting A Yes/No Option in a Scenario

Post by Coiler12 »

ORIGINAL: butch4343
Guys I wonder if I can draw on your knowledge again, lol.
I have two sides in my scenario, I have the RAF Air Defence Commander the player, and I have my V-Force bombers as a separate side. What am wondering, is , Is there a way where I can have CMNAO ask the player “do you wish to launch the V-Force? Yes/No” If they select yes then the V-Force Mission goes active and they launch, if no the mission remains inactive.
Is there a way to do this?
If its via LAU scripting, can anyone point me to a script that works?
I could swear I have played a scenario with a similar function but cant remember which.
Regards

Ok, if they're a separate side and you don't mind an out of your hands mission, all you have to do is make a special action "Activate V Force", and have the action script assign them all to a mission.

Or you can use ScenEdit_SetUnitSide to give them to the player and have them control them.
User avatar
stilesw
Posts: 1569
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: Including/Scripting A Yes/No Option in a Scenario

Post by stilesw »

I agree with Coiler12. You can set up a Special Action and have it hidden until it is triggered by some event. When triggered a message box can pop up asking if you want to execute the activity. Go to "Game > Special Actions" and execute (or not) the event. If you select not to do so the Special Action can be turned off via Lua and no longer be available. I've used this type of thing a couple of times with success.

-Wayne Stiles
“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
User avatar
Gunner98
Posts: 5881
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Including/Scripting A Yes/No Option in a Scenario

Post by Gunner98 »

Not meaning to hijack the thread but along a similar line of thinking - and I think the answer is no, but who knows what some of you wizards can come up with:

Can you 'merge sides'? For instance have a force - a CVBG for instance, that is on another side to the player -- but when something triggers it, the whole CVBG comes under the control of he player?

I know how to do the change sides bit in Lua but it would a trick to do for an entire CVBG.

Thanks

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
stilesw
Posts: 1569
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: Including/Scripting A Yes/No Option in a Scenario

Post by stilesw »

At start, "Game > Special Actions" is empty.
Set up a special event "Editor > Event Editor > Special Actions" (see screenshot)
Make sure "Is Active" is not checked.

Create an event to give player an option to do this:
Lua:
Event - Nuclear Option.
Trigger - City destroyed.
Event - Ask to allow nuclear option and activate Special Action so that it appears under "Game > Special Actions":
Message "Do you want to authorize nukes?"
ScenEdit_SetSpecialAction(ActionName="Nuclear Option", IsActive="True" )
Two choices:
Yes
No.
If yes then nukes will be authorized.
If no then no nukes and run another Lua script to eliminate the option from "Game > Special Actions"
ScenEdit_SetSpecialAction(ActionName="Nuclear Option", IsActive="False" )

I hope this makes some sense. Please ask if not.

-Wayne Stiles


Image
Attachments
Event1.jpg
Event1.jpg (38.53 KiB) Viewed 139 times
“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Including/Scripting A Yes/No Option in a Scenario

Post by michaelm75au »

In 1.11.7 (i think it was), I introduced a new Lua function - ScenEdit_InputBox ('message') which prompts with a message, and returns the data entered back to the script.
Example
local response = ScenEdit_InputBox('How are you today')
print('Response was ' .. response)

You can interrogate the response to act on things. It is fairly simple, but I was really after getting a bit of dialogue going between the script and the player
Michael
DeSade
Posts: 155
Joined: Mon Mar 01, 2004 5:08 pm
Contact:

RE: Including/Scripting A Yes/No Option in a Scenario

Post by DeSade »

ORIGINAL: michaelm

In 1.11.7 (i think it was), I introduced a new Lua function - ScenEdit_InputBox ('message') which prompts with a message, and returns the data entered back to the script.
Example
local response = ScenEdit_InputBox('How are you today')
print('Response was ' .. response)

You can interrogate the response to act on things. It is fairly simple, but I was really after getting a bit of dialogue going between the script and the player

For Yes/No type dialog easiest way imho is to apply style=4 in ScenEdit_MsgBox, for example:

local dialog = ScenEdit_MsgBox('Authorize strike?', 4)
print(dialog)
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Including/Scripting A Yes/No Option in a Scenario

Post by michaelm75au »

ORIGINAL: DeSade

ORIGINAL: michaelm

In 1.11.7 (i think it was), I introduced a new Lua function - ScenEdit_InputBox ('message') which prompts with a message, and returns the data entered back to the script.
Example
local response = ScenEdit_InputBox('How are you today')
print('Response was ' .. response)

You can interrogate the response to act on things. It is fairly simple, but I was really after getting a bit of dialogue going between the script and the player

For Yes/No type dialog easiest way imho is to apply style=4 in ScenEdit_MsgBox, for example:

local dialog = ScenEdit_MsgBox('Authorize strike?', 4)
print(dialog)
Good one. Forgot about that. Reminds me to update the Lua functions document to include the possible style numbers (and there meaning)
Michael
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Including/Scripting A Yes/No Option in a Scenario

Post by butch4343 »

Gents,

Thanks so much for the replies, Stilesw thanks for the screen shot, that takes a dunce like me through it step by step,

Thanks guys once again , the community has come up trumps for me [:)]

butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Including/Scripting A Yes/No Option in a Scenario

Post by butch4343 »

Gents,

Could I ask a further question, I know am a pain in the postierior!

Does anyone have a working LAU script, for add explosion, that they could post up, I have tried to follow the instructions from Baloogans page on how to use it, but I seem to be messing it up somewhere, I wondered if anyone could post a working version so I can compare it to mines?

Mines is :

ScenEdit_AddExplosion ({warheadid=253, lat=unit.latitude, lon=unit.longitude, altitude=unit.altitude})

which translates into a minuteman warhead going off near allstedt when a RAF Aircraft penetrates the zone.

ScenEdit_AddExplosion ({warheadid=1603, lat=51.434., lon=11.342, altitude=0})

I presume the lat longs need to be converted to the decimal format and the altitude is zero for a ground burst? Is it metres or feet?

Can anyone see where I have gone wronng? Ive included a copy of the sceanrio , all you need to do is select the RAF side and fly any aircraft over Allsted Airfield

Thanks again in advance
Attachments
TheEmpire..1962V2.zip
(115.24 KiB) Downloaded 4 times
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Including/Scripting A Yes/No Option in a Scenario

Post by michaelm75au »

From one of my Steam Sandboxes http://steamcommunity.com/sharedfiles/f ... =682886045
--------------------------
v = math.random (-5,5);
target = {};
-- note that guid is from the export INI template as it is not that easy to get named locations
-- also is probably safer ..
table.insert(target,'54381d09-ea1b-4c1e-b70d-e51f44798674'); -- SAM BTY (I-HAWK)
table.insert(target,'ac0f60cb-6336-45b5-9985-7dfceee732d5'); -- SAM BTY (I-HAWK)
table.insert(target,'6398beea-4f07-4d97-b97b-9b7a30d8ec7c'); -- SAM BTY (I-HAWK)
table.insert(target,'0ff13833-1c3c-4fb7-bf6d-3407bec315c4'); -- SAM BTY (I-HAWK)
table.insert(target,'6c2e76a7-a966-4b4e-af0e-a96d2fa3a44e'); -- Sam Bty (Patriot)
table.insert(target,'cfa7180c-7be7-4cef-8df8-ecd56587da05'); -- Sam Bty (Patriot)
table.insert(target,'3ab40869-fe5c-45c6-8573-f4fbeef70ff2'); -- SAM Bty (Sky Bow III Bty [Tien Kung 3])
table.insert(target,'f247cfaa-dcde-4f24-93e6-d6dec7b20c50'); -- Tainan Ammo Bunker (Surface)
table.insert(target,'aed36768-5784-4032-ac81-62b291c43791'); -- Tainan Ammo Bunker (Surface)
table.insert(target,'75adf018-aa17-4247-94b0-17e0487bb279'); -- Tainan A/C Hangar (2x Medium Aircraft)
t = math.random(1,10);
unit = ScenEdit_GetUnit({guid=target[t]}) -- return the unit information
if unit ~= nil then
print(unit)
for weapon = 1, 5, 1
do
-- 1.4kg HE warhead delivered from RPG, have it explode near the unit
ok=ScenEdit_AddExplosion ({warheadid=253,lat=unit.latitude,lon=unit.longitude,altitude=unit.altitude +v})
end
ScenEdit_MsgBox('A RPG attack has occured on '.. unit.name,0)
end
Michael
bearhunter007
Posts: 23
Joined: Sat Mar 11, 2017 2:51 am

RE: Including/Scripting A Yes/No Option in a Scenario

Post by bearhunter007 »

Michael,

Thanks for posting your script. I especially like how you detail the use of a custom table. Tables are a unique feature of the LUA language.

butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Including/Scripting A Yes/No Option in a Scenario

Post by butch4343 »

Gents

Thanks once again, that is a great help.

Butch
Post Reply

Return to “Mods and Scenarios”