Need some Lua halp with a Special Action (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


BeirutDude -> Need some Lua halp with a Special Action (2/7/2022 11:04:39 PM)

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})




BDukes -> RE: Need some Lua halp with a Special Action (2/7/2022 11:09:15 PM)

Hmm.. Isn't the type = PointChange

Mike




KnightHawk75 -> RE: Need some Lua halp with a Special Action (2/8/2022 12:27:38 AM)

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})






BeirutDude -> RE: Need some Lua halp with a Special Action (2/8/2022 2:42:42 AM)

quote:

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).




BeirutDude -> RE: Need some Lua halp with a Special Action (2/8/2022 3:05:39 AM)

quote:

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]local://upfiles/44561/822FB907FC98421EBA15BCBEACC7033E.jpg[/image]




KnightHawk75 -> RE: Need some Lua halp with a Special Action (2/8/2022 3:29:02 AM)

quote:

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.

quote:

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");

[img]https://i.postimg.cc/v4NWWLz9/Auth-Nukes-SA.jpg[/img]






BeirutDude -> RE: Need some Lua halp with a Special Action (2/8/2022 3:31:38 AM)

OK, I'm headed out the door for work now and will give it a try tomorrow. Thanks for your help!!!!




KnightHawk75 -> RE: Need some Lua halp with a Special Action (2/8/2022 3:33:45 AM)

Your welcome, let me know if you run into any further issues.




BeirutDude -> RE: Need some Lua halp with a Special Action (2/8/2022 9:52:45 PM)

quote:

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.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.171875