Starfinder Playlist
  1. #1

    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.

  2. #2
    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?

  3. #3
    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é
    Attached Files Attached Files

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,532
    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]);
    Where self.target[1] is the name of the save - "constitution", for example, and window.getDatabaseNode() returns the database node of the PC making the roll.

    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.
    FG Con 16 – Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    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!

  5. #5
    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.

  6. #6
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    22,161
    Blog Entries
    1
    Is this a typo?
    doUndeadFortituteRoll

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,532
    Quote Originally Posted by Simerion View Post
    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).
    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.
    FG Con 16 – Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    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!

  8. #8
    Yes, my english isn't very good, typos can happens...

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Joshua Stream Pre

Log in

Log in