STAR TREK 2d20
Page 1 of 3 123 Last
  1. #1

    Posting chat message only to myself?

    Hi!
    I am working on an extension for 5E which calculates the difficulty of an encounter in relation to the currently logged in party.
    The idea is to be able to change adjust the encounters of the official modules in-game if some player is missing or if the encounter might be too easy/difficult.
    I would like to post the result with some statistics to the chatwindow but only visible to myself.

    Trying to set the recipient like this does not work.
    Code:
    Comm.deliverChatMessage(msg,User.getUsername());
    Any idea how the second parameter of that funktion is supposed to work?

  2. #2
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,384
    Quote Originally Posted by hereander View Post
    Hi!
    I am working on an extension for 5E which calculates the difficulty of an encounter in relation to the currently logged in party.
    The idea is to be able to change adjust the encounters of the official modules in-game if some player is missing or if the encounter might be too easy/difficult.
    I would like to post the result with some statistics to the chatwindow but only visible to myself.

    Trying to set the recipient like this does not work.
    Code:
    Comm.deliverChatMessage(msg,User.getUsername());
    Any idea how the second parameter of that funktion is supposed to work?
    Use Comm.addChatMessage(msg). You can however use deliver function and pass nothing or empty table as second parameter to pass that to GM only
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  3. #3
    the first option works perfectly. thnx

  4. #4
    I have got some follow-up questions as a ruleset noob.

    I have my lua script defined at window level of the encountersheet

    Code:
    <root>
    	<windowclass name="battle">
    	<script file="scripts/5EEncCalc.lua" />
    ...
    then i call my main calculation function from a buttoncontrol

    Code:
    			
    <buttoncontrol name="calc">
    	<anchored to="contentframe" position="belowright" offset="10,-13" width="33" height="26" />
    	<icon normal="button_arrowdown" pressed="button_arrowdown_down" />
    	<tooltip textres="battle_tooltip_calc" />
    	<gmvisibleonly />
    	<script>
    		function onButtonPress()
    			window.calcEncounterDifficulty();
    		end
    	</script>
    </buttoncontrol>
    how can i access the window instance and its databasenode from within that function?
    it tells me that the (global) variable window is nil in this context.
    I was expecting it to be available as sort of a "this" pointer

  5. #5
    We'd have to see your code and the exact error message, but the "window" variable is set for every control/field object defined within a windowclass.sheetdata tag. I've been using it all day without issues.

    Regards,
    JPG

  6. #6
    I have attached a zipfile with a stripped down extension which just contains the problem. when you open an encounter and press the button that I added you will see

    Code:
    Script Error: [string "scripts/5EEncCalc.lua"]:9: attempt to index global 'window' (a nil value)
    That is where I am trying to access window from within the function
    Last edited by hereander; November 4th, 2015 at 22:55.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by hereander View Post
    I have attached a zipfile with a stripped down extension which just contains the problem. when you open an encounter and press the button that I added you will see

    Code:
    Script Error: [string "scripts/5EEncCalc.lua"]:9: attempt to index global 'window' (a nil value)
    That is where I am trying to access window from within the function
    Because the script 5EEncCalc.lua is tied to a windowclass (not a control) and that windowclass is the highest level window in the hierarchy, using the window variable (i.e. the window in which the control resides) doesn't return anything, as the window is not residing in another window. You can use self to return the reference to the window itself. You can also very often do away with self completely, for example: self.getClass() and getClass() would return exactly the same thing (the classname of the current window).

    Continuing on from this, your code was looking for the exp field, which is within a different windowclass "battle_header" (actually a subwindow) so you'll need to navigate through the subwindow to get to the exp field:

    Debug.console(header.subwindow.exp.getValue());

    Note that I'm not using self here as it's not needed, but the same result could be obtained with: self.header.subwindow.exp.getValue();
    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
    [MODERATOR] Note - this extension has compatibility issues with the current version of the 5E ruleset.

    Thnx a lot for your help guys!
    I just finished a first version of the extension. Please feel free to test it.

    How it works

    Activate the extension for your campaign
    Attachment 11192

    In the options dialog you can choose wether you want the extension to fetch the party's level information from the CT or from the Partysheet.
    The choice should depend on where the current party setup is represented in your session (remember: the idea is to be able to adjust encounters if players are missing a session)
    Attachment 11189

    When you open an encounter you will find a button at the bottom saying "Encounter Difficulty". If you press it, the calculation will be posted to the chat window. Thats it!
    Attachment 11190

    cheers,

    hereander
    Last edited by Trenloe; September 4th, 2017 at 20:52.

  9. #9

  10. #10
    I'm not sure if this is working right.

    Based on my party of one 2nd level and two 3rd level char, the Party XP threshold is the following:

    200
    400
    600
    1000

    Calculated the difficulty with just one Peryton at the adjusted XP value of 450 the encounter should be medium. Your add on is giving me the rating at EASY at 225 adjusted XP. Not sure where the 225 adjusted XP is coming from.

    Reading off from both the party sheet and the CT.

    Chung

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in