Need some Lua halp with a Special Action

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
BeirutDude
Posts: 2799
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

Need some Lua halp with a Special Action

Post by BeirutDude »

Want to charge a side (Russia) 2500 VP for requesting release of nuclear weapons. The nuclear release works fine but something I can't figure out is wrong with the subtraction of the VPs...

ScenEdit_SetDoctrine({side="Russia"}, {use_nuclear_weapons="yes" })
ScenEdit_SetAction({mode='add', type='Points', name='Russia loses some ..', SideId='Russia', PointChange=-2500})
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
BDukes
Posts: 2693
Joined: Wed Dec 27, 2017 12:59 pm

RE: Need some Lua halp with a Special Action

Post by BDukes »

Hmm.. Isn't the type = PointChange

Mike
Don't call it a comeback...
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Need some Lua halp with a Special Action

Post by KnightHawk75 »

Why do you need an separate action if it's contained in a SA and not just:
ScenEdit_SetScore("Russia", ScenEdit_GetScore("Russia") - 2500,"Nuclear release authority granted"); ?

But if you were trying to create an Action (tied to some trigger) the issue is name vs description.
ScenEdit_SetAction({mode='add', type='Points', Description='Russia Authorizes Nukes (point change)', SideId='Russia', PointChange=-2500})


User avatar
BeirutDude
Posts: 2799
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

RE: Need some Lua halp with a Special Action

Post by BeirutDude »

ORIGINAL: KnightHawk75

Why do you need an separate action if it's contained in a SA and not just:
ScenEdit_SetScore("Russia", ScenEdit_GetScore("Russia") - 2500,"Nuclear release authority granted"); ?

But if you were trying to create an Action (tied to some trigger) the issue is name vs description.
ScenEdit_SetAction({mode='add', type='Points', Description='Russia Authorizes Nukes (point change)', SideId='Russia', PointChange=-2500})

So I'm trying to do two things in one SA, allow the player to grant nuclear release at a cost of a certain number of VPs (likely -2,500). Seems like the first option will take away any points they gained and set the score to -2,500 which I don't want to do. but if say they have gained 3,000 VPs so far and then decide to go nuclear, after the SA is invoked I want them to have 500 VPs remaining (in that particular example).
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
User avatar
BeirutDude
Posts: 2799
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

RE: Need some Lua halp with a Special Action

Post by BeirutDude »

ScenEdit_SetAction({mode='add', type='Points', Description='Russia Authorizes Nukes (point change)', SideId='Russia', PointChange=-2500})

Yeah, this gets me the same thing, nothing. I ran the scenario using this in the SA and in theory Russia should have -2,500 VPs right now but it's still zero. I've been playing with this for hours! Its funny the simple stuff is hard, and the seemingly hard stuff not so bad! This shouldn't be this hard, but it's not working.

Image
Attachments
Capture.jpg
Capture.jpg (37.03 KiB) Viewed 325 times
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Need some Lua halp with a Special Action

Post by KnightHawk75 »

Yeah, this gets me the same thing, nothing. I ran the scenario using this in the SA
You do not run that in the SA itself, that Creates an Action, it does NOT execute it. Go look in your actions you'll see it's there (remove it though). Actions must be tied to triggers if you want them to execute, or if you were like re-using or manually wanted to call the actions you could use ExecuteEventAction('thename') after creating it. Anyway doing either is making it more complicated then it needs to be.
So I'm trying to do two things in one SA, allow the player to grant nuclear release at a cost of a certain number of VPs (likely -2,500). Seems like the first option will take away any points they gained and set the score to -2,500 which I don't want to do
Nope, it first gets the current score and removes 2500 from the current score and is the simplest way to do what you want.
Put this in your SA and you should be good to go:

ScenEdit_SetDoctrine({side="Russia"}, {use_nuclear_weapons="yes" });
ScenEdit_SetScore("Russia", ScenEdit_GetScore("Russia") - 2500,"Nuclear release authority granted");

Image


User avatar
BeirutDude
Posts: 2799
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

RE: Need some Lua halp with a Special Action

Post by BeirutDude »

OK, I'm headed out the door for work now and will give it a try tomorrow. Thanks for your help!!!!
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Need some Lua halp with a Special Action

Post by KnightHawk75 »

Your welcome, let me know if you run into any further issues.
User avatar
BeirutDude
Posts: 2799
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

RE: Need some Lua halp with a Special Action

Post by BeirutDude »

Nope, it first gets the current score and removes 2500 from the current score and is the simplest way to do what you want.
Put this in your SA and you should be good to go:

ScenEdit_SetDoctrine({side="Russia"}, {use_nuclear_weapons="yes" });
ScenEdit_SetScore("Russia", ScenEdit_GetScore("Russia") - 2500,"Nuclear release authority granted");

Thanks that worked and I see what you did. I would have played with it for a week and never through of calling up the score with a Lua function within a function. Again TY.
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
Post Reply

Return to “Lua Legion”