-
May 18th, 2020, 18:56 #1
- Join Date
- May 2018
- Posts
- 21
5e How execute save-check from lua?
I try to execute a Saving Throw from lua code, but something is always missing. I have target and source, and i wan't make an constitution-saving throw agains a calculated DC and do something depending on the result.
Have one an example for me?
I'm sorry, I missed the "Coding dice rolls (actions) in CoreRPG" post. Must have been half asleep. I try it again...Last edited by Simerion; May 19th, 2020 at 07:28.
-
May 19th, 2020, 17:15 #2
- Join Date
- May 2018
- Posts
- 21
I read "Coding dice rolls (actions) in CoreRPG" post and try many things, but i have a problem:
First i havn't find any way to do a 5e save-throw and get the result back. I create a new action, execute it with performAction (draginfo is nil, i havn't it in this context) and get the result in the event-handler, but i haven't access to the Actor there (and rSource and rTarget-Parameter are nil) - the result without the Actor doesn't help me.
How can i make an roll, get the result and have access to the Actor-Data?
-
May 20th, 2020, 06:54 #3
- Join Date
- May 2018
- Posts
- 21
I try another way, can me anyone says if this is okay?
I can not embed the code in the text, supposedly it contains some forbidden words (unfortunately without specifying what they should be). I append it as Attachment.
cu André
-
May 20th, 2020, 07:41 #4
The save action is already coded in 5e in the scripts\manager_action_save.lua script file - which is the ActionSave global script package.
To see how to initiate a save, look at the code attached to where saves are initiated in the 5e ruleset - for PCs in the character sheet, main tab, using the number_charabilitysave button. The code in that button to initiate the save is:
Code:local rActor = ActorManager.getActor("pc", window.getDatabaseNode()); ActionSave.performRoll(draginfo, rActor, self.target[1]);
If you want to do a roll vs a target DC then you'd call SaveAction.performVsRoll - which has more arguments. See line 92 in the 5e ruleset scripts\manager_action_save.lua script file. An example of where this is called is in the 5e scripts\manager_action_power.lua file on line 30 - this whole action structure is called via the performSaveVsRoll at line 155. An example of where this is called is ActionPower.performSaveVsRoll(draginfo, getActor(), rAction); in ct\scripts\ct_power.lua.
From all of this you can see that it is quite complex. You may want to look at how the scripts\manager_action_power.lua script file is used to execute the saves and use this as your basis. Note - as I describe in the forum thread you reference, you will need to define a new action type to do anything like this.Last edited by Trenloe; May 20th, 2020 at 07:55.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 20th, 2020, 09:04 #5
- Join Date
- May 2018
- Posts
- 21
My goal is not to carry out a manually initiated action, but to do this automatically in the damage treatment. Here I have neither "draginfo" nor the possibility to use a "performXXX" method (since I need the result and the goal to adjust the wounds and remove the Unconscious-Effect).
I have change the first version of the dmsguild-Extension "AutomaticDeathResistance" for my purposes and add this (the actual version do the same now, but only on base of the attribute-value, i wan't a variant that use the regular save-mechanism as far as posible).Last edited by Simerion; May 20th, 2020 at 09:12.
-
May 20th, 2020, 10:53 #6
Is this a typo?
doUndeadFortituteRoll
-
May 20th, 2020, 11:00 #7
That's why I included the last paragraph describing how the manager_action_power script defines some actions that use the underlying SaveAction package.
Remember that any dice roll is done asynchronously, you can't pause a script and wait for a dice roll result. So, if you want dice to roll, you'll need to use an action and code for the asynchronous dice results.
Second, if this is a standard save roll, then you want to use the underlying ActionSave mechanism so that it will automatically take into effect all of the modifiers and effects that can impact a save. If you don't use SaveAction, then you're either going to have to code for everything that could impact a save in your own code, or you lose a lot of the FG automation.
Like I mentioned, I'd recommend looking at how the manager_action_power script uses different actions that use the underlying SaveAction package. However, you're going to get complexities because of the asynchronous aspects of dice roll. What you're trying to do is very complex.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 20th, 2020, 11:56 #8
- Join Date
- May 2018
- Posts
- 21
Yes, my english isn't very good, typos can happens...
-
May 20th, 2020, 12:11 #9
- Join Date
- May 2018
- Posts
- 21
I know the dice rolls are asynchron, that is not my problem, i will try the variant from manager_action_power-Script.
I have problems with the understanding the FG-Code, not with programming concepts or complex logic - I am neither used to dynamic languages nor do I find the documentation sufficient, but I have been developing software for more than 2 decades. This are my first steps with FG and lua. Another problem is certainly that I most likely have time for FG when I am already tired ;p
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks