#Custom System Builder
1 messages · Page 17 of 1
Good 😉
and we now have a working foundry sheet for the Legend RPG
not open legend, which already has one 😛
Cool 👍🏻
According to @blazing ibex, they've set it up all correctly, but when I try to get the templates through game.system.template.Item, it doesn't have any of their configured props
You can actually see it working, but not where it should be
The "Qty" is a custom column that's supposedly checking the same variable as the default "Quantity" column
Were you having the same issue?
It looks that this user also had the problem #1037072885044477962 message
All my CSB Worlds' launch icons have vanished, replaced by a "Requires Dependencies" icon ... did I delete a Module that's required or somethign?
- It is compatible with V11 and is also under active development
- Well, I don´t know how to answer that... If you want to know what is possible, then it might be worth to check the sheet-library of CSB: https://gitlab.com/custom-system-builder/custom-system-builder/-/tree/develop/sheet-library?ref_type=heads. It´s also worth to take a look at the Example-Template
- I´m not familiar with Midi, but you´re able to integrate own macros and scripts if you like
- Well, CSB lacks a bit of performance optimizations... But I´m able to run Shadowrun-6 with tons of Items on a Raspberry PI without many performance-drops. Only the initial load takes a few seconds.
CSB has Chat Commander as a hard dependency. Install that if you haven´t.
- yes, writing your own code will always be more flexible than using someone else's sub-framework. But if CSB can do what you need it's a lot faster.
- this isn't CSB specific, right? Yes, in Foundry in general, if you have "tons" of Actors or Items, it will be more performant if you put many into Compendia.
that was it, I had uninstalled it since it looked situational.
Thanks.
For CSB to do that I think you'd need to Extend it with a Module of your own make.
That´s doable, yeah
Are lighting rules more of a System thing or more of a base Foundry thing? Like the dark/dim/bright light division.
The rules are system-specific. Status and visuals come from Foundry
what do you mean by Status and Visuals?
and, if I want to make a change to lighting from the way CSB has it, I assume that's within the scope of a Module without making a whole new System?
Although I have read through the wiki, I have not been able to find a solution when multiple conditions must be true. My approach:
${Bedingung-1 ? Bedingung-2 ? Bedingung-3 ? mach das : mach nix}$
${item.key_item_phiole_effekt_dauer_label >= 1? item.key_item_effekt_auswirkung_lp == true ? item.key_item_phiole_wirkung_plus == true ? setPropertyInEntity('self', 'numberfield_lpakt', "numberfield_lpakt+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
Where is my mistake?
And is there the possibility to define OR-conditions as well or are all conditions always AND?
Thank you very much!
You can use the or and and-operators: https://mathjs.org/docs/expressions/syntax.html#operators
Math.js is an extensive math library for JavaScript and Node.js. It features big numbers, complex numbers, matrices, units, and a flexible expression parser.
This way:
${item.key_item_phiole_effekt_dauer_label >= 1 AND item.key_item_effekt_auswirkung_lp == true AND item.key_item_phiole_wirkung_plus == true ? setPropertyInEntity('self', 'numberfield_lpakt', "numberfield_lpakt+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
In lowercase
👍
${item.key_item_phiole_effekt_dauer_label >= 1 and item.key_item_effekt_auswirkung_lp == true and item.key_item_phiole_wirkung_plus == true ? setPropertyInEntity('self', 'numberfield_lpakt', "numberfield_lpakt+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
Although all three conditions are true, 0 is output.
Or of course key_item_phiole_effect_duration_label >= 1 😉
Versuchs mit Klammern um die Bedingung, also alles vor dem ?
I'm having some trouble with the attribute bars. I want to do one for HP, with HP and maxHP as the component keys to use for the value and maximum for it. But I can't figure out what format it wants. The fields keep coming up blank, so the token claims NaN.
No luck even with 'self'. I continue to just get a chat message of 5 and the function does not change the value of AmmoCountPrimary. Can anyone post an example of a working setPropertyInEntity() ?
Well, I don't know what to say. It should work in that form.
Only thing that comes to mind is that if AmmoCountPrimary is in an item you have to use "item.AmmoCountPrimary" instead.
Decrease the ammunition total by one in the current item in an Item Container: setPropertyInEntity('item', 'Ammunition', "item.Ammunition - 1")
Every function has examples btw
Thanks Martin and Torlan. I have tried that example Martin initially and had no success. I started to trying other examples from the documentation and when i still had problems, i posted here. Here are some screenshots showing all the components and syntax i am using. These components are simple ones so i can figure out what i am doing wrong and are not what i plan on using setPropertyInEntity() in the future.
Oh well, it all looks fine to me. Can you try setPropertyInEntity('self', 'label_slick', "label_slick+5") and see what happens?
No luck. This really has me stumped.
Hmmm. I'm out of ideas, sorry 'bout that.
setPropertyInEntity() can only affect Input Components, so Labels are out.
Oh well, my bad
I'm building myself a system to play Heavy Gear 2e. Started out thinking I'd just put all the right fields in, and then play it pretty much manually. But of course... it's hard not to try and make it smoother. 🙂
I'm trying to figure out if there's a way to track the number hexes an actor moves during a combat turn. Preferably through core Foundry/CSB, but I know Drag Ruler has movement history so that's an option as well (I just don't know how to access that data).
Basically I want to track movement so I can use it for modifiers when attacking/defending.
That would be hard because CSB has no concept for movement
Ok, so that leaves the data in Drag Ruler. Another (less satisfactory) option would be to have a prompt asking you to enter the number of hexes moved after you release an actor during combat, that could then be used for mods etc. 🤔
That would be system.props.key
What would that be? Drag ruler data?
Yeah
Ok, I could try digging around there and see what I find. Thanks!
Well, you basically tell Drag Ruler how far a character can move. For that, you can use data from CSB directly
Yes, drag ruler works fine right now. I just want to track the number of hexes moved in a label key so I can use it for attack modifiers, ie "Jaguar has moved less than half it's Combat Speed so get +1 on attack rolls" etc.
That one would be trickier. You´d need 2 things:
- You need to check if Drag Ruler is even providing that data (how far did my character move in this round...)
- You need to update the actor sheet accordingly (changes in drag-rulers data are not mirrored to CSB automatically, this will be your responsibility)
It feels like it should be doable somehow... just need to figure out where that data is located (if it even is!). A bit too late today though, but thanks for the pointers.
By the way... I've cobbled together a script for the fairly unusual dice roll formula. Basically it's a keep highest d6 dicepool, except each 6 beyond the first adds +1 to the result, and if you roll all 1s the result becomes 0. I've got it working reasonably well, but it produces two logs in chat - one from the GM and one from the actor just containing "Undefined".
I guess it's something about the script not containing triggering actor data so the roll output doesn't include it, but I'm not sure how to go about fixing it. First calling the actor somehow and then having the script include it somehow...
The macro looks like this:
const roll = await new Roll(`${amount}d6kh`).evaluate(); const numDice = roll.dice[0].results.length; const sixes = roll.dice[0].results.filter(r => r.result === 6).length; const ones = roll.dice[0].results.filter(r => r.result === 1).length; const bonus = !!sixes ? sixes - 1 : 0; const fumble = ones === numDice ? 0 : 1; roll._total = (roll._total + bonus + Number(`${mods}`)) * fumble; await roll.toMessage({flavor: "<h2>Attack!</h2>"});
And the label roll message:
%{return await game.macros.getName('Perfect!').execute({amount: '${gunnery_lvl_actual}$', mods: '${attack_mods_total}$'})}%
And chat output (numbers all correct, it just looks a bit weird).
A Label Roll Message will produce a Chat Message on its own (regardless of your Script). It will be possible to suppress that in the next version. For now you can add the workaround with %{throw 'Done'}% at the end (thrown Exceptions are stopping further code-execution, thus stopping the creation of the Chat Message)
Ah, cool! Thanks!
I mean, this perfectly fine and means I can play without having to check the ones and sixes. But it woudl be nice to have the chat message be from the actor whose sheet triggered the script (in this case the Iguana).
That worked nicely! I guess I could try and get the actor name into the flavor text somehow. Or even better, if I could get the actor name, and also the name and damage value of the weapon used.
I'm wondering if someone can help me...I'm using the custom system builder 3.0.0. What I want to do is create attribute values on the tokens that are calculated from items dropped into an item container on the token. Like ARM = SUM(maxarm + maxstrut) / 3
How should I go about doing this?
So dropping in items add to a total bonus or total stat?
Arm lable should be ${sum(${maxarm}$ + ${maxstrut}$)/3}$
What I would do is edit one of the _templates for items to match the field names with and adjust the values based on your desired number. Then create a container matching and adjust sheet accordingly.
I havent gotten fully into making items but thats briefly how I read they worked. @mental rose
hmm
If you havent already installed them, grab the templetes that are in the example file. use the armor one and adjust to you needs and make a piece of equipment that would adjust as such
or creature
creature maybe your better options since its already fleshed out for the most part.
@formal goblet Can you hide fields from users in a dynamic table or is it broken atm?
setting the visibility for ownership doesnt seem to do much
Also, isnt there a way to reference dynamic table fields by using table.field? I thought I saw that somewhere
example file?
ah thank you
That's currently broken
darn ok,
Take a look at the FAQ of the wiki on how to transfer values from items to actors (the example with the weight). Then you need to define a complex attribute bar (non-editable from token) OR a number field with a max-value (editable from token).
Okay, I'll try to find that on the wiki
That did the trick, amazing. Thank you again. I dont see the limitation listed in the documentation 4.2.11 on gitLab. Should i have seen that somewhere else?
does anyone know why the value for currentHP doesnt get updated within the roll message for the purposes of referencing it, even if the value does get updated on the sheet? the functionality of this rest button does work, except the message at the end always says "Character heals 0 hitpoints." because currentHP is considered to have the same value by the end as at the start
Missing double-quotes for the 3rd parameter in setPropertyInEntity()
well, even with double quotes, it's not fixing the problem. setting the property works fine (and worked without the quotes too). i've modified the output a bit to show the problem. so, i started with 7/12 hitpoints (currentHP). after my dialog pops up, i choose to rest for 1 hour, which heals two hitpoints. i setPropertyInEntity, which works, leaving me with 9/12 hitpoints. however, when i check the value of currentHP afterwards, it still thinks that currentHP is 7
maybe the code after is executing too quickly, before the change is applied?
Ah, that's the thing. The actual sheet update is performed after the creation of the Chat Message probably
You can just get the result from setPropertyInEntity() btw
So, the property accessors access the view (character sheet)'s, not the model's values?
I'd need to take a look to be fair, not my implementation.
It actually seems to be more complicated. Updating the hidden input fields in the browser inspector does something, but it's delayed.
I checked it. It's a race condition, the update is not awaited 😅
ah, didnt realize it returned the adjusted value. managed a solution based on that, thanks!
Hi Martin,
ich hänge gerade an folgender Umsetzung, die leider nicht funktioniert:
${item.key_item_phiole_effekt_dauer_label >= 1 ? setPropertyInEntity('self', 'key_item_waffe_schaden_mod', "key_item_waffe_schaden_mod+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
Das Item mit dem Mod-Wert "key_item_waffe_schaden_mod" (Nummernfeld) liegt in einem ITEM-Container. Diesen Wert möchte ich durch einen Wert ändern "item.key_item_phiole_effekt_aktiver_wert_label". Ich bekomme bei der o.g. Anweisung weder eine Fehlermeldung in der Console, noch eine Ausgabe im Chat.
Für andere Werte, wie LP oder RW funktioniert es sehr gut...
Kannst Du mir hier weiterhelfen?
Dir fehlt ein item.-Präfix am Anfang des 3. Parameters.
${item.key_item_phiole_effekt_dauer_label >= 1 ? setPropertyInEntity('self', 'key_item_waffe_schaden_mod', "item.key_item_waffe_schaden_mod+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
So bekomme ich eine Fehlermeldung im Chat...
Statt self item
Leider immer noch eine Fehlermeldung im Chat...
${item.key_item_phiole_effekt_dauer_label >= 1 ? setPropertyInEntity('item', 'key_item_waffe_schaden_mod', "item.key_item_waffe_schaden_mod+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
Und der Fehler?
So, I'm still looking into Item Piles compatibility - since all default props are stored in the flags of the item templates, how would I construct a data-only representation of the different item templates?
Ie, if a setup has an item with system.props.quantity, how can I know if that type of item has that setup without checking the items' props?
Checking the flags.custom-system-builder.templateHistory seems a bit complex for this, I'm curious if there's a simpler way
Items have a link to the Item Template (ID) (Item Templates are also Items). So one way would be to find the item template via game.items.get(templateId).
yeah, but I can't seem to find the properties on the template item
I think at least the Item Keys are defined in the Template, but I'd need to take a closer look when I'm home.
@brittle moth feel free if you're faster 😅
In der Console: Error: Cannot convert "ERROR" to a number
Liegt es evtl. an der Struktur?
Diese Anweisung
${item.key_item_phiole_effekt_dauer_label >= 1 ? setPropertyInEntity('item', 'key_item_waffe_schaden_mod', "item.key_item_waffe_schaden_mod+item.key_item_phiole_effekt_aktiver_wert_label"):0}$
führe ich über "Anwenden" in dem ITEM "Effekt" aus (Effekt.png).
Dieser Wert soll sich auf den MOD-Wert (Number field: key_item_waffe_schaden_mod) einer Waffe (Waffe.png)
auswirken, die in einem anderen ITEM-Container liegt und diesen Wert entsprechend ändern.
Ein Item Container hat erstmal nur Zugriff auf die eigenen Items. Wenn du Werte von anderen Items verändern musst, dann musst du das über ein Script lösen.
I have to basically recurse through each template item to find out 😄
function findKeyInContents(elem, key){
if(Array.isArray(elem)){
return elem.some(subElem => findKeyInContents(subElem, key));
}
return elem.key === key || (elem.contents ?? []).some(subElem => findKeyInContents(subElem, key));
}
const templateItemId = game.items.getName("test").system.template;
const templateItem = game.items.get(templateItemId);
console.log(findKeyInContents(templateItem.system.body.contents, "quantity"))
is there a way to check 2 conditions in the roll message? like ${r1 >= 5 && r2 >= 5 ? "success" : "fail"}$
I have a bunch in a row its checking but only one of them has 2 conditions. I could break it out more but I was hoping for a cleaner way
oh nvm figured it out using ${min(r1,r2) >= 5
for the visibility section, whats the code you use to hide a component if a checkbox is empty?
not checkboxkey
including space?
Yes. But now that I read it you said 'hide if empty', so just leave checkboxkey and the field will show only when the box is checked.
I'm a little lost. It says 'visible if checked'...
Doing what?
deleting so this doesnt confuse anyone else
Hey, I want to do a roll, depending on a value on an item. This is my formula
${switchCase(item.stufe, '0',setPropertyInEntity('self', 'chaoswert_aktuell', "chaoswert_aktuell-1"), '1',setPropertyInEntity('self', 'chaoswert_aktuell', "chaoswert_aktuell-[1d8]"),'2',setPropertyInEntity('self', 'chaoswert_aktuell', "chaoswert_aktuell-[2d8]"),'3', setPropertyInEntity('self', 'chaoswert_aktuell', "chaoswert_aktuell-[3d8]"), '4', setPropertyInEntity('self', 'chaoswert_aktuell', "chaoswert_aktuell-[4d8]"),0)}$
Sounds weird but I'm pretty sure it worked as intended two days ago. Now it will evaluate the switchCase as if every item has 'stufe' == 4. Any ideas what the problem could be? No errors are thrown.
And the chat shows that every roll is thrown but only the 4d8 is applied
Read the last part of Conditions: https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Guides/Formula-System#314-conditions
I have a dynamic table that I want to reference to come up with a value but running into a bit of a wall.
SL_Chart <-- name of table
Chance <-- referenced by stat
SL-5 -> +10 returned
Stat identifies Chance
Roll identifies SL based on that chance number..
I have attempted this a couple of ways
${max(${Target_Number}$ >= first(fetchFromDynamicTable('SL_Chart','Chance', 'Chance')))}$ <-- returns true or false based on number
${fetchFromDynamicTable('SL_Chart', 'Chance', '100','==')}$ <-- populates blank.
Thought about using a switchCase but in this example I am trying to validate 3 values so wasnt sure..
Any suggestions would be welcome
Just for context
fetchFromDynamicTable has either 2, 4 or 5 input parameters, having only 3 does not make any sense because you are missing the target-value you want to compare against.
Your correct, I missed it earlier lol
${max(fetchFromDynamicTable('SL_Chart', 'Chance', 'Chance','${Target_Number}$','>='))}$
the max formula doesnt work as intended with this use case.. value of 60 produces a 90 which it should produce 65, 150 produces 500...
It should be providing the max number during the look up with the targeted number..
You should remove ${}$ from Target_Number if this is available in the same context. And this should also be a number and not a string
You have a logical issue. What you currently do is the following: "Give me all values in the column Chance from the table SL_Chart where Chance is >= Target_Number".
Target_Number is not in the same table and will be a static number, Chance will be a varible number therefor looking at chart to determine that varible.
"Give me all values in the column Chance from the table SL_Chart where Chance is >= Target_Number".
What I am attempting to asking
"Return the closest value in the column Chance from the table SL_Chart that is <= Target_Number".
It doesn´t have to come from the same table
OK good to know
Pulling the array, using sort to sort the array and having it return the max doesnt seem to work either lol
And the function is designed to return all values which meet the criteria
Ultimately, I need to take that single value closes to the target number and reference it again another 15 times against the same dynamic table. and return the Row Name
Sorry, trying to describe the full intent and use case for full understanding
You might want to work with a Script instead
I am putting it on paper, will get you a full understanding here in a second
Hope this makes sense
fetchFromDynamicTable('SL_Chart', Success_Level, 'Chance', floor(Target_Number / 5) * 5) with Success_Level being the key of one of the columns?
Hmm let me take a look and see if that will work
Has anyone used html enrichers to modify the rendered actor sheet or item sheet? I am hoping someone has an example.
on a checkbox is there a way to put a label icon?
I want to use a dice icon like you can on a normal label
Are you saying if the check box is checked it would be an icon instead of an empty box?
Can you reference a Component key of the label by using the %{return await game.macros.getName('YourMacro').execute({name: '${name}$'})}%
IE I dont want to have to modify the call since this could be going on something like a Dynamic table, and I want to roll from it
I think you can do that with CSS, but I´m not sure about that
hmm ok
No like on the labels, they have the "Label Icon" field where you can put the name of an icon like dice-d6. Checkbox only has "Label" so it shows text, but it would be awesome if it could do the icons too.
Are you asking if you can also use the component key of a Label to transfer its value to a macro?
Yes without having to manually designate it.. IE if a lable is listed as Str_Total, I dont need to hardcode the ${Str_Total}$ during the call
Do you have a text field which contains the key of a component?
%{return await game.macros.getName('macroName').execute({name: entity.entity.name, strength: ${Strength}$});}%
yes
Just use ref() then?
Can you do that as a call like above?
${Strength}$ is just a normal CSB-Formula, so yeah
I'll simplify my question:
how do you put rollable tables in conditional outputs like this:
${r1 == 0 ? "@UUID[RollTable.kWkgUoxqDkufFKIJ]{Conditions: Immediate}" : ""}$
Sorry but even after looking around I've found no answer.
Thanks for looking, yea Im stumped lol.
Trying to speed up the injury system in my game by linking the roll tables in chat
What's the outcome of that code?
Console errors?
Could it be RollTables instead of RollTable? Just guessing...
Well, I cannot test anything till tomorrow but I'll let you know if anything pops up.
If I just put that straight in the roll message it works but inside the conditional it breaks
like if my roll message is just "@UUID[RollTable.kWkgUoxqDkufFKIJ]{Conditions: Immediate}" it'll display normal, just cant get it to show selectively.
Don't know, have to tinker with it.
How about using ${!...}$?
Around the UUID string you mean?
No, for the whole Formula. ! is meant for removing the box in Label Roll Messages
Small hint:
- JS: Single Quotes
- HTML: Double Quotes
Just a conventional thing.
So are you saying put the ! here: ${!r1 == .......}$
y
still not working, gives that same error in the console.
Heres the whole roll message for context:
`<p>Fatigue result = <strong>${r1:=[:FatigueCurrent:d6cs=1]}$</strong></p>
<hr>
${!r1 == 0 ? "@UUID[RollTable.kWkgUoxqDkufFKIJ]{Conditions: Immediate}" :
r1 == 1 ? "<span style='color: darkred;'>Lingering Condition</span>" :
r1 >= 2 ? "<span style='color: darkred;'>Critical Condition</span>" :
""}$`
Basically I want all of those results to be roll tables, only the first one is now while im trying to get it to work
Does ${!'RollTableId'}$ work?
If not, then it will not be doable with CSB-Formulas
are you saying replace "@UUID[RollTable.kWkgUoxqDkufFKIJ]{Conditions: Immediate}" with ${'kWkgUoxqDkufFKIJ'}$ ?
Although... The example sheet uses a link as well. But the link is stored in the text of a RTA-Component and the Label Roll Message is just referencing that
Na, the whole UUID-thing
gave the same console error
maybe try with the module inline table rolls?
Ill try that
I cant even get it to use the RollTableId as a command via lable..
I know I remember seeing the wiki reference @UUID but I cant find it anymore
I can't remember that I've written anything with @ in the Wiki. There's only a small section in the Readme about that
Might of been where I saw it but I couldnt find it again lol
That worked perfectly!
it's good that the module recently changed the syntax, I can imagine the old [[ ]] causing problems with roll messages from CSB
(
function roll1d100() {
return Math.floor(Math.random() * 100) + 1;
}
const Chance = 85; // Replace with your Skill Value (Chance)
const roll = roll1d100(); // Roll a 1d100
let SL;
if (Chance >= -5) {
SL = Chance + 170;
} else if (Chance >= -4) {
SL = Chance + 120;
} else if (Chance >= -3) {
SL = Chance + 110;
} else if (Chance >= -2) {
SL = Chance + 60;
} else if (Chance >= -1) {
SL = Chance + 50;
} else if (Chance >= 0) {
SL = Chance;
} else if (Chance >= 1) {
SL = Chance;
} else if (Chance >= 2) {
SL = Chance / 2;
} else if (Chance >= 3) {
SL = Chance / 4;
} else if (Chance >= 4) {
SL = Chance / 4 - 10;
} else if (Chance >= 5) {
SL = Chance / 4 - 20;
} else if (Chance >= 6) {
SL = Chance / 4 - 30;
} else if (Chance >= 7) {
SL = Chance / 4 - 40;
} else if (Chance >= 8) {
SL = Chance / 4 - 50;
} else if (Chance >= 9) {
SL = Chance / 4 - 60;
} else if (Chance >= 10) {
SL = Chance / 4 - 70;
} else {
SL = 'Invalid Chance'; // Handle invalid Chance values
}
console.log(`Chance: ${Chance}, 1d100 Roll: ${roll}, SL: ${SL}`);
// Determine the result
let result = '';
if (SL >= -5) {
result = 'Succeeded';
} else if (SL <= 1) {
result = 'Failed';
} else {
result = 'Undefined';
}
console.log(`Result: ${result}`);```
Quick question here:
but trying to get this to trigger and replace Chance with whatever my lable will be .. lets say Skillfor the this example
%{return await game.macros.getName('Rolling').execute({name: entity.entity.name, Skill: ${Skill}$});}%
Would this be correct?
I dont quite understand the name: entity.entity.name entry in the wiki explaining it.. Does that reference the function to start?
I am working on the script above now so figured I would ask before everyone disappears
Simply try out %{console.warn(entity.entity.name)}% and you'll see what that is (keep the console open).
Baby developer here ... still learning things
Created ChatMessage with id [SqiL1Sw4sL0cmeSE]
logger[level](${vtt} | ${msg});
Hide log-level debug and info
I dont see how to hide them but I enabled verbose
Computing %{console.warn(entity.entity.name)%
console.debug('Computing ' + this._rawPhrase);
- Did you put it into a Label Roll Message?
- Did you reload the Actor?
This is what should come
You´re missing a closing brace
how do you set the value of another component on the sheet with a roll formula?
I have an initiative button that I want to set a hidden variable to the result.
is there a way to use a dropdown list's keys to change the value of a label ?
Yea if its label is ${DropDownComponentName}$
I have that for my weapons where there's a dropdown named WeaponTwoHanded
in this case your label would just became the name of your key right ?
In my case I have 3 weapons type in a dropdown list, and each type deal 1d6, 2d6 or 3d6 damage.
I want the damage to change when I change the weapon type in my dropdown list ( that's useless automatism I know, I just want to know if it is possible.
I tried with condition but it didn't work because it wasn't value ^^
I have something kinda similar but its manually typed in for damage
It works with a drop down too
Then I have that as the roll message
does that help? @rustic void
${[:DamageFormula:]}$ is the key to getting it to roll, you need [: :] around the variable name and itll treat it like a roll.
nop but it gave me another idea and this one working ^^
I'm not yet at the "rolling part" for now but I'll keep it in a corner for later 🙂
Im having an issue with my script where it cycles through each of these options instead of only doing the one that matches the condition:
${min(r1,r2) >= 5 ? "${#setPropertyInEntity('self', 'InitiativeCurrent', "6")}$" : r3 <= 3 ? "${#setPropertyInEntity('self', 'InitiativeCurrent', "1")}$" : r3 == 4 ? "${#setPropertyInEntity('self', 'InitiativeCurrent', "3")}$" : r3 >= 5 ? "${#setPropertyInEntity('self', 'InitiativeCurrent', "5")}$" : ""}$
The ternary will execute all parts regardless of the condition. For example:
isActive ? notify('info', 'This is active') : notify('info', 'This is not active') will execute both
notify()-functions regardless of the condition it will evaluate to. You should use it this way instead to prevent the
problem of double-execution: notify('info', isActive ? 'This is active' : 'This is not active'). This is a limitation
by the system, so be careful with that. Usually it´s not a problem, because most of the time CSB-Formulas are not
performing any active actions, but it will become one if you combine conditionals with actions (like notify() or
setPropertyInEntity()). If you still need short-circuiting conditionals, use
Script-Expressions instead.
Whats the easiest way to change the font of the whole character sheet?
Edit the json?
Idk the actual answer but assume the font is listed somewhere in the json. I can check in the morning if you cant figure it out
I found a way in a custom css module
Can I add a new entry in a dynamic table from code?
Since there is no possible to add in the hotbar a macro from a item container, I think to put a button in the item container that copy the info of the item to a dynamic table. It is possible?
Thanks in advance
You can with javascript.
Is there a place to share our macros, sheets and code? I know github has sample sheets but being this is a purely custom system it would be nice to have a place where people can contribute. Just my 2 cents
Hey, can I get a little help to create at least 2 attributes regarding this issue ?
I don’t think I need much more than that.
I think the module Bar Brawl lets you create bars with static values. Otherwise if you want bars which are dependant on sheet-values, you only need 2 things:
- A number field component
- A defined max-value in the number field
Fiddling around with a row of checkboxes for HP, and trying to make a formula that an earlier checkbox if a later checkbox is checked.
Just having this as a separate label/secret attribute doesn't work, although it seems to me it should. 🙂
${inf_member_01_dambox_02 == 1 ? setPropertyInEntity('self', 'inf_member_01_dambox_01', 1) : ''}$
I’ll try that !
Aha... so it would be tricky without script expression?
No, just put the condition into the function
Struggling with this:
${setPropertyInEntity('self', "EntityInitiative1", "fetchFromActor("${EntityName1}$", "InitiativeCurrent")")}$
Goal is I hit a button and it fetches the last rolled initiative value from each sheet written in the text boxes
fetchFromActor() bit is working, it grabbed the right number
I just cant figure out how to then set it as the label next to the text box.
Single quotes for the second and third argument maybe?
just tried that, nope
it wont replace that "None" text with the number it grabs
OK I have a macro that works but it doesnt post correctly in the chat
Here is what I got,
Top one is executing the macro by itself, the second is the call from the lable
Thing is double quotes for the third argument and inside it might be not correct. I'm just depending on my memory, so I might be wrong.
I usually do setPropertyInEntity('self','key', value) or `setPropertyInEntity('self','key', 'string').
Closing ) and } missing at the end, I think.
%{return await game.macros.getName('111').execute({roll: true, Chance: (${Target_Number}$)}% <-- throws error about syntex
%{return await game.macros.getName('111').execute({roll: true, Chance: (${Target_Number}$%)} <-- rolls but prodces the same log in chat
%{return await game.macros.getName('111').execute({roll: true, Chance: (${Target_Number}$)%} <--- rolls as above
I saw it says in the documentation that you have to use ' inside of ", so my code should be:
${#setPropertyInEntity('self', 'EntityInitiative1', "fetchFromActor('${self.EntityName1}$', 'InitiativeCurrent')")}$ but this isnt working still
Try this maybe:
%{return await game.macros.getName('111').execute({roll: true, Chance: (${Target_Number}$)})}%
For @grave ether 😅
What is self.EntityName1?
thats a typo woop, thats not in my code now
That comes from your macro. This here is not allowed:
const a;
a = 1;
How's the code then?
That is not allowed in JS overall 😉
Macro executes by itself in foundry
ITs just executing it via the lable I am having issues with
The call portion
If you can identify where in the code I made a mistake I can fix it but everything resolved in node..
Ok, but @formal goblet said the error you see refers to an assignment to a constant that is present in the macro.
`${fetchFromActor('${EntityName1}$', 'InitiativeCurrent')}$
${setPropertyInEntity('self', 'EntityInitiative1', 5)}$`
I broke out the functions, setPropertyInEntity isnt working at all but fetchFromActor is.
I have a feeling that the 1st argument should be just 'EntityName1'. Not sure and cannot test it myself...
Alright, that cant be it..
New code (gutted)
function roll1d100() {
return Math.floor(Math.random() * 100) + 1;
}
let Chance = 100; // Replace with your Skill Value (Chance)
let roll = roll1d100(); // Roll a 1d100
ChatMessage.create({
speaker: { alias: "Not Bob, definitely not Bob" }, // Add a comma here
content: `
<p>You rolled a 1d100 Roll: ${roll} with a Chance: ${Chance} and got a SL:</p>`
});```
%{return await game.macros.getName('post').execute({roll: true, Chance: (${Target_Number}$)})}%
same call
Cannot find macro with name post
Here I named the components what their keys are to help
Basically its a list, and when I click initiative at the top it should check the names in the text boxes, look at those sheets, grab a variable called "InitiativeCurrent" and then set that as EntityInitiative#
Macro is in a compendium since I dont know where else to store it.
My game uses a weird phase based initiative system so thats why im making a sheet to track it lol
Ok, I get it. In the 1st example I read the char name is Akkat (Dan). Is it correct or is it just Akkar?
"Akkar (Dan)" is his sheet name, and it correctly is able to fetch his initiative value.
Oh mine does as well, I havent figure out a way to implement it yet.. everyone goes on different counts based on what you do.
Mine has 5 phases
Phase 1 (Successful player Initiative)
Phase 2 (NPC Swift actions)
Phase 3 (Standard player Initiative)
Phase 4 (NPC Main actions)
Phase 5 (Failed player Initiative)
My bad, did not read your message
I could say they are similar
Can you try putting the macro in the macro-bar just to see if the call works?
Thats what I am about to do.. needed to talk away for a moment.. lol
The EntityInitiative1 field is a label, right? Try putting single quotes around the 5.
that worked
well it set it to 5, I need it to be the fetchActor thing lol
... so if you have text in the label, you cant set it to a number it looks like
Labels are not changeable
Because when I cleared out the "None" it worked lol
Ok, looks like the macro pulls from the hotbar actually executes. How do I get it to pull from the compendium?
compendiumName.macroName would be too easy, right? 😅
always too easy lol
I do not know, then
Hmm... you mean something like this?
${equalText(inf_member_01_dambox_02, '1') ? setPropertyInEntity('self', 'inf_member_01_dambox_01', '1') : ''}$
Or did you mean using switchCase in some way? I'm new to all of this so kind of muddling along. 😄
Been tinkering around the web and maybe this could do the trick for you, but it uses a macro to do it:
const macroCompendium = game.packs.get("world.my-macros"); macroID = macroCompendium.index.find(t => t.name === "Echo Swap")._id; macroCompendium.getDocument(macroID).then(m => m.execute());
You may want to look at the full page: https://www.reddit.com/r/FoundryVTT/comments/sncnau/macro_to_roll_a_macro_from_compendium/
Or here: https://www.reddit.com/r/FoundryVTT/comments/ozrth6/can_i_use_a_macro_to_access_a_comendium_item/
Thanks bud! I will review this in a moment, I realized I am getting an error running the macro via hotbar, its not exchanging the data out, it sees the new value but its almost like it doesnt know what to replace in the macro
I will review that once I figure this out.. I think its %{return await game.macros.getName('dice').execute({roll: true, Chance: ${Target_Number}$})}%
It is coming up as undefined,
as a friend told me, 90% of the problem is getting it to post correctly lol
Why not Target_Number without ${}$?
Its seeing the target number
its not seeing the chance
Target number registers as it should from what I am getting
Sorry I posted the wrong pic
Looks like Result comes out undefined
Could it be something inside the macro?
But i cannot seem to find anything in it.
is there a way to control the combat tracker initiative from the sheet?
Ive got a fancy roll message that calculates initiative and it would be awesome to write that into the combat tracker
Hey, is there some kind of limit to the number of formulas that can be executed from a rollable label? I've recently returned to a project from earlier this year that contains a rollable label to automatically perform an attack roll from within a character sheet. It uses a bunch of different formulas to do that, and it worked earlier this year (based on checking chat messages and the releases page of the gitlab, it looks like we were on version 2.2.7 at the time), but now clicking the label seems to give up on trying to calculate formulas after a few, simply pasting the remainder of the message as plain text. I've tried checking the console to see if there's an error with my syntax or something, but the only thing that comes up is Foundry's notification that it's creating a chat message.
I know it's a big mess, but here's the message input vs the actual message when clicked. You can see that it just kinda gives up after a few lines. The consoleLog I put at the start for debugging works no problem too, so it's not like it's not executing the first few either.
There´s no limit
I think the system doesn´t like what you did with the part in recalculate()
Hmmm, any better way to do that then?
I have a string that says, for example, '1d4' and I want to change it to '1*4'. That's the only way I've found that it at least used to work
Then the replace-function should be enough.
Sorry, I should've said I want it to actually perform that math equation. That's why I tried the recalculate there, and then I found that I needed to put it in formula brackets which made all the other nonsense.
So the crit-bonus is just the maximum roll possible?
Exactly
oof
I suppose if push comes to shove, I can make a switch case since there's a limited number of possibilities. Let me try that now and see if I can get the whole message to work again or if it still gives up partway through
You can store ${ and }$ in temporary variables and use the variables instead in the concat.
Holy cow, OK, perfect
You're a lifesaver
I think what was actually the issue was the '${'. Regardless of if it's already in a formula, that seems to make it give up for whatever reason, but I stored two variables that use replace functions to get to the same string and it worked perfectly
Thanks again, that helps a ton. I'd been trying to figure that one out for a while now.
getting an undefined after the script runs, in the console log its {name: undefined}
I am not defining a name in the script but seems like I need it somewhere?
Also, how do IU get the name to display on the top tag?
%{return await game.macros.getName('rolling').execute({ replaceMe: ${Target_Number}$});}%
Can anyone help me understand what's not lining up here?
${rollformula = '[3d6kh2]';
chatstring = `rolling minor edge:{:rollformula:}`;
ChatMessage.create({content: chatstring});
}$
Dice-so-nice sees the instruction to throw d6's which is great, but the chat log is not happy.
having similar issues what does your console say?
let rollFormula = '[3d6kh2]';
// Define the chat content
let chatString = `Rolling minor edge: ${rollFormula}`;
// Create a ChatMessage
ChatMessage.create({
content: chatString,
});```
try that?
comma after chatstring?
Ok, well, among other things console is telling me Update Foundry!! pls stand by.
That's normal. You can suppress that by throwing an error at the end.
Pass a speaker when calling create().
No need for that, it's the last property of the object
Foundry, systems, mods... all updated. Still not working out. should there be an await in there somewhere?
Will pass the speaker through in the morning.
I threw your code against chatgpt and it spit out everything was fine but rewrote it
So not sure
Still dont know why my code is throwing errors but will figure it out. It is passing the variable through which is good
What does the fo..., console say?
For me, the most recent version of this character sheet label (button) has:
${rollformula = "[3d6kh2]";
chatstring = `rolling minor edge:{:rollformula:}`;
ChatMessage.create({
speaker: ChatMessage.getSpeaker({token: actor}),
content: chatstring});
}$
That's a Script, not a CSB-Formula
Hmm... ok, Can I have a button on the sheet that sends an inline dice roll to the chat?
Console said that btw...
${}$-> CSB-Fornula[]-> Roll-Formula%{}%-> Javascript
You used the wrong delimiters
... in the chatstring initialization?
The first 2 characters...
So... %{}% instead of ${}$
Yeah
Broke before the foundry chat log got anything.
It feels like I should be seeing the issue here... (grumble, grumble)
"actor is not defined". I think that one is more than clear
well, I fetched
speaker: ChatMessage.getSpeaker({token: actor}), ...
right from foundryvtt.com/article/macros 😔
Is that syntax wrong?
The console is giving you a reference error, not a syntax error.
Check the Readme about Script-Expressions (especially the section about entity).
Yeah, ok, I don't retain well trying to book-learn, but this readme you mention is CSB, Foundry, Javascript? ... do you have a link for me?
Yeah... 40 mins later all I know is that the readme I found got me more confused than when I started.
How from macros I can access to the token item container and specific item?
I think the answer to this is no cause I'm not seeing it in the documentation, but I wanted to double check. Can you take information from a spreadsheet outside of Foundry VTT and import it to a table or dynamic table?
I think I've seen this question asked before and the answer is no, for as much as I can remember.
Yeah, that's what I expected.
I've attempted to do so, but could not. I fear you'll have to traverse the entire item collection.
You can but you will need to write a macro to do so. I would probably export the spreadsheet as CSV and than paste that into a text field within the macro (because I am lazy and dont want to bother figuring out how to directly import a file). I have a macro that writes to a dynamic table and I can post it tonight, if you like. It wil get you half way there. Ping me in about 7 hours as I am at work now and will likely forget.
Cool! Thanks for the hint 😉
Yeah, that sounds way easier. I'd appreciate you sharing it. I'll try to remember to ping you later, hopefully I don't forget, lol
Is there a quick way to fetch range to target token?
Oooh... I just asked that in Macro-Polo...
const distanceInUnits=canvas.grid.measureDistance(token,game.user.targets.first())
This is what they gave me.
Ah, ok... so macro is needed. I'll look around some more.
I'm still fuzzy on how to return macro results into sheets or dialogue windows. 🙂
Can I ask for a little context? What's the situation you are in when you're looking for Target Distance? ...When you have that distance, what do you do with it?
An actor making a ranged attack against another actor.
Came across this which works, but it seems like hexes are tricky since it's off by 1 now and then.
const target = Array.from(game.user.targets)[0]; // only uses the first target
if(!target) return ui.notifications.info("You have no target");
const distance = Math.ceil(canvas.grid.measureDistance(token, target)); //gets the distance between to tokens, rounded to 1 decimal place.
const content = `${token.name} is ${distance} units from ${target.name}`;
ChatMessage.create({content});```
Feels like there should be an easy way to get this info from Foundry since it's built into the core system.
Mmmm... I'm sorry to say that my use of a hex grid in foundry is practically non-existent. Maybe if we look at it done up in js coloring something will pop.
```js
Code
```
if(!token) return ui.notifications.info("no token selected");
const target = Array.from(game.user.targets)[0]; // only uses the first target
if(!target) return ui.notifications.info("You have no target");
const distance = Math.ceil(canvas.grid.measureDistance(token, target)); //gets the distance between to tokens, rounded to 1 decimal place.
const content = `${token.name} is ${distance} units from ${target.name}`;
ChatMessage.create({content});
Aha! I was wondering how to get code to look all nice like that. That's good to know. 🙂
Not sure if this will help much but I'd use game.user.targets.first() instead of Array.from... since you really only care about the first one.
As commentary after Math.ceil, you mention ...rounded to 1 decimal place. I thought Math.ceil(3.1415) and nothing else would give back 4, not 3.2... 🤔?
Sorry to intevene, but Math.ceil(3.1415) rounded to 1 decimal place should be 3.1 because the second decimal is <5.
It should, I say, because its logic may differ from what I know...
Yeah, sorry I put the ceiling in there as it first showed decimals, but didn't edit the comment.
I wonder if I should use something like "hexgrid" instead of just grid.
Ok so I know CSB cant control the initiative in the encounter tracker directly and I have to use a macro. How would I make a macro that updates the initiative of selected tokens in the tracker using a specified value on the character sheet?
Actually, as far as rounding a decimal number goes there are a few different methods:
- math.ceil takes any portion of a number and rounds it UP.
- math.floor takes any portion of a number and rounds it DOWN
- math.round worries about going up or down. 2.49 and less goes down, 2.5 and more goes up.
Every sheet has a value called "InitiativeCurrent" that Id like to send to the combat tracker, ideally trigger it with a roll message
This seems relevant...
https://foundryvtt.com/api/v10/classes/client.HexagonalGrid.html#getAStarPath
Documentation for Foundry Virtual Tabletop - API Documentation - Version 10
Oh well, there's always something to learn 😄 Thanks!
If you dont have an answer until tuesday! you can PM me, i have done an Initiative macro which should be easy to adopt for you.
So, yeah, @plucky canyon, if you're using math.ceil for your rounding and the number is occasionally off by 1... try math.round instead.
Been stuck on this for a while lol. Ill let you know then If I still need help!
Anyone know how to make a macro that does that?
I just need it to set the initative in the combat tracker to a value from the selected tokens character sheet
I haven't yet worked on interacting with the initiative tracker, but I would start by looking at this, perhaps the content of a number field could be referenced here like [:CalculatedInit:] (Colons inside are very important.)
I didn't think to try that. Its grabbing the number that they rolled from the sheet now which is cool
Is there a way to trigger a roll message?
Glad I could help as much as that, but I don't know about including a roll message, the game settings box does explicitly say "No ${}$s"
Right now they roll from the sheet, it displays to chat, and then if they roll in the combat tracker it sets it to what they rolled last on the sheet.
rolling int should be standard inside of Foundry
Do you mind sharing that @runic condor ?
That should be right, if you roll via combat tracker it rolls the int that is displayed in CSB like above
mine is set 2d10
My initiave isnt a single roll is my problem, its a D6 that sorts you into a phase. 1-3 goes last, 4 goes in the middle and 5-6 goes first
So I have a really long roll message on the sheet that displays what they rolled and what phase that puts them in and then stores the phase as a variable.
Ahh thats right, I forgot about your combat tracker development
I would suggest writing a macro for it
Ok, sounds very specialty... 🙂
lol yea it seems overly complicated but I love how it plays out.
Enemy always goes at the same time so you're basically rolling to see how you do vs them and if you get to act before they do.
I think there is a way to trigger a roll message, I cant remember how
I am looking lol
/sheetroll
I found it
I wish I could put that in the initiative formula lol
or If I can idk how,
does /sheetroll not work
How do you show item values in a container?
/sheetroll InitiativeRoll works if I type it in chat, but I cant put that as the initative formula it yells at me
Can you make that a rollable field on your sheet
wym
InitaitveRoll is the name of the label that has the roll message to display to chat and updates a variable on the sheet called InitiativeCurrent
If I set the formula to "InitiativeCurrent" it grabs that number but they have to roll from the sheet still
Itd be cool if they could roll from the tracker and it triggeres the roll on the sheet
How it is rn is pretty close though just grabbing that value is nice
ok hold on, lets back up a moment because I dont understand.
I am trying to understand use case and here is my understanding.
You want to roll either via the combat tracker or by /sheetroll InitiativeRoll to use your custom value that is dice + other things correct?
So right now, we've been ignoring the combat tracker bc my silly initiative system.
I have a button on the sheet that rolls and outputs to chat how you did on the initiative roll and stores that number in a hidden variable on the sheet.
My goal is that they could click the roll button in the combat tracker and it triggers the roll on the sheet. Right now all it does when they roll initiative through the tracker it grabs the number they rolled last time.
ok what is the name of the button
InitaitveRoll
InitaitveRoll put that in the box by itself
Alternatively, if when they hit InitaitveRoll , if combat tracker somehow knew that they rolled so it doesnt show the D20 symbol in the combat tracker
I cant help the d20 symbol but if your looking to use that button as your trigger to roll then you need to call it via the InitaitveRoll inside your initiative formula
example
When I do this it pops up "validation errors:
initiative: must be a finite number"
ok what is the button doing?
I am assuming its calling other values?
example STR+STR+DEX+DEX
that will add all those values up to output a number
So the button the press is InitiativeRoll, and it has this ass the roll message:
`Initiative:
${#r1:=[1d6]}$ ${#r2:=(ImprovedInitiative? [1d6] : [0])}$
${r3:=max(r1,r2)}$ =
<hr>
<div style='text-align: center; font-size: 1.2em;'>
${min(r1,r2) >= 5 ? "<span style='color: darkblue;'>Crit Success</span>" :
r3 <= 3 ? "<span style='color: darkred;'>Failed</span>" :
r3 == 4 ? "<span style='color: darkgreen;'>Standard</span>" :
r3 >= 5 ? "<span style='color: darkgreen;'>Success</span>" :
""}$
</div>
${#setPropertyInEntity('self', 'InitiativeCurrent',
min(r1,r2) >= 5 ? "6" :
r3 <= 3 ? "1" :
r3 == 4 ? "3" :
r3 >= 5 ? "5" :
""
)}$
`
hmmm
Basically it rolls a D6, and checks if you rolled a 1-3, a 4 or 5-6
Then it sets a hidden variable "InitiativeCurrent" based on that result.
And it outputs to chat if your roll was "Failed, Standard, Success, or Crit Success"
thinking through this give me a moment
That last bit is in there twice and doesnt need to be, fixed
Theres an improved initative feat that lets you roll 2D6 and take the better. And if you roll both as a 5 or 6 you get bonuses to your actions on your turn
Thats what that first ternary is at the begining
OK So, I dont think you can call a macro from the init or through the roller without actually modifying what it does
can it be done, I am sure it can with someone that is smarter than I
Lol well thank you for checking. Im happy with it just fetching the number after they roll from the sheet, easy enough for me to click "roll all"
Uncaught (in promise) Error: Unresolved StringTerm InitiativeRoll requested for evaluation
dang
It works for calling a macro
[%{return await game.macros.getName('rolling').execute({ replaceMe: ${Target_Number}$});}% %{throw "Done";}%]
So if I made a chat macro that was /sheetroll InitiativeRoll ?
That works
output would need to be adjusted to output a reult that matches the init but...
putting roll InitiativeRoll in the box works fine but this is a button right
So If I had a macro that did /sheetroll InitiativeRoll
And then fetched "InitiativeCurrent", could it put that in the initiative track?
Yea If I put InitiativeRoll in it gets mad at me. If I put the variable in that it updates after rolling, it sets the initative to that
Figured out how to measure range with hexes. Apparently distanceS and counting actual gridSpaces is the key:
const ray = new Ray(token, game.user.targets.first());
const target = (token, game.user.targets.first());
const segments = [{ray}];
const dist = canvas.grid.measureDistances(segments, {gridSpaces:true})[0]
ui.notifications.info(`${token.name} is ${dist} hexes from ${target.name}`)```
Does anyone know if it's safe to update to the lateast Foundry build for CSB?
Updated fine without errors on myside
Good deal
Here is (the important parts of) the code I use to add to a dynamic journal. This is designed to place that entry at the top of the list. For CSV, grab the contents of the text box (maybe use CSS to make it multiline /w scroll), split each line to an array and then reference each element in the JSON. @fierce harbor
// create table entry
updatedJournal = addNewRecord(message, xpSpent*-1,stat,stat,itemType);
//update journal
await actor.update({ "system.props.xpjournal5": updatedJournal });
// Function to add a new record at position 0 and renumber <var> sequentially
async function addNewRecord(message, xpSpent,itemName,itemID,itemType) {
// Find the highest value of "sn"
let highestSN = -1;
for (const key in xpjournal) {
if (Number(xpjournal[key].sn) > highestSN) highestSN = Number(xpjournal[key].sn);
}
// Insert a new record at the beginning with key "0"
const newRecord = {
"objectName": itemName,
"itemID": itemID,
"deleted": false,
"predefinedIdx": null,
"message": message,
"xpSpent": xpSpent,
"itemIncreased": itemType,
"deleteXPentry": "Delete"
};
// Create a new JSON object with updated keys
const updatedJSON = {};
updatedJSON["0"] = newRecord;
// Renumber subsequent records
let index = 1;
for (const key in xpjournal) {
if (xpjournal.hasOwnProperty(key)) {
updatedJSON[index.toString()] = xpjournal[key];
index++;
xpjournal[key].sn = index;
}
}
return updatedJSON;
}
I have button that calls a macro which displays a dialog box. The "undefined" chat message appears along with the dialog (which eventually generates a chat message). Throwing an error doesnt seem to work nor any attempt to delete the chat message via JS except via a "hook on chatmessage" in world script module and that only deletes previous undefines, not the current one. Any suggestions on how to suppress this? Thanks
I don't understand how to get item containers to work. I can't get anything to show up in them
@latent sorrel add this at the end of the call %{throw "Done";}% - My understanding is its an error that is being worked on
@jolly stone - Item containers require items to be created and dragged into the container.. IE make a torch and then drag it from the compendium into the container. The containers can be setup to hold different things..
think of containers not as just inventory but also races, classes, ect
It´s not an error 😅
Tried that and it works for other macros but the dialog is causing the issue, somehow. I know that its being worked on but impatience is one of my more charming traits 😶
populating as undefined is not an error?
No, because your return of the Script is undefined. And CSB will always create a Chat Message on its own
hmm ok, sorry to say Lyinggod thats the extent of my coding knowledge to assist
Messing aroudn with itemTemplates. Just making soeething very basic at first to try it out, with player inputing mods and the template adding up those mods. However, it doesn't add up anything when referencing the relevant keys. What am I missing (tried item.<key>)?
The values in ${}$ will only show up when you create an item based on the template. If the fields in ${}$ are not on the item template, and are on the actor than you will need to reference the actor using fetchfromActor
Using JS, how can I reference a calculated label from within a macro? This is for my initiative formula so I think I need to retrieve all relevant data based on the actor id from the tracker object which I can do up to getting the calculated label.
This is just a guess, but [:CalcLabel:]?
Thanks but I beleve thats for a roll message. I need this for processing in javascript.
Sorry, meant userInputTemplate. So the problem is the opposite - I can call values from the actor with no problem, but have problem with keys/values that just belong to the inputTemplate.
You can pass entity to the macro if it is called from the actor. There you have access to the props of the actor.
its called from the individual roll initiative button in the combat tracker
The Input Template doesn´t support calculations atm.
Aha...
Should still be doable I think
Is it just me or (myself included) is there a lot of begging for interacting with the CT lately?
Do you have a suggestion as to how? I dont know what field to reference since it is calculated and not static (ie system.props).
If the actor sheet had label of component name brawn with a calculation, how do access the calculated value via a macro?
I had the same issue and had to write an extensive macro to replicate this due to a lack of this functionality. PITA.
Hmm... how about regular user input? Can that have calculations?
Having a hard time with setPropertyInEntity() on a checkbox.
none of the examples have a checkbox in the documentation
its seems to only be able to check the box but not uncheck it
How are you trying to unset it? ... what value is being passed?
oh nevermind I was sending false but if you send 0 it works
There you go. Good job.
Lol thanks
curious though, when you say you tried sending false, was that wrapped in any quotes? (`, ', ")
I tried all false, 'false', and "false". all of those check the box lol
I think if it gets any value other than 0 it gets checked
let x = false;
let y = 'false';
let z = "false";
Do you notice how x's false is colored differently? That's the keyword false and means the same as 0 and (1 > 1).
Well, welcome in the world of implicit coercion.
y and z's false's are strings, strings have meanings, something that has a meaning == true
I have a initiative formula macro which calls a dialog for user input. To pause the initative roll to wait for the dialog, I have let myDialog = Dialog.wait() which seems to work (except the "character rolls initiative" chat message appears at the same time as the dialog), except it throws the following console error. Is this is a bug or something I need to correct?
How do you get the total number of items in an item container? I have a counter value on items I could use to sum but IDK how to grab it
Ok I see the FAQ for that, im still confused as to where to put what info
Oh no. Are Item Modifiers not part of a template?
Oh ok it does carry item modifiers from templates. Man that FAQ would really be helped by some picutres lol
So, I'm a little confused on how to fetchFromActor to use a piece from that in a macro. For example, I'd like for players to be able to click on the macro and roll 3d6 + their accuracy modifier (we'll call it 'Mod' here for the sake of ease). How do I indicate that I want it to use the player's character sheet to pull 'Mod' from and get the value of that key from there?
Why a macro and not a label with roll message? In the same sheet, I mean.
I thought a macro might be easier for some players, so I wanted to have both as options. I've got a roll message on a label working though.
Oh, I see. I think you can refer a targeted token's sheet in a macro, but shoot me if I remember how 😅
I did see that in the documentation. Would that be where they just need to click on their token before clicking the macro?
Right, but the you need a specific sintax to acces the token's actor. Something on the line of game.token.actor but surely not this.
This code gives you an idea of how to access the actor:
`//Is a token selected? If not, error
if(canvas.tokens.controlled.length == 0 || canvas.tokens.controlled.length > 1){
ui.notifications.error("Please select a single token");
return;
}
let actor = canvas.tokens.controlled[0].actor
//Does the token have a torch? Otherwise error
let torch = actor.items.find(item => item.data.name == "Torch")
if(torch == null || torch == undefined){
ui.notifications.error("You don't have a torch in your inventory!");
return;
}`
Oh, beautiful! Thank you so much :)
You're totally welcome, but that is not my code. Just took it from the web 😅
Yeah, but you saved me the energy of having to find it :)
Oh, there's a sheetRoll option. I didn't remember that being a thing, but that's good to know.
Are players supposed to be able to put their own tokens on the board? The ones in the game I'm running aren't able to, so I'm wondering if I have a setting wrong?
You have to assign each actor to a player and give that player Owner permission. Then if you define a default token for the actor, each player will be able to drop that token on each map and it will be always the same. Remember to link the token to the actor, there's an option on the token's setup.
This needs a permission, which can be configured in the permission-settings in the game.
If the players have a configured player actor (see bottom left), then you can just use actor to get the necessary data in your macros.
Are you still working on it? Just curious 🤩
I am, but not had a breakthrough yet. Traversing the template item structure is... inconsitent. No real way to get the props of template items to verify whether it has a certain property
I wish I could help 🥲
I'm close to get my roll dialogue and result working as intended. I'd just like the modifiers in the final line to multiply by 0 if the silroll macro returns 0 (which happens if all dice come up 1). I could do it by feeding them all as arguments into the macro, but I'd prefer to keep them outside to more clearly show the roll in chatt.
${#concat(?{speed:"Speed Modifier:"[number]|0}},
{?{obscurement:"Obscurement Penalty:"[number]|0},
{?{accuracy:"Weapon Accuracy:"[text]|inf_weapon_acc_actual},
{?{range:"Range:"[number]|(%{return await game.macros.getName('get_range2').execute({short: ${inf_weapon_range_short_actual}$, medium: ${inf_weapon_range_medium_actual}$, long: ${inf_weapon_range_long_actual}$, ex: ${inf_weapon_range_extreme_actual}$})}%)})}$
${
%{return await game.macros.getName('silroll').execute({amount: '${inf_skill_actual}$', mods: '${inf_skill_mod_actual}$'})}% + inf_weapon_acc_actual + speed + obscurement + range
}$```
I tried using Roll:= to save the silroll result and reuse it in a conditional, but that didn't work. Tried simply going `<returned silroll result> > 0 ? (+ inf_weapon_acc_actual + speed + obscurement + range) : 0`, but of course that doesn't work as the actual roll gets discarded. Feels like I need a way to save the roll.
Wouldn´t it be something like this?
game.items
.filter((item) => item.isTemplate)
.filter((item) => item._templateSystem.getKeys().has('Quantity'));
It goes through all Item Templates and lists these, which have the prop Quantity.
That seems to give me the correct templates, indeed! My current implementation looked akin to this...
function hasTemplateItemQuantity(templateItemContents) {
if (Array.isArray(templateItemContents)) {
return templateItemContents.some(subElem => hasTemplateItemQuantity(subElem));
}
return (templateItemContents?.key && game.itempiles.API.ITEM_QUANTITY_ATTRIBUTE.endsWith("." + templateItemContents.key))
|| (templateItemContents?.contents ?? []).some(subElem => hasTemplateItemQuantity(subElem));
}
export function getItemTypesThatCanStack() {
if (!itemTypesWithQuantities) {
itemTypesWithQuantities = new Set();
if (game.system.id === "custom-system-builder") {
const itemTemplates = game.items
.filter(item => item?.templateSystem?.isTemplate)
.filter(item => hasTemplateItemQuantity(item.system.body.contents));
for (const item of itemTemplates) {
itemTypesWithQuantities.add(item.name);
}
}
...
I had no idea about getKeys on the template object, thanks!
@glad spade Might be worth a look (especially templateSystem.js): https://gitlab.com/custom-system-builder/custom-system-builder/-/tree/develop/module/documents?ref_type=heads
where is the best place to post about bugs, here or gitlab?
Hey guys, can someone give me a fresh pov on this?
const pogs = %{fetchFromDynamicTable('pogTable', 'pogFilename')}%;
const src = token.document.texture.src === pogs[0] ? pogs[1] : pogs[0];
AudioHelper.play({
src: "C:\VTT Assets\Foundry\Data\Sounds\TF\conversion-grind-LR.mp3",
volume: 0.8,
autoplay: true,
loop: false},
true);
return token.document.update({"texture.src": src});
Console says "SyntaxError: Unexpected token '%'..."
If I remove the %{}% delimiter the error becomes "fetchFrom... is not defined"
where is that located? in a script or on the sheet?
It's a macro on the bar.
The actor pog is selected... but that's probably not enough, eh?
You want to get pogFilename from a DT in that actor's pog, right?
Right.
You do not need %{}% in the macro, only in label roll messages.
It's a Transformers RPG, and so 90%+ of the pogs can go to an alt mode.
so would the function then be called by:
selected.actor.fetchFromDynamic.....
Hm, let me see how to do that ...
I think you cannot use that function in a macro, unless you create the function string and you put it in a label roll message via macro.
At least this is what I've found so far.
I'll look further into it and let you know.
I would still very much like to use one macro for any & all Transformers... but I've got a good Band-Aid for now... Copying the macro 800 times and hard-coding the image path/filename's.
Might it be more efficient to use one macro with an hard-coded array of all the paths and then selecting the correct one based on what you need? Just thinking...
Mmm... probably more efficient... but how to distinguish which of the array elements are correct for use?
What you use those elements for and how would you select them if you could use a DT directly?
The character sheet has a tabbed panel called GM (Visibility is for Assistant GM and up). The Dynamic Table is in there and the Path/Filenames are listed, one per row.
The controlling user highlights the token and runs the macro. if the existing name is for the Bot Mode, the token.document.texture.src becomes the Alt Mode, and vice-versa.
btw: this is what one of the Band-Aids looks like...
const pogPath = "Tokens/_TFOR/_Bots/Shinobi/";
let pogs = ["shinobi", "Shinobi-Alt-2"];
let pogBot = pogPath + pogs[0] + "-min.png";
let pogAlt = pogPath + pogs[1] + "-min.png";
const src = token.document.texture.src === pogBot ? pogAlt : pogBot;
AudioHelper.play({
src: "Sounds/TF/conversion-grind-LR.mp3",
volume: 0.8,
autoplay: true,
loop: false},
true);
return token.document.update({"texture.src": src});
I have the Tokens folder, then the Campaign folder and then Faction... After Faction comes the PC name as another folder, and lastly the actual image name.
So if the pog is in Bot state, it goes into Alt state and vice-versa. And from what I read each bot-mode has a corresponding alt-mode, correct? Or can this be a n-to-m relation?
Nearly all Cybertronians are limited to a single Alt, but then there are 'Triple-Changers' which need special handling anyway.
Being conservative, the ratio of single-alts to multiples is at least 50:1
Ok. You could maybe create a 2-d array in which the first value is the bot and the second is the corresponding alt. If I understand correctly, each pog has its state available and readable from the macro, so you can easily choose what you need. But please correct me if I am wrong.
Hmmm.... wait a minute.... The Selected Character Name... a macro can dig that up.... If I build pogBot and pogAlt around the selected name.... I just need to be sure the paths in the file structre line up.
Now that's a good and effective/efficient idea. Nicely thought 👍🏻
Hehe... esp for 1:30am. 🙂 👏
Hi guys, my players can edit item modifiers with the "configure item modifiers" in the item sheet, is that normal? I can't find a way to prevent that.
Yes, that is normal for modifiers set in the item itself.
If you set modifiers in the item-template they can not reach them.
Is there a way that I can have items go into an item table, but then some of the information of that item appear in like a weapon's tab automatically where it can be rolled on?
Items can only be shown in Item Containers. Multiple Item Containers can show the same Item, because they only act as a Display Container, Items are all stored in the Actor.
Is something like this possible ${Roll:=[:item.dmg_arme+dmg_supp:d6x:explosion:]}$
Or I'm just trying to make the impossible ? ^^
I know the :item.dmg_arme+dmg_supp:d6 work. I just want to know if I can use a variable for the explosion part
and to add difficulty, I'm doing this in an item container 😄 ( I'm suspecting it don't work because of this )
Yeah, that´s doable. The whole Roll Formula can be stored in a variable if needed
I managed to do it with a roundabout way.
My problems come from ignoring how to use a variable created in an item container ^^
So I stored all the formula in the item template and just use the label :3
Inside an item i have an empty number field. With a label next to it i would like to start a label roll message to roll a d6 and store the result of this roll in my number field. The number field has the key "result" What would be the Label roll message please?
${roll:= [1d6]}$
${#setPropertyInEntity('self', 'result', roll)}$
Hey guys, I had an issue about 9h ago involving getting info from a Character Sheet Dynamic Table into a Foundry Macro. By accepting certain limitations I have a band-aid solution, but I'd love to make this happen instead...
The ultimate goal is one macro that goes on the button bar that I or my players can use to "transform" all selected pogs under the users control... with the freedom to have dynamic choices for image path/filename.
Question,
Use case: Players have a skill list that they can populate themselves with variable skill names. The table is created as a dynamic table because the calculation for each line is the same but references the skill name as a reference. I habe broken the table apart into entries vs calculations since I can not hide the calculation fields from the players onto another dynamic table.
So the question looms, is there a way for me to populate the second calculation table with names from the first when they add a row and it be filled/changed in as we go?
If not is there away for everytime a field is added it adds a number to a field.. ie 1,2,3,4,5,6,7, ect...
-- Found a work around, seems like hiding does work for players so thats a plus but would still like to know the above.
Is there a way within a character sheet to get it to recognize variable that are in different tabs of a tabbed panel?
Tabbed Panels have no impact on calculations
Anybody care to weigh in?
The path for the data of a Dynamic Table is actor.system.props.dynamicTableKey. You can log that and see how the structure is
Ah I realized I bungled something else. Thank you for the clarification!
You cannot automatically populate Dynamic Tables, you have to manually insert the rows. Everything else can be handled with calculations over Labels.
Thanks @formal goblet, I knew it had to be possible. 
You can also just log the actor and see what data is available. This should give you a good overview about everything the actor is offering you.
Or you log the game-object and literally see everything.
Hello, I'm trying to make a formula that sees a number then prints a corresponding test phrase. In this case -1 weak, 0 is neutral, 1 is resist. How would I go about doing that?
nvm figured it out
Anyone still up?... 👀
Need a little help with a Macro that's not quite hitting the mark. I'm starting with "A", I want "B", but I end up with "C".
Woke up few hours ago. How can I help you?
The Macro looks like this:
AudioHelper.play({
src: "Sounds/TF/conversion-grind-LR.mp3",
volume: 0.8,
autoplay: true,
loop: false},
true);
// Sound plays just once, then change images.
for(const token of canvas.tokens.controlled) {
let pogImgs = actor.system.props.pogTable;
let pogBot = pogImgs[0].pogFilename;
let pogAlt = pogImgs[1].pogFilename;
let src = token.document.texture.src === pogBot ?
pogAlt : pogBot;
token.document.update({"texture.src": src});
}
return true;
Anything to do with pogFilename being the same?
pogFilename is from a Dynamic Table in each individual actor sheet. And they are distinct from each other.
In fact, this is flawless if only one token is selected...
(Fun fact: even after the multi-select screws it all up, single selected macro runs undoes the damage.)
Haha!!! Solved it!
let pogImgs = actor.system... edited to
let pogImgs = token.actor.system... because for loop focus.
Thanks for listening. I'm not sure I'd have seen that if I wasn't trying to explain to someone else. 🙂
Always glad to be of help 😉
46 test versions can finally make way for v.1.0
Way to go!
I was really, really hoping not to hit the infamous Star Trek Number of fails. 🖖
Ok, new stumbling block: is it possible to select the next dropdown list item because a checkbox is ticked?
Not with default CSB-behavior
Hmmm... why isn't this value modifier working? both keys are simple labels with value 1. It works when I used = operator, but not +.
Any errors in the console? Does your target-Label have a numeric value?
No errors. Target label(s) look like this:
Try setting it to 0.
Tried it, no change. Very weird.
Have you tried priority=0? Shouldn't change a bit, but...
Yeah, no difference
Oh well, this is weird...
Only other thing that comes to mind is removing the spaces from the formula 🤷🏻♂️
Is your group-field empty?
Otherwise change 0 to 2 in the else-part to see if your condition is evaluated correctly
Yes, group-field is empty. When else is 2 it actually adds it, so it seems to be working backwards...
Seems like else fires no matter what I put before it.
crew_test is the key of the item?
Yes

No, sorry action_test is what I want to modify, if crew_test is over 0.
I have an item template with lots of number fields. i would like these fields to changes the background to a predefined color when the number entered is != 0 in an item. Is this doable with CSS?
Sort of if you define a Label with a style-tag and put your css-classes inside there. Then you should be able to use those classes for your number fields.
question about actor.roll
actor.roll(rollCode: InitiativeRoll, [{ postMessage: true }])
is this typed right or am I not reading the wiki correctly?
Not the CSB-Wiki, right?
I actually forgot about that thing 🤣
Chances are high that it moved to the templateSystem instead of being in the Actor-class
ok so if I copy the button as a macro it gave me this:
`let rollMessage = await actor.roll(
'InitiativeRoll',
{ postMessage: false}
);
let speakerData = ChatMessage.getSpeaker({
actor: actor,
token: actor.getActiveTokens()?.[0]?.document,
scene: game.scenes.current
});
rollMessage.postMessage({speaker: speakerData});`
I want to add one line that grabs a value from the sheet and sends it to the initiative tracker
but idk how to do that
that or have it trigger the initaitve roll and then I set the initative formula as the variable.
Can someone help me a moment,
Use case: I got a dropdown list that list MG1 -MG15, G1-G15, and blank.
${max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', switchCase(sameRow('General_Skills'),'G1', 'G1', 'G2', 'G2','G3', 'G3', 'G4', 'G4','G5', 'G5', 'G6', 'G6','G7', 'G7', 'G8', 'G8','G9', 'G9', 'G10', 'G10')))}
and
${max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills')))}$
These 2 do the same thing but basicly it matches the G1s and pulls highest value. The issue I have is that blanks and - cause errors and I would like them to be validated as 0, same with MG.
I attempted to do a If else statement but for some reason I cant get it to compute..
examples
${equalText(sameRow('General_Skills') = "-" ? 'yes' : 'no'}$
If anyone can think of something I didnt please let me know
end of the day, I need a way to filter the blanks and MG~ (does ~ work) to = 0 but for the life of me its being stuborn
You can put default values for switchCase and sameRow as last argument.
Sure, happy to try that
I suspect that because blanks are text its causing the issue since its trying to find values of Max, thats my guess tho
Might be
so wouldnt I technically, have to put the switch case first,, ie switchCase( ' ' || 'MG~' , 'MG~', 0, ' ', 0,)
something like that?
I feel like I am missing something in that equation
Hell, I would use switchCase(DropdownKey, 'a', 1) but its not registering my drop key..
I feel like a If statement would be better, {fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills')) === ' ' || 'MG~' ? "0" : max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills')))}$
It states if the table = blank or MG[number] ? Yes : no
Try this:
switchCase(opt1,val1,opt2,val2,...,0)
This should do the trick.
Just talking it through helps sometimes so would like feedback lol
equalText() is the magic word you're seeking
I tried that as well but didnt compute either, but will try it again lol
Does the ~ and || statements work?
~ doesn't exist and the equivalent for || is or
Compares each filterColumn with the filterValue by this operator. Default comparison is ===.
You can use every comparisonOperator described in Conditions together with ===, !== and ~.
Saw it available so thought I would ask
That's only for this function and just tells, that it should be interpreted as a Regex
now I gotta learn what an Regex is, thought it was a number at the end counting.. ie M1 M2 M3 ... instead using M~ would capture all ... ok no worries there I will figure that piece out
equalText didnt do it either
What is the command to run in the console to see if it resolves?
ComputablePhrase.computeMessageStatic(formula, props)
Thanks because running just {'-' === '-' ? 'Yes' : 'No'} resolves in the console but doesnt on the sheet
I think your issues lie within fetchFromDynamicTable() and max()
I might be dumb, I was still using the =, staring at this for hours just bashing it to get it to compute broke stuff
Oh I agree with you Martin
${max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills')))}$ < -- computes fine, but it returns a number, what I suspect I need to do is say if General_Skill is -, assign it a 0 value upon return
That 0 gets passed to fetchFromDynamicTable(). If it doesn't find a value with 0, it will return an empty array.
Correct
${max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills')))}$
Max(table, skill(array 1,2,3,4,5,6), location, filter) = returns 6 becauses thats the highest
Thats how its written and works as intended. I need to it to pass a 0 to several of those values in filter to still return a max of 0
Issue is, blank doesnt carry a value, and - while it matches doesnt return anything either
even if I have multple - with skill ranks
if I could pass a value of null = 0 that would solve for both I think
hence is why I was going to go with the if and statements, but that doenst work either lol
Wait, you are misunderstanding the fetch-function a bit. To explain it in plain words: "Get all values from the column Skill_Rank in the table PCF_Table where General_Skills equals whatever you are comparing with."
Correct
thats what I am doing
Get everything in Skill_Rank and provide me with the highest value
${max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills')))}$
${max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', switchCase(sameRow('General_Skills'),'G1', 'G1', 'G2', 'G2','G3', 'G3', 'G4', 'G4','G5', 'G5', 'G6', 'G6','G7', 'G7', 'G8', 'G8','G9', 'G9', 'G10', 'G10')))}$
Both of those are doing the same
Well, the one with the switchCase is completely useless
I figured giving you a picture will help understand
Group skills take the highest skill rank that is produced on Test on the right
So if I have 17 G1s and the highest is 9 it will return 9
How did you even get multiple numbers under 1 column?
That one is correct. We need something like if empty array return 0 otherwise return the max
Wow, you need a Script 🤣
ugh
Nooooo
Array just FYI
I am not the greatest at scripts so it would take me a bit longer to write lol
%{
const skillRanks = '${fetchFrom...}$'.split(',');
if (skillRanks.isEmpty()) {
return 0;
}
return Math.max(skillRank);
}%
You can run scripts on a lable right?
So I'm digging into doing coding stuff in this system, but I have next to no coding experience at all. If I had a good idea of what I wanted a thing to do and could describe it decently, could I be pointed to examples of what I'm trying to do or get help with it? This is dangerous close to "asking to ask" so I'll specify by saying I'm looking to have the sheet I made roll a die and checking it against a given number, with success and fail states for that roll
I want to say simple, but you never know with this kind of thing
Have you looked at the example sheet?
What your asking for is already built in there
for the most part, unless its custom then it may require a macro to script things out
I... May have missed that there's an example sheet
that makes a lot of sense, yeah. I have the Fabula Ultima sheet in my game which I was using as an example, but couldn't quite figure it out
Part of the problem is I don't understand the variables being used in the syntax, I think. Gotta read over the documentation
Start with the Example sheet first, then look at what you want to do and either gut or make your own
Gotcha. Thanks!
Both are good resources to start
the formula System uses ${}$
calling values are fairly straight forward, name the value, garbageCan and pull ${garbageCan}$ <-- in lable field will return whatever you made that value to be
Values and return
anything is red is in the roll field
I use the roll field as a place holder to validate after I am done with a formula
So ignore all my red lol
Happy to help where I can but I am no expert and rely on others for help when it requires scripting
🙂
completely unrelated to the above about scripting: is it possible to change the styling of a number field, or text field?
I know that there is a way but I couldnt tell you how
The sections for those in the documentation only speak about what they do, not whether that's possible. I do see some notes about bringing in your own CSS styling, but I'm not sure if it extends to those
Ah, okay
I was looking to see if there was something in the config
It might be in the CSS file section tho
or additional Fonts
Right
I'll check that after
Totally not procrastinating on, you know, actually prepping my upcoming game by focusing on making this sheet. No sir, not at all
lol
I been taking a part a Excel file and putting it into foundry
A LOT of formulas to sift through
convert and rework
I am almost done tho
That's where I'm comfortable actually! I made a pretty snazzy sheet once for a PbtA game in google sheets
So like, I'm sure I can figure Foundry out. I'm just not familiar with it
Yeah, I am too but because this game relies on a Success Level value and skills that are not out of the box (ie anything is a skill) it was too much to deal with
I wanted to make it easier for the player
Ah, yeah
Foundry is fun 🙂
I'm pretty proud of myself already for what I've managed with this system. It's really cool
pulls up example sheet, is immediately stumped by how it's doing something
How the heck is clicking this red d20 icon pulling up a popup window with buttons in it, what the heck
I did
view from the test character and the go from there
in the default version of the roller there is a modifer added in
you can remove that
This little dooder here opens the dialog window
Yep
If you look at the rolling fuction in the GM(editor) you will notice in the rolling section there is a modifer verbage and some coding..
<td>${?{Modifier[number]|0}}$</td>
</tr>
<tr>
<td><strong>Result</strong></td>
<td><strong>${Roll + Modifier}$</strong>```
Its also on the wiki
My suggestion if your starting out
Create you a compendium, pull a copy of the _template in there that hasnt been touched, dup and change the name of the template to _gamename V.0 or whatever
that way if you mess up you can always go back
Save often
keep backups often
oh yeah, definitely
Oh, wait
${#?{Dice_Modifier:'Skill Check Modifier'[number]|0}}$
yep
Dice Modifier isn't calling something from the sheet is it, that's just a thing the system can do
I see
correct
Okay, cool
I was scrolling through the <table> stuff trying to find how the dialog box was built, so this makes sense. Cool cool
gotta jet but if you need help let me know, I am happy to look at something for ya
sure thing, thanks again
ended up doing this
(equalText(sameRow('General_Skills'), 'MG12')) ? '0' : (equalText(sameRow('General_Skills'), 'MG15')) ? '0' : (equalText(sameRow('General_Skills'), 'MG14')) ? '0' : (equalText(sameRow('General_Skills'), 'MG3')) ? '0' : (equalText(sameRow('General_Skills'), '-')) ? '0' : (max(fetchFromDynamicTable('PCF_Table', 'Skill_Rank','General_Skills', sameRow('General_Skills'))))}$```
Is there a way to to reference the column kinda like sameRow but down lol
was trying to get rid of the PCF_Table name since its referencing the inside the table
Nope, only with fetchFrom...
Yeah, just use the %{}%-delimiters like I did.
${%{
const generalSkill = '${sameRow("General_Skills")}$';
return generalSkill.contains('MG') || generalSkill === '-';
}% ? 0 : max(...)}$
Is there anyway to use truncate?
You have access to Javascript, so yeah
Lol was talking about through the csb but i get it
CSB has only access to functions mentioned in the Readme and in math.js (excluding loops and functions with lambdas).
I am getting failing calculations within my sheet that werent there before
at M (math.js:6437:59)
at Function.oe (math.js:6725:51)
at Function.addScalar (math.js:6740:54)
at Function.oe (math.js:6724:82)
at add (math.js:6740:54)
at math.js:25781:48
at Object.evaluate (math.js:24162:45)
at r.evaluate (math.js:24139:55)
at Formula.computeStatic (Formula.js:858:27)
at Formula.compute (Formula.js:442:21) {formula: 'PSD + pcf/10', props: {…}}
I can make a change to any field and refresh and it will populate correctly then error out on the next open
Your formula is PSD + pcf/10. One of the both keys seems to be undefined.
There both definded unless something happened and was dropped
let me review, searching through the Json now
pcf is defined
PSD is defined
I am also noticing in the json everything deleted or changed still gets noted, is there a way to clean that up? IDK if memory for the scaler is an issue
Only manually. And no, that's not the issue.
Populates fine after I update a field
but then I refresh again, it goes back to errors
Do you use setPropertyInEntity() in a Label text (not Label Roll Message) somewhere?
Not at this moment
Not recommendable anyway
gotcha
Yeah only thing I was going to do is break down the containers allowing races to modify things as well as weapons and what not
I dont know if that will cause issues but thats a issue for later Dragius
right now, I cant continue forward until I resolve what this issue is
I got a lot more calculations to do
You can validate your values with the Label prefix in the target-Label. Just do ${componentKey}$ and see if it is present after a reload.
Otherwise you can also check your props in the error message.
That's irrelevant. You only have to look for errors and uncomputed-props-warnings
Here is a copy of the json
See if your getting the same errors
Outside of it being a lot of calculations, there shouldnt be anything weird
Hi guys, trying to get my head around item pile with CSB. Everything seems to work, except for quantity related features. Is it a compatibility thing or am I doing something wrong (I know that this module is not natively supported yet so i'm not sure).
That is a problem already reported by several people but as far as I know there is no clue at the moment how it comes or how to solve it.
I saw a few days ago that wasp was working on compatibility between CSB and item pile so maybe that's what he was talking about.
So it's not me doing something wrong, that's what I wanted to know so thanks 😘
Hey, I never used/tried csb , but I was wondering if it was working with the Currencies brought by monks enhanched Journals ?
I dont have a answer for you but I would suggest trying it out
Hey, I'm back with another weird question. This one seems like it might've been tried before, but I couldn't find exactly what I was looking for by searching this chat so sorry if this is a repeat.
Is is at all possible to define a custom part of a roll message with a formula in an item itself? As a simple example, I have a rollable label in my character sheet's item container which puts out a message. This message is
${!item.use_text}$```
where `item.use_text` is a short string defined as `Dealing ${([1d10] + STR)}$ damage.`. As you can probably expect, I have no trouble retreiving the string, but I'd really like to have it actually execute that roll instead of pasting it as text. The ideal final message would be something like:
```Used [Bomb].
Dealing [(rolled number)] damage.``` Of course, the benefit of this is that I could have a custom part of every item's usage message that contains that item's unique damage number/formula
I tried using recalculate in various places (recalculating the item.use_text call, recalculating the actual roll formula itself, both), keeping in mind the quirks that that function likes to have, but I either get it to print the message normally or it throws an error that stops it from printing a message at all
Hi. I just started using CSB after I was told sandbox is no longer being actively developed. Any tips or tricks? I am trying to get my sheet built before my next session with my players and this seems like so much more compared to sandbox.
I don't have any experience with sandbox whatsoever, but taking a quick look at it it looks like everything you know is here just with a slightly different look. Some very light coding experience will likely be useful to you (mainly just understanding the basics of syntax), but nothing heavy if you're not doing anything too weird. I imagine you've been to this page if you've made it here, but I'd make this a permanent resident of your browser tabs: https://gitlab.com/custom-system-builder/custom-system-builder/. It's pretty comprehensive about what everything does with pretty good examples of how to do it.
Also when you're starting out, keep ref(' on your clipboard lol. Any time you need to have something check the value of something else, you've gotta use ref. Minor trick there, always include a fallback value if possible (ie, don't just ref('strength'), do ref('strength', 0)). Pages will try to skip calculating things they don't think they need, but in my experience, they're really not perfect at guessing what is or isn't a useful value.
More a best practices thing than anything else, but it's a tip I wish I could've given myself when I started using CSB
Thank you for this. Sandbox was a great system when it worked, but after Foundry moved to v10 they just never updated it and it's been a semi buggy mess for a while. Thankfully I'm a developer by trade, so I have the coding experience. Hopefully I can get something cool going here like I had in sandbox sheet wise.
Do you know if there any custom css sheets out there that I can just look at? That aren't the export and import ones.
Consider the Custom CSS Module. Its makes applying CSS very easy.
The only custom css sheet that I am aware of is for the setting Household. Its posted here, so you can search in the channel.
Also, you just happen to have mentioned Item Piles while I'm trying to get it to work, do you happen to know if there's a way/how to configure currencies on Item Piles with CSB sheets? I tried making a hidden attribute of my currency then pointing it to that (in this case I made the attribute credits and told it the currency was props.credits), but every time I try using it it just reports that it can't find the attribute.
How would I set up a roll that would check against a number, so I can see if it's rolling under that number?
Can't seem to find an example of that in the example template
2. Roll is over stat being rolled. FAIL
3. Unmodified roll exactly matches stat is a Crit```
are the states I need to check for... This can't possible be difficult
I say to myself, bad at coding
lol
${#roll:= [1d20]}$
${roll == stat ? 'CRIT' : roll < stat ? 'PASS' : 'FAIL'}$
Something like this?
I mean.. Yeah, probably
Ok so
Was about to ask what the := does, but I just got to that paragraph in the documentation
Thanks! I'll give this a spin
Just use system.props.credits
Should work
Ahhh, okay. So the ? is testing each event, the : is an Else... I see
That's what it was! Thanks so much dude!
Hey all, how wouldI calculate if a d100 roll is double numbers (11,22,33, etc.)?
It's the ternary operator. As you said, it's a conditional where [condition] ? [if true] : [if false]. It's basically an if statement written in a different way
yeah
lordy lordy...
Okay, tell me what I'm doing wrong here
custom dropdown list key testchoice
keys are Check and Fight
I want the label at the top of a table to change from Bonus to Penalty depending on which is chosen. Bonus if it's on Check, Penalty if it's on Fight.
${ref(testchoice) == Check ? 'Bonus' : 'Penalty'}$ this returns an answer, but only "Bonus," and doesn't change when I change the dropdown option
I've tried checking with the key and the label from the dropdown list, but neither work properly
ref(testchoice) is the same as ref('Check') which is the same as Check.
Additionally, comparing strings does only work with equalText(). So at the end it should be this instead: ${equalText(testchoice, 'Check') ? 'Bonus' : 'Penalty'}$
Ahhh
That did the trick! Thanks much!
A quick ctrl+F in the documentation for "equalText" returns nothing, so at least this time I can't blame being blind
It' part of the math.js-library (the library itself is mentioned). You will also find examples with it in the Wiki.
There's a wiki? Is it different from the gitlab page?
Yeah. It has some more information 😅
That will probably help!
Wiki != Readme
Yeah
Oh wow yeah this is way easier to follow
lol
Well, props to me for figuring stuff out with the readme I guess
it works
Is there way to display the status list and edit it? Like adding custom status or something like that? Or does it take a module to do that?
Which status list?
I'm sorry maybe i'm not using the correct term, i'm talking about that
"Core Settings Expanded"-Module can help you there
Thanks, I will look into it ! 👌
I've been looking at math functions but unsure how to make it round any negative numbers to zero. If weapon has 5 ammo left and a burst attack subtracts 10 it should go to 0, not -5.
Could do it in other ways of course, but it feels like there should be a math function for this that I'm just missing.
Take the max between 0 and (current ammos - ammos used)
Aha, like max(0, (max_ammo - ammo_used))
Hi, do you manage to make automatic status changes on data scores in the sheets ? I couldn't make it work myself.
Thansk!
I didnt take a look at that yet, but i will
Can i manipulate a hidden Attribute with a number Field? Would like to add +1 to my hidden attribute as Long as the number HP_current if 5 or less. I know how to do this with items or Status effects But These are Not involved here
Having an issue with radio buttons when they have the same value. Four buttons in the same group, all with different component keys. When two have the same value in the resulting sheet, the clicked button jumps between them. In a switchCase the ones with the same value act like the same component key.
Hidden attributes can have formulas, so np
The values also have to be unique across the radio buttons in the same group
So i could build a condition. How Can i increase its value by +1 if condition is true? Dont warnt to set value ==1, But increase it by 1
Sadly, I don't think that exact thing is possible. I was actually just trying something similar so it's fresh on my mind. Anything other than a hidden attribute, it works fine, but a hidden attribute has a static formula. There are 2 ways to accomplish it with a hidden attribute that I've used though
- Incorporate the condition into the attribute formula - Let's say your condition is
twohand. If it's true, the player'sstrengthincreases by 1. Set the attribute formula forstrengthto[normal strength formula] + (twohand ? 1 : 0) - Use items - If this is a conditional that's more like a status condition than something the players will edit in their sheets, use an item with a stat modifier. Stat modifiers are applied after the normal formula, so equipping an item can add +1 to your hidden attribute as much as your heart desires. Just set the item's modifiers, make sure the character sheet has an item container that can hold that type, and drag it in.
${defaultValue + (condition ? 1 : 0)}$
Aha, then I need to change approach. Dropdown might better... 🤔
Thanks!
Dropdown keys also have to be unique
Oh, haha! ok
that workesd, thank you!
it this a valid visibility formula: AND(KU > 0, HU=0)
?
No, you´re using an assignment-operator =, which is not allowed
=, == and === have different meanings 😅
Are opposed rolls possible (in a reasonably straightforward manner)?
Something like actor roll > await target roll > result...
Possible, because Script Expressions can also handle async-tasks. But you´d require your own script to handle that
Ok, thanks
I'm now at a stage where everything works as I want (or I know how to make it work as I want) and looking mostly at nice-to-have stuff. 🙂
can you change a specific value in a DynamicTable using an itemModifier ?
That´s possible with a combination of fetchFromActor() and getRefFromDynamicTable() in the item modifiers key
damn, if it look like what I guess it's gonna be a long ass key for just a +1 XD
Yeah...
Question time!
<td><p><b>${! equalText(testchoice, 'Fight') ? string('Attack bonus:') (first(fetchFromDynamicTable('weapons_table', 'attackbonus', 'Weapon', aptchoice))) : string('')}$</b></p></td>
I am trying to have it so if testchoice is not showing Fight, then the string Attack bonus: X won't show up in the table that gets output to chat.
Right now it's throwing an error. I think it's because it doesn't like that I'm saying its True statement is both to output a string AND include a fetchFromDynamicTable. Is there a way I can have both?
The conditional statement is working in that if testchoice isn't on Fight, it won't show the thing at all, so at least I've got that
On your true part you need a concat(string1,string2) to join the two strings. I think that is the error you're getting.
The second part isn't a string though, it's a number being pulled from a dynamic table
Get a string() around it, should work.
it did work, but the styling in the chat window shows it as text rather than as the grey box number thing it does for other numbers...
Hmm
That's another story...
I got that formatting with a macro in which a chat message is created. I'm not able to get to my PC, so cannot show you, sorry, but you can find an example on the web for sure.
Plus, grey boxes are for dice rolls, I'm afraid. Not sure, though.
I've got my modifiers/bonuses showing up like that
Like this
I want that 5 to look like the 0 next to it, is what I mean
So it works for numbers too, good to know 😅
I see.
I'll send you a pic of my macro tomorrow morning, maybe it's what you need 🤷🏻♂️
appreciated
but there's gotta be a way to stick these two things together in the true statement, it would be insane if there wasn't
Like the & function in Excel
As far as I know only concat() does it. You might want to search the web for a JS function doing what you need.
Hmm. Well, I'll have to try and figure it out later
The ! in ${}$ means that the boxes will not be rendered for the whole formula. If you want those boxes, move the number to another formula or use your own styling.
~~Apologies if this has been asked before, I've been searching but couldn't find anything directly related to this issue: when I switch tabs on this sheet, the image for the actor jumps around, is there something I can do to keep the image fixed near the top?~~Scratch that, I figured it out, I'd been putting the tabs in the header which was messing with the formatting
Okay, that's good to know. So then my problem is how do I have a result show in the chat box only when a condition is set, which includes both a string and a number it's pulling from a table
Unless...
no, the problem remains
Damn damn damn...
Excuse me if this has been covered.. just getting to chat
How is the condition being set?
<tr>
<td><p>Bonus/Penalty: ${bonusmalus}$</p></td>
<td><p>${attbon != 0 ? string('Attack bonus: ') attbon : string('')}$</p></td>
</tr>
</table>```
So I've got this. `attbon` is a `fetchFromDynamicTable` call. If `testchoice`, a dropdown box, is set to `Fight`, `attbon` will pull an attack bonus from the table. Otherwise it'll set to 0.
I want the above to send to the chatbox the table showing both the bonus/penalty as well as the attack bonus if the sheet is set to Fight, or not send it if it isn't.
So it'll look like this if testchoice (the dropdown on the left) is set to Check or Contest
And this if it's set to Fight
The error is where I want Attack bonus: X to show up, where Attack Bonus is a string and X is the attbon stat pulled previously
<td><p>${attbon != 0 ? string('Attack bonus: ') attbon : string('')}$</p></td> so the problem is here, where the true function needs to be both a string and a variable
If I get rid of attbon after the string, it obviously gives me this. I just... Want that extra bit, lol
Screw it, I'll just have it always appear
.. Oh wait, I could have two conditionals
HA
It worked
thank you random thought
Sometimes talking through it helps
<tr>
<td><p>Bonus/Penalty: ${bonusmalus}$</p></td>
<td><p>
${! attbon != 0 ? string('Attack Bonus: ') : string('')}$
${attbon != 0 ? attbon : string('')}$
</p></td>```
Just made it do it twice, lol
Considering it never got a response, I doubt anyone is interested, but I did make a solution to this problem. It's not amazing, but it does work. If anyone wants to store item text like this, it's possible and I can DM you the macro/roll text combo I made for it
I am reading Ry
give me a second
Ohhh Item stuf... I am not quiet there yet.. LOL
Would love to see or hear your solution tho
Awwww damn, doing that though leaves a little dooder showing up when I don't want anything showing up.... Oh well
I think there is away to not put something.. let me look
I could put a ! at the start of the function but then that gets rid of the little box style I like
the '' is what is causing it
can you put a ! at the beginning of the string
!string('')
BTW I dont think you need to add string to the code..
gives an error
interesting
I probably don't, yeah