PDA

View Full Version : Posting chat message only to myself?



hereander
September 25th, 2015, 23:00
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.

Comm.deliverChatMessage(msg,User.getUsername());

Any idea how the second parameter of that funktion is supposed to work?

Ikael
September 25th, 2015, 23:15
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.

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

hereander
September 26th, 2015, 22:02
the first option works perfectly. thnx

hereander
September 29th, 2015, 23:35
I have got some follow-up questions as a ruleset noob.

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



<root>
<windowclass name="battle">
<script file="scripts/5EEncCalc.lua" />
...


then i call my main calculation function from a buttoncontrol



<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

Moon Wizard
September 29th, 2015, 23:38
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

hereander
September 30th, 2015, 18:26
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


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

Trenloe
September 30th, 2015, 20:00
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


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 (https://www.fantasygrounds.com/refdoc/subwindow.xcp)) 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();

hereander
October 1st, 2015, 23:31
[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
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)
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!
11190

cheers,

hereander

damned
October 2nd, 2015, 05:55
I havent tested this yet but - good work hereander!
I will test this soon :)

cychow
October 14th, 2015, 10:32
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

hereander
October 16th, 2015, 11:40
thnx for the feedback. I am gonna check that later today

hereander
October 16th, 2015, 22:30
I think i spottet it. In LUA array indexes start with 1 and not 0 like in C and Java. I always keep forgetting that :/
This means the adjusted multiplier is always one category too low.
Gonna fix that

Kelendros78
October 25th, 2015, 22:45
has this been resolved? just curious

hereander
November 4th, 2015, 22:56
i changed the attachment in the original post. i think i fixed it. please check

jajen2003
November 23rd, 2015, 13:59
I see that it's posting the XP summary for various difficulties in the chat window, but at the same time, it's generating a LUA error and causing FG to lock up on me.

I'm running the 5E ruleset v3.1.3 and running FG v3.1.4.

Thoruk
January 2nd, 2016, 22:41
It doesn't show any errors with me, but it shows the wrong multiplier.

It shows like this:
1 Monster = Multiplier 0.5
2 Monster = Multiplier 1
3 - 6 Monster = Multiplier 1.5
7 - 10 Monster = Multiplier 2
11 - 14 Monster = Multiplier 2.5
15 + Monster = Multiplier 3

But according to the PHB it should be:

1 Monster = Multiplier 1
2 Monster = Multiplier 1.5
3 - 6 Monster = Multiplier 2
7 - 10 Monster = Multiplier 2.5
11 - 14 Monster = Multiplier 3
15+ Monster = Multiplier 4


Except of this it seems to work just fine with me.
Thanks a lot for this phenomenal tool (When it is fixed, it will also make the encounter calculation for my offline games a lot easier ;))

jeskr
March 18th, 2016, 20:05
Is this tool fixed and running now ?

It seems to me, it still has calculating problems. Not showing correcct :(
It would have been a cool tool.

PsychoPif
March 20th, 2016, 20:44
Seems to me like there is a bug with this extension. When I have it enabled, the arrow to refresh the XP and the CR on the encounter window are disabled.

spite
March 20th, 2016, 21:49
Came here to say the same as PsychoPif, this extension no longer seems to work with the encounter window, removing the refresh arrows on my version aswell.

Trenloe
March 20th, 2016, 21:52
It looks like this extension needs an FG version compatibility update. Hopefully the author will look into this...

chillman0122
May 1st, 2016, 15:09
As of now, it's also not working in the sense that it doesn't ignore low-level monsters when calculating the multiplier. For example, if I build an encounter with 1x CR9 and 10x CR1/4, the encounter comes out around CR14-ish. I don't know anything about it, but I'll poke around, see what I can scare up. Trenloe, would you be willing to pull this off the general 5e community extensions for the time being, since it's broken and there's been no reply from the author for a while?

Trenloe
May 2nd, 2016, 17:27
Trenloe, would you be willing to pull this off the general 5e community extensions for the time being, since it's broken and there's been no reply from the author for a while?
Moved the link to the old extensions section - with a label saying it needs a new community developer to update.

chillman0122
May 2nd, 2016, 20:19
Thanks - I'll keep picking at it. I have no idea what I'm doing, but I've a got a lot of free time right now and a good chunk of the heavy lifting is done already. Who knows? Maybe I'll do something useful.

ghilteras
April 12th, 2017, 00:20
delete me