-
September 25th, 2015, 23:00 #1
- Join Date
- Dec 2008
- Posts
- 53
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());
-
September 25th, 2015, 23:15 #2"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!
-
September 26th, 2015, 22:02 #3
- Join Date
- Dec 2008
- Posts
- 53
the first option works perfectly. thnx
-
September 29th, 2015, 23:35 #4
- Join Date
- Dec 2008
- Posts
- 53
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" /> ...
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>
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
-
September 29th, 2015, 23:38 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,553
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
-
September 30th, 2015, 18:26 #6
- Join Date
- Dec 2008
- Posts
- 53
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)
Last edited by hereander; November 4th, 2015 at 22:55.
-
September 30th, 2015, 20:00 #7
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!
-
October 1st, 2015, 23:31 #8
- Join Date
- Dec 2008
- Posts
- 53
[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,
hereanderLast edited by Trenloe; September 4th, 2017 at 20:52.
-
October 2nd, 2015, 05:55 #9
I havent tested this yet but - good work hereander!
I will test this soon
-
October 14th, 2015, 10:32 #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.
ChungWargamers Consortium - https://www.wgconsortium.com
Wargaming Youtube - https://www.youtube.com/wgconsortium
Roleplaying Youtube - https://www.youtube.com/rpgconsortium
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks