#Custom System Builder
1 messages · Page 19 of 1
Is Forge doing something again? ...
Boy do I know! 🤷🏻♂️
I already had a few cases where the issue was on forges side
Updated everything and it's all f'd up...badly, for what matters...
Console is in italian, but I think you understand what it says...anyway, first one says it could not load TabbedPanel.js due to application.xml MIME type not allowed, following say that several CSB components could not be loaded...Code-Lord knows why...
Not a problem for me, I'm italian 😉
But if you want them in english I can do that
Custom System Builder uninstalled and reinstalled...nothing works, just like before 😭
Well, I'm out for tonight. Need some rest, then I'll try and tackle the issue tomorrow. Cya.
Can I use setPropertyInEntity to set the value of a label from a number field in an item?
Nope, you can only set Input Fields
Would I be able to set the input field value of another number field then?
If so what would that formula look like?
Yep, that would be doable. Various examples can be found under the description of the function: https://gitlab.com/custom-system-builder/custom-system-builder#4211-setpropertyinentity
Yup yup. But how would I take the entry of the one number field and move it to the other one?
setPropertyInEntity('self', 'targetNumberField', item.sourceNumberField) (if target is in an Actor and source is in an Item).
This will be difficult to explain, I think. I am getting about 12 errors that I think relates to the same issue. This is the simplest to explain. I have a button that deletes a specific item from an item container and adds a new item. The item has item modifiers which are used to generate a sum. I have a label prefix that is part of the errors. The error starts with
Formula.js:870 SyntaxError: Value expected (char 9) (at math.js:27324:37)
and ends with
{formula: "concat( < 65 ? 'red' : '')", props: {…}
The missing value after concat actually shows up on the sheet (ie no error or undefined on the sheet) and is part of the sum from the item modifiers. I think the error is generated between when the item is deleted and the new one is created. The links in the error dont seem to point to the problem code. Any ideas? Thanks
Hey guys... Feels like I've just got something simple making me want to gouge my eyes out.
if (!token) return ui.notification.error("Select a token first.");
This won't stop the script if nothing's selected. Thoughts?
concat( < 65 ? 'red' : '') what are you comparing against 65?
The label prefix is <div style="color:${concat(${RemainingXP}$ < ${minimumXP}$ ? 'red' : '')}$";>
Alright, and why the additional CSB-Formulas in it? Why not using the plain keys? And concat() can also be removed if you only have 1 string 😅
Great! That removed 8 of the 12 errors. The following error I think is being caused by the previously stated issue. I can't find the code that seems to be the culprit in the links:
Do we even have an active beta for version >3.0.0?
I installed it in Foundry when the beta went live and didnt see a need to switch over to the "live" version (waiting for next version). I update to the live version to see if it resolves the issue.
Quick question:
I used to use a really ugly nested IF statement that would pull a value. Now, I moved to using a switch case. This formula is within a dynamic table
Then, I used a fetchFromDynamicTable that would pull whatever that value was from the nested if statement. However, now that I am using the switch case, that fetch no longer works. It just gives me an error. Does the switch-case not actually provide a value that can be fetched?
Can you show the error?
And the formula
${fetchFromDynamicTable('weapon_magazine_dyntable','weapon_magazine_bullet_damage','weapon_magazine_used','1','>=')}$
This is the fetch code. The weapon_magazine_used is a checkbox that I look to see if its been checked.
Then the switch case is (and im cutting it a bit short since its very long but the switch case itself does work): ${switchCase(sameRow('weapon_magazine_bullet_type'), ref('bullet_one'),ref('bullet_one_dmg'), ref('bullet_two'),ref('bullet_two_dmg'), ref('bullet_three'),ref('bullet_three_dmg'), ref('bullet_four'),ref('bullet_four_dmg'), ref('bullet_five'),ref('bullet_five_dmg')........
Essentially, I have a table of bullets and that table provides bullet damage, bullet weight, and a whole bunch of other very specific attributes. I used to use a nested if statement however, the games been lagging a lot with this. And the console will often sit there recalculating bullets anytime anything is changed on a character sheet (these guns are items which are within item containers on actor sheets) and this can go on for a while with some annoying lag. I figured going to a switchCase would reduce lag. Unsure if thatll actually work but considering it was like a 30 nested if statement, maybe it caused the lag. But thats why I made this change in the first place but just having issues with now fetching the value the switch-case got
It shouldn't make a big difference between nested if-elses and switchCase() performance-wise.
You can also remove ref() because you're using static strings in it. The component key itself should be more than enough.
But I can't tell what causes the issue from the information you've provided.
hm
Prolly not
yeah it didnt. shame
It worked before with the nested if statements but now just doesnt. Very confusing
Actually, replace 1 with true and remove the comparison-operator.
true without quotations right? or with
Without, it's a keyword
kk
${fetchFromDynamicTable('weapon_magazine_dyntable','weapon_magazine_bullet_damage','weapon_magazine_used',true)}$
still seems to provide an error .Strange
Just to provide a bit more info. But you can see here that the items dynamic table, the bullet damage column (where the switchCase is) successfully finds the correct value. But once referenced by the fetchFromDynamicTable it can't get it
Where is the formula of fetchFrom?
It's in a label that is not within the dynamic table but still on the item template
Ok, that's fine
Yeah. I'll have to workshop this at some point. I could use a drop down but referencing the value of the key in the drop down is a bit confusing for me tho I'd prob have to just mess with it
It's just ref(dropdownKey)
dropdownKey becomes the selected key, and that is then processed by ref()
Yeah. It's just weird because I still have to fetch it from the dynamic table. And when I tried doing ref(fetchFromDyn...) it didn't seem to workn
Which version of CSB are you using?
Possibly a bit older but nothing crazy. Maybe updated 45 days ago. Unfortunately I'm away from my computer now
That would be the latest version, there was no update since months 😅
Ah okay loll
So I've been working on making something with CSB (day 2.) I was putting some text boxes in a table and I cant figure out why the label for two of the text fields are out of alignment with the others. Is there something I can do to fix this or do it be like that sometimes?
Actually, you're using 2.4.4 and not 3.0.0 if I see the error message correctly, so you're not on the latest one.
Fuck. Alright. I'll get my friend to update it lol. I will return tomorrow once it's updated and if I maybe get it working or go with drop down. It's not even my campaign but I do all the coding on it lol
Thank you for the help, much much appreciated
You can fix that by applying your own CSS-rules. You can use the CustomCSS-module for that or provide your own CSS file and reference that in the game settings.
Which components are you using in the table btw?
I'm kinda driving without a steering wheel here. I have next to knowledge of CSS. I've been learning as I go. Where can i find out how to do that?
Components are three text fields and 2 dropdowns.
Any alignment rules for the table?
Ah, yep. that was it. Forgot i had tried to do something eariler with it.
You'd need to know how CSS works in the first place (google can help you there)
Thanks!
Simple solution to that. Make sure your panel layout is set like this:
Actually ignore that. I didn't read that properly. I thought it was a panel not a table. Sorry.
np, thanks for answering
This is what you want - still an easy fix:
Could I put this in item modifier or do I have to hook this up to a button?
Should be in a button
Hey is thier a way to move the avatar symbol area on the sheet when making a custom one or shrinking the panels to a certain size in the header
Shrinking the picture via "Configure sheet display" on the template. Moving only via CSS.
@vagrant hollow ahh thanks
I'm trying to set thing so that when you click on a certain label the chat shows a simple message containing, among other fields, a description. My intention was to put the description in a hidden dynamic table in the sheet and then pull data from there, problem is that players could delete roes and data won't be there for new actors created from scratch and not by duplication. Any idea on how to achieve what I need?
What about a Dynamic Table with undeletable predefined lines?
Thought of that, but do not know how to make rows undeletable. Still players could change the values, couldn't they?
Yeah. Then create an Actor the players don´t have access to and pull your information from there
Could try that, thank you. Rollable tables could work?
Never worked with them 😅
Oh well, nvm 😉
To make the rows undeletable, use CSS to hide the delete\trashcan icon. CSS can also be used to make fields uneditable. You can use CSS not to keep these effects from effecting the template by .className:not(_Template *){css commands}. Recommend using Custom CSS module for this.
I am now on the latest version though unfortunately, the fetchFrom is still not working on my switch-case
😭
So weird. The fetch works for everything that is not using a switchCase
wtf
So I switched it around just incase. So instead of having a label (that is outside of the dynamic field where the switchCase is present) that pulls data from another label that has a switchCase, instead the field within the dynamic table will reference a cell that used a switchCase that is outside the dynamic table. But this actually also does not work.
Referencing a cell that uses a switch case returns nothing
So I think that is just my issue in general. Maybe a bug, I don't know. But referencing a cell that uses a switch case does not work?
Can you send me the template?
Sure
Item Piles 2.8.2 should add support for CSB
So when I do that it does throw up an error. Also is there a way to set the property entity as a one time thing so the players can still edit the field?
Noice one!
setPropertyInEntity() is just changing the current value of an Input Component. The players can ofc still edit the target input component.
I'm getting this error when I'm puttin in the formula for setProp:
It should have access to Armor_Durability
I´ve never seen this error before 😅
Oh
That's lovely
Maybe I need to remake the armor template.
${setPropertyInEntity('self', 'head_armor', 'item.Armor_Durability')}$
This is the formula I'm using
That works fine when using in a Label Roll Message in an Item Container
Would they all need to be within the same panel?
Because at the moment mine are not in the same panel.
Panel is irrelevant
Even with a new armor template, new item container, and doing a restart it seems to break everything.
It will set the value but it then locks up my templates and sheets.
Do you want the world in a download to take a look?
Could it be my custom css?
Probably not, that one affects only styling
I'm a little stumped on what is happening
Can you send the templates?
y
Both the armor template and the char_template
Things might look weird since there is no styling
Where´s the formula with setProperty() ?
I am not able to leave it in there as it results in me not being able to edit the sheet and freezes my foundry.
It would be in the inventory tab at the end for armor.
I can try to readd it and then resend it
That works without any issues on my side
Can you show me exactly what you did?
Just to confirm that I'm not implementing something wrong.
Just added your formula to the Label Roll Message of inv_armor.Durability
${setPropertyInEntity('self', 'head_armor', 'item.Armor_Durability')}$
You added this formula to confirm?
y
When I placed that formula within the property its giving me this error:
This is what I have in there currently
Which version of Foundry, CSB? Any modules loaded? Do you use Forge?
Foundry: Most Recent, CSB: Most Recent, Modules: Dice So Nice + Addons, Forge: No.
Then idk. I cannot reproduce it with your template.
how do I create a button?
Just define a Label Roll Message. It acts then like a button
ok
Okay, so I’m trying to do a thing.
I want to display a character’s weaknesses and resistances based on their current elemental attunements. Characters can have up to 3 elements attuned at a time and weaknesses/resistances can add up.
For instance a character attuned to Fire would take 1/2 dmg from fire. A character attuned to Fire and Water would only take 1/4.
I have elements set up in dropdown lists.
Any ideas on how could approach this somewhat elegantly before I hamfist this?
I suggest that the resistances are different for every character?!
So setting a number field where the player can place his basic coresponding resistance. Beside of this set a label were in the label text it is checked if the corresponding key of the dropdown is set and the resulting resistance is calculated and printed on the sheet.
With this you need only 3 fields on the sheet.
Thank you very much 🍰
Are these attunements changeable throughout the game or are they set on character creation?
If they´re defined only at character creation, then Items with Item Modifiers (modifying the damage-modifier-stats in a Table) should be the best choice. Otherwise, Dropdowns should be fine as long as your Formulas for your Damage Modifiers are handled correctly.
Sadly item quantity is still not showing up at all. 🥺
What is your quantity property in item piles
and where it is located in the item's template
@vagrant hollow
Wow, just was trying to type a bug report ^^
It is a number field with key “quantity” right beside the “item price attribute”, which is working perfectly.
Setting is “system.props.quantity”.
Maybe not related – in console I get “An error occurred while rendering MerchantApp 103. Cannot read properties of undefined (reading 'getKeys')”
Thanks for a marvellous module.
Can you paste the entire error, please? 🙂
And images of your setup would assist me as well
As you wish.
This page of the settings?
Number fields are stored as strings (no idea why) btw
I was told that item.templatesystem.getKeys() can be used to get an item template's keys
Maybe you are on an older version of the system that does not support this?
I am doing this:
if (game.system.id === "custom-system-builder") {
const itemTemplates = game.items
.filter(item => item?.templateSystem?.isTemplate)
.filter(item => item.templatesystem.getKeys().has(item.system.body.contents));
for (const item of itemTemplates) {
itemTypesWithQuantities.add(item.name);
}
}
Foundry 11.315 CSB 3.0.0 Item Piles 2.8.2
As am I
What if you type this into the console at the bottom and press enter?
game.items.getName("_Armor").templateSystem.getKeys()
Replacing "_Armor" with one of your item templates
the name of it, that is
So it exists
Well then I will add an additional check 😄
This is why I don't like adding support for additional systems in the code, so many small issues lol
And "gmptown" right beside for price works perfect.
I totaly understand you.
Sorry, that I was coming up with it.
im almost done woth the fiorst sheet then need to do the mech sheets then i need to figure out how to get it working like a sheet nd macro for combat rolls
Try with 2.8.3, it should work now
Sadly – nope.
ItemPile uses a character sheet – does this sheet maybe need a quantity key too?
Do I have to deinstall/delete all my piles and start from scratch?
Any errors this time?
Absolutely no errors.
Would it help if I send you my merchant json?
Nah, I think I just need to take another look
Oki. Tell me if i can help or test for you.
Thanks for your work.
is there anyway to combine arrays with text? This works to pull all the arrays together but would like to have names added to seperate the tables.
${concat(fetchFromDynamicTable('PCF_Table', 'skillName'), fetchFromDynamicTable('MCF_Table', 'skillName'), fetchFromDynamicTable('DXF_Table', 'skillName'), fetchFromDynamicTable('AGF_Table', 'skillName'), fetchFromDynamicTable('SCF_Table', 'skillName'), fetchFromDynamicTable('KIF_Table', 'skillName'), fetchFromDynamicTable('INF_Table', 'skillName'), fetchFromDynamicTable('SKF_Table', 'skillName'), fetchFromDynamicTable('CTF_Table', 'skillName'), fetchFromDynamicTable('DVF_Table', 'skillName'), fetchFromDynamicTable('VHF_Table', 'skillName'), fetchFromDynamicTable('TCF_Table', 'skillName'))}$
So on the Dynamic Table, 1stType and 2ndType reference the drop down lists with the corresponding keys. If the value of the same row ‘Element’ is the same as the Drop Down, it answers as “True” and “False” if it does not.
I need to have ThridType reference the ThirdType label above for the same True or False statement.
However, it doesn’t seem to like referencing the answer to a formula. Is there a way to do this?
What is the outcome your looking to achieve ?
Also, for a 3rd variable try using and()
but it looks like your trying to reference text
So the goal is for 3 tables to reference the same dynamic sheet. They will grab values based on whichever element is true.
Another table will then add those values together and define what they mean. (0 = Normal damage, -1 = 1/2dmg, etc)
OK so I do something similar but I use nesting ifstatements which has been working for me. The major issue you have is that the values your referencing is text so you need to use equalText() which is basicly a if statement in itself
let me see if I can piece this together for you based on my understanding
so I understand, the goal is to have a true true true or does that matter?
or are you saying if this is true tue false = this, if its true true true = this, if its true false true = this...
return will always be the element
the values of type 1 2 and 3 are variables
So the True in each column marks which element the character is attuned to. The first two are easy enough because they wont change.
That third column changes, but cannot be equal to either of the first two.
Running some simulations on my side to see if I got the context correct, give me another moment, I have to figure out the comparison in my head lol
lol okay. This is my first time with system and I'm pretty sure this is the hardest part I'll have to do for the sheet and its been giving me fits. I just want to make sure my players dont have to manually calculate their weaknesses and resistances each time they swap elements.
Yep completely get it
@pallid kettle try something like this - You could also tackle it via script.
${and(and(fetchFromDynamicTable('TableName', 'FirstTypeSelect') == 'true', fetchFromDynamicTable('TableName', 'SecondTypeSelect')) == 'true'), fetchFromDynamicTable('TableName', 'ThirdTypeSelect') == 'true' ? sameRow('Elements') : 'No'}$
thats basicly saying true to all values you pull the samerow from elements, mess with sameRow and fetch
sub out the tableName for whatever it is
I can also try to takle down the issue if you want to.
Might be easier to do that within a Script, CSB has barely any capabilities with arrays.
Its temporary, so I am just going to leave it like it is. I can combine the list which then pull the numbers and I roll based on it
Later on it will be different but its what I got = )
Assigning an array to each string value I would like to insert is a bit much
I would of thought that string() would of worked but it didnt lol
Where should I be dropping this formula?
Where is your result going to be listed? right now you have 3 values comparing to return the element, where is that being poplulated on your sheet?
i'v forced ThirdTypeSelect to work for this. It currently does not.
So my info will be populated at the bottom.
Type 1 table gives the weaknesses and resistances based on what element type 1 is.
Type 2 and 3 do the same for their respective elements.
Those get added together on the value table. (Thats not complete list because I can't get the ThirdTypeSelect column to work)
Does that make sense?
Interesting, can you shoot me your sheet template?
Gives me a good chance to test before i push it back to you
Sure, I apologize in advance.
No worries! I am just happy to help, been staring at my sheet for hours
@pallid kettle see my PM - need a new file
Using Dynamic Table, there's a way to sum all the numbers from a column?
^ I too would like to learn such.
sum(fetchFromDynamicTable('dynamicTableKey', 'targetColumn'))
Oh, Thank you! Divines bless your kind heart!
can someone help me? I'm trying to make one roll quote with advantage and disvantage in Custom System Builder, anyone know how to do this?
I have a label with a fetchFromDynamicTable formula in it.
If I give the label a component key, the value disappears from the generated character sheet.
Am I doing something wrong or is this normal?
Check the console (F12) for errors
I´d create a simple user input prompt to ask if the roll should be performed normally, with advantage or with disadvantage. Then I´d construct the roll-formula respectively and use that:
${#?{Roll_Mod:'Roll Modifier'[check]|'normal','Normal'|'advantage','Advantage'|'disadvantage'|'Disadvantage'}}$
${#Roll_Formula:= switchCase(Roll_Mod, 'normal', '1d20', 'advantage', '2d20kh', 'disadvantage', '2d20kl')}$
${[:Roll_Formula:]}$
Reference:
I am currently rocking no errors.
And warnings?
unless im missing something
Hello I'm using a script to call a macro and to pass data it as follows :
%{return await game.macros.getName('ProcessRolls').execute({labelroll: '${item.labelroll}$', jetint: '${item.jetint}$', typemag: '${item.typemag}$', modificateur: '${item.modificateur}$'})}%
but when the macro tries to use these values there a null. I tried this macro to test if they are passed correctly, and it returns nothing
async function displayPassedData(args) {
const { labelroll, jetint, typemag, modificateur } = args;
let content = `<p>Received Data:</p>
<p>labelroll: ${labelroll}</p>
<p>jetint: ${jetint}</p>
<p>typemag: ${typemag}</p>
<p>modificateur: ${modificateur}</p>`;
ChatMessage.create({
user: game.user._id,
speaker: ChatMessage.getSpeaker(),
content: content
});
}
Am I doing it wrong?
Doesn´t seem so if a sheet update shows nothing. How´s the formula constructed and how does the sheet look like?
These input parameters are not under args, they are already under their respective names. So just remove the 2nd line of your macro.
Oh okay thanks
I change it but same problem, nothings apears in the chat
Top two are the label/formula with and without key.
Bottom two are who it appears on the sheet.
Hello!
I am currently looking for a way to write a visibility formula so that something appears only if a certain dropdown list (with key A) is set to one of its options (with key 1).
So far I had A==1 as a visibility formula but that doesn't seem to work...
What should I write?
Keyed and keyless Labels are executed in different contexts. But I still don´t know what goes wrong 😅
So i'm not doing anything wrong and i should assume for now that i wont be able to reference that label due to background eldritch nonsense we cannot comprehend?
Cool, got that to work 😄
You can send me the current version of the template. Maybe I can find the culprit
Thank you! I'm usually having trouble understanding the notations in these readme things but if someone points out the exact one I should use I can figure out what to put where haha
Now if I want it to show up on two options of the dropdown, what do I write?
equalText(DropdownKey, 'Dexterity' or 'Strength')
what should the or be?
equalText() can only accept exactly 2 input arguments, in return it returns you a boolean value (true or false). If you want to combine results logically, you can use the or or and-operator: equalText(dropdownKey, 'Dexterity') or equalText(dropdownKey, 'Strength').
or:
- false or false -> false
- false or true -> true
- true or false -> true
- true or true -> true
and:
- false and false -> false
- false and true -> false
- true and false -> false
- true and true -> true
Here an overview over the formula system: https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Guides/Formula-System
Thanks again, I did read that, but without any coding experience my comprehension from these text is not great :0
Odd question: I'd like to duplicate the sheet's label roll message format for the results of the roll but in a macro where I format the roll specifically. In particular I want to have the roll result displayed next to a Die icon with a border and when clicked, display the individual rolls like shown in the pic, with colors of successful dice and explosions. Is there code I can copy from somewhere for that?
I see a lot of people with this image used as a separator, is it done using CSB feats in the sheet, or is it some custom CSS stuff outside of CSB?
Css stuff from my understanding
I know icons can be used like the d20 roll icon
As long as it comes from https://fontawesome.com/
Ok ok, fair. If this is done with CSS they must be able to add any kind of image anyway.
I was hoping to find out exactly what was used to save time
I just updated to foundry v11, and to the latest CSB. Is there a reason all items are orange now, and can I change the colour somehow?
One of the modules is causing that, it's not CSB
Apparently Monk's enhanced journal recolours them now? How strange.
It has no colours enabled on the settings, so I wonder why its doing this ...
Disabling Inline roll styling fixed it? I don't even know, I'll just be happy it worked
Is there a way to truncate the dispaly of a formula on a template? I have a set of formulas a half a mile long and it takes a few to get to the undo button.
Trying to use the "Initiative formula" in CSB settings, I put [1d20 + @VIT] but I always get 1d20 + 0, what am I doing wrong? (system.props.VIT = 3 on that actor).
CSB doesn´t use the @-Annotation: https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Guides/Formula-System#322-dynamic-roll-formulas
oh god, sorry mb, I should have check this
How do I add a label to a label roll message only if it isn't null?
Essentially, if label not null output label
Need to find a way to do that, because currently if a roll message includes a null label it doesn't output at all
Thank you for the link. I'm trying to piece it together to find what I need.
Another dice question. My system rolls 4dF + modifier. I want to include a way to reroll the one blank dF whenever the outcome of the 4dF part of the roll is 3. Basically a roll of +++0 is regarded as a potential critical hit. Rerolling the 0 and getting a + confirms the critical hit. I would also like to get a visual confirmation of a critical hit (++++, or +++0 with a rerolled 0 coming up +). Can anyone point me in the right direction?
Check this article here: https://foundryvtt.com/article/dice-modifiers/. If it´s not doable with this, then you have to implement your own solution via Scripts.
The official website and community for Foundry Virtual Tabletop.
Something like ${Label ? Label : ''}$? Might be more helpful with an example.
${Label != null ? Label : nothing }$
Although from my experimentation I expect a CSB-Formula will always result in a inline roll, since it does even with a null input.
Still, finding a way to not break the roll formula just because a Label is null would be good.
How about hiding the box with ${!Label ? Label : ''}$?
That works, I didn't realise ! would hide it
Hm, when using it on a rich text area, it errors out unless it is opened and saved on the character first.
Is it possible to set a minimum value for a hidden attribute?
question is CSB suitable for making a system that uses a card deck instead of dice?
Tricky... You can include your own Scripts, which should handle card decks instead of rolls. But that will require some more setups instead of just using the Foundry Roll API.
Well and the challenge is ever player need to have their own custom deck of like 13 cards and their is a central 54 card deck everyone uses
You'd basically need your own small subsystem for carddecks
I don't even know if Foundry has card decks by standard
Is there anyway to have a sort of equipped item slot ? where my players could drag their armor from their inventory into this spot. Bonus points if i can use this slot to pull basic info about the equppied item likes it armor value
That would be an Item Container. You can check the Readme and the Example Template to see how Item Containers work.
I've got some item containers. I just didnt know if i could drag an item from a container called "Bag" and into a spot called "Armor" for example. i have it working where the players can open the item and change a drop down item and that changes the container. wasnt sure if there was another way
Items are not dragged to Containers, they are part of an Actor, so you basically drag an Item to an Actor. What the Container does is displaying the Items conditionally.
So you have to think a bit different here
got ya! ok. I can fiddle with it and get it working. just wanted to make sure there wasnt another way to make it work. I appreciate ya as always @formal goblet
Alright, one more Question. I have a item that features a button. When pressed it runs ${setPropertyInEntity('self', 'Armor_Durability', 'Armor_Durability -1')}$ and works like a charm. i also have an item container where i would like one of the components to be that button. just so the player doesn't have to open the item every time. I got the button to appear but it doesnt run the code. I tried copying the same code to the button on the item container and that doesnt work either. Can this be done?
Hi all, first time user of foundry (any vtt really). Making a warhammer fantasy 2e game and using CSB. I have 0 experience in programming, so going to ask a bunch of noob questions.
First is how do i link Dynamic tables to drop downs if there on different sheets? lets say the DT key is stat_advance and the column key is stat_list. i put both in and get no link unless they are on the same sheet. The pdf says somthing about putting parent. in first but it does not work. thanks
Should be doable: ${setPropertyInEntity('item', 'Armor_Durability', "item.Armor_Durability - 1")}$
I excellent! I’ll try this in the morning
You can use fetchFromActor() to pull data from other actors. With this, you can switch to "Formula" for the dropdown-options and use this formula: ${fetchFromActor('actorName', "fetchFromDynamicTable('stat_advance', 'stat_list')", 'No actor found')}$
cool, how do i pull from items to actors?
Hi all, I'm still quite new to Custom System Builder and have the following question: Is ist possible to generate a dynamic table from another danymic table? To be more precise, maybe: I want to have a (hidden) master table where I put in all Skills that are available to the players including the calculations. On the Character Sheet I want to have different sections (e.g. "Melee") where only the skills which are labeled "melee" in the master table would automatically appear. (Explanation why I want to do this: Easier calculation of available Skillpoints, tidier backend and more flexibility to show skills at more than one place on the character sheet). Any Feedback or suggestions if this is possible and (if yes) how would be highly welcome.
Yes, I call these helper tables and use them all over the place. All you truely need to do is create the first table then reference that table in your other dynamic table. For example, I have a helper table named Melee, in it consist of Attack bonus, Range Bonus, Misc. My dynamic table is called helperMelee. In this case I would just fetchFromDynamicTable('helperMelee', 'Attack_Bonus') in my other dynamic table for whatever attack_bonus is) changes made on the helper table will adjust the other but not viceversa
That's great to know! Would it be possible for you to give me a short example or explanation how this is done?
You can also do this directly with Tables and provide them with a Key to reference. Such as standard Table maybe Melee and the key would bey meleeattack you would just reference ${meleeattack}$ in a lable
If you need help specificly, I am happy to look at your vision and sheet to help further
Thank you very much! I'll look into this and see if I get it wo work. If not, I'll get back :-).
I cannot get sameRow('options') to work in a dropdown that is in a Dynamic Table. The same code works in a label. Am I missing something?
Can you shoot your sheet to me?
Its an item. Here is the template. Its very much a work in process. It may give weird errors because its pulls from a master sheet. The issue is under the "Bonus Tab", enter a CSV in the untitled textbox. There is a test label that should show your entry via sameRow.
OK let me look
I dont understand why your export is providing extra data and will not import on my side
Had this issue with someone elses sheet recently,
That was via the export template function under Game settings. If you are importing from the item tab, try this
Ahhhhh
That maybe why
That looks like what I was expecting
got it
Your trying to reference the options on intemMods right
YES
OK where are you trying to reference this at?
As in, from the sheet or from another table
from same table, same sheet.
ok just making sure
ahhhh IC
OK
Your using formula
Change that to Dynamic table
Table Key and Column need to be included
That will allow the dropdown to appear
trying to get it to work with the formula now
I assume you have some custom stuff going on as well
I am not sure I follow. I think you may refering to some wayward code that I dont think applies
No, I was just saying if your using as formula in conjunction with the pulling of the dynamic table then there you go
or
both work
sameRow is not working in this context since sameRow looks at the row not the column
Does that solve the issue or is there more to it I am missing
ok. Thanks for the help. That worked. It just seemed that the column was specified by the value of sameRow
sameRow only looks at the value of the row your trying to calculate on so if I was to write an additional formula that was referencing the data of say options I could make that column read as a label something like ${sameRow('options') + 10}$ <-- this would then be applied to all fields in that column referencing the data of that row to calculate
Imagine the Dynamic Table is a 2-dimensional coordinate system. sameRow() will return the value of x = currentRow of the formula & y = specified column.
That's just an additonal dimension 😅
Thats a bit better, not so hurtful on the eyes lol
after a2 + b2 = c2 you lose me on math lol
I've already got another question which I need to solve before the helper table thing 😁 . Maybe someone can help me with this... My formula is: ${fetchFromDynamicTable('table_score_to_dice', 'dice_value', 'score_value', sameRow('spec_score_melee'))}$ This is a panel within a dynamic table. What it should do is: 1. go to table "table_score_to_dice"; 2. look at the column "dice_value"; 3. find the row in the column "score_value" that equals the column "spec_score_melee" in the same row of the original dynamic table (<== the one where the panel shall be generated); What it does is basically produce an empty label, so I guess, I am doing something wrong or do not understand the synthax correctly...
Hope it is clear, what I am trying to do and what my problem is.
So in this example I would expect the panel to generate "d6" but it stays blank.
Somehow when I first read your response earlier, it just ended after the first full stop (or I did not see the rest of it, because I seem to be really tired today 😆 ). Reading it in total now, it is very much clearer to me. Thanks again!
No worries and looking at your issue above
{fetchFromDynamicTable('table_score_to_dice', 'dice_value', 'score_value', sameRow('spec_score_melee'))}$
{fetchFromDynamicTable('table', 'value returned', 'reference colmun', 'filter')}$
Your filter maybe off, if your looking at another dynamic table you will need to use another fetchFromDyanmicTable to make that happen,
sameRow only references the table your first fetching and in this case it appears your nesting tables? You said panel but the panel should cause issue. if its a panel with a table that table will have its own reference ie ${ref}$
hmmm, I was fearing that it was a problem with the cascading tables. And I was already thinking about including a second fetch but I can't figure out a way to tell the system that it should refer to the correct row row then.
So what I want it to do is to compare the value of "spec_score_melee" (adds up "spec_points_melee" and "spec_heritage_melee") and look in the "table_score_to_dice" what would be the correct dice for that value.
Is there a way maybe to store the value of spec_score_melee just for that one comparison?
Suggestion, dont filter and tell me if it pulls something
If I don't filter it pulls everything from the column "dice_value" in the table "table_score_to_dice".
I tried the formula before with a simple example:
Here it works just as intended but i would have liked to do that in a dynamic table where it compares not to a single number field but to a certain field in the same row.
Ah! That might be it! I'll give it a try. Thanks again for the quick help!
It does 😂
Noob question : is there a way to do a roll (like 1d20) with a script macro (not a chat message)?
tried this :
let roll = new Roll("1d20").roll();
roll.toMessage({flavor: "Rolling 1d20"});
not working
The problem is that I dont need to return a matrix. I need to reference only a text field containing a CSV in the same row of the dynamic table so I can populate a dropdown. fetchFromDynamicTable does not work for this purpose.
You can call a macro or script via label and it will roll if thats what your asking
Yes ty !
Is there a tutorial on how to create a total for weight of a specific item container?
The FAQ has one. Otherwise you can also find some in the Example-Template
I'm running into another thing using the equalText(a, 'b') in a visibility formula (where a refers to the key of a dropdown list and b references a key of an option in the dropdown list).
I have 5 weapon slots formatted as dropdown lists: weapon_1, weapon_2, weapon_3, weapon_4 and weapon_5.
I want the description of the weapon to appear if it is selected in any of the weapon slots.
equalText(weapon_1, 'sword') or equalText(weapon_2, 'sword') or equalText(weapon_3, 'sword') or equalText(weapon_4, 'sword') or equalText(weapon_5, 'sword')
The above visibility formula only makes the description of sword appear when it is selected in dropdown list weapon_2, 3, 4, and 5. Not when it is selected in dropdown list weapon_1.
Why would that be?
Do you have an empty space in the option key?
No empty space
🤷♂️
Should work aye?
Aye...
What do you get if you just reference the key of the 1st dropdown?
You can also check the selected value with game.actors.getName('actorName').system.props in the console.
I'm an idiot haha - I'm making a Mexica themed game and all the weapons have impossible names - so it was indeed a spelling thing I completely glossed over lol
I've got my actors setup with an item container, but I want to roll an actor stat from the item sheet. Is it possible to reference an actors stat from an item sheet?
Also, can I do a dice roll where every highest value explodes but I only keep the highest of that chain. For example, I roll 3d6. Die 2 and 3 come up "6", so they both get another roll. The one associated with die 2 is 4 and die 3 is a 1. So the final output would be 10.
Would need to be a custom script to make it work as a rolling mechanic. Is it possible? yes, you would just need to be something like roll dice, if equal to 6 roll again and keep highest values on return..
Is there a way to allow commas in a numberfield?
use a txt box instead
yeah ._. that would be smart huh?
LOL its easier than fighting with it
If you want them to have a + or - you can always create a button that adjusts the value
Its for gold pieces, the txt box will work perfect.
You can use dots if the number field allows decimals
fetchFromActor() can do that
Wonder if you can help me with this chestnut. Have a problem with a formula ${(ref(skill_current) + string(skill_state))}$ There are 4 options for skill_state /2,+0,+10 and +20. They all work besides the /2.
@formal goblet In a dynamic table, Is there any way to have unique values in a dropdown that are based on a text field in the same row as the dropdown?
#1037072885044477962 message
Uhm, number + string doesn´t work at all 😅 If you mean to concatenate strings together, use concat(). If you actually want to add things together, then make sure that both values are numbers.
Wouldn´t that be just sameRow('list') in the formula of the Dropdown?
Thanks mate, will give it a try.
I thought so but that doesnt work. Empty dropdown. It does work in a label.
I feel like this is an easy one: I've got a dynamic table on an item sheet. There is a text field, a number field, and a label. I want the label to match the number field of that same row. I've tried "parent.{component_key}", "item.{component_key}" and a few other things I could think of. Any ideas? TIA!
ok, that one is my fault... forgot to integrate optional references...
You can fix that by your own by adjusting the code in custom-system-builder.module.sheets.components.Dropdown.js - line 168 until the update fixes it:
const keyOptions = ComputablePhrase.computeMessageStatic(this._formulaKeyOptions, entity.system.props, {
...options,
reference: options.dynamicRowRef,
defaultValue: '',
triggerEntity: entity
}).result.split(',');
const labelOptions = ComputablePhrase.computeMessageStatic(this._formulaLabelOptions, entity.system.props, {
...options,
reference: options.dynamicRowRef,
defaultValue: '',
triggerEntity: entity
}).result.split(',');
Alright, so a Dynamic Table in an Item with 3 columns. And where´s the target-Label, which should pull the data from the Dynamic Table? And which data do you need?
The target label is the third column in the item.
For example, the listed item in the dynamic table is "pistol", the next column is it's point value of "5". Ultimately, I'm trying to create a label in the same row that will roll (pointvalue)d(actorstat). You already showed me how to get the actorstat via fetchFromActor() but referencing the pointvalue is harder than I thought.
@formal goblet The target label is the third column in the item.
For example, the listed item in the dynamic table is "pistol", the next column is it's point value of "5". Ultimately, I'm trying to create a label in the same row that will roll (pointvalue)d(actorstat). You already showed me how to get the actorstat via fetchFromActor() but referencing the pointvalue is harder than I thought.
sameRow('pointValueColumn') 😅
Thank you! I was looking at some of your recent posts and thought that might do it. Thank you for all your help!
Strange thing happened. I had it working, closed it down for a couple hours then came back and it doesn't work anymore. This is the Label Text:
${sameRow('Concentration_Num')}$d${fetchFromActor('selected',"Def_Type")}$
The sameRow works but the fetchFromActor isn't coming up. The spelling is correct on Def_Type.
selected / target are not updating automatically after selecting / targeting a token
That´s why they´re better fitted for Label Roll Messages
This is the roll message:
${sameRow('Concentration_Name')}$ Shootin' Roll: ${[:sameRow('Concentration_Num'):d:fetchFromActor('selected',"Def_Type"):kx]}$
That's not working either.
What´s the error in the console?
How do I check? Sorry, I'm new to Foundry.
Press F12 and open the console-tab
Failed to load resource.
Could this be because I've been doing some work remotely on a different pc?
That one is about loading images, not really interesting in this case. Try the Label Roll Message again and screenshot the log
And you have a token selected?
I guess I opened it from the Actor sidebar. Is there any way to fix that or do I have to make sure I open it from the map token every time?
It worked when I did it from the token.
Selected means on the map selected
Copy. Thank you, again!
You can also specify a static name in fetchFromActor() 😅
The item is actually an "Aptitude" for Deadlands Classic. I've set it up to easily give the same aptitude to several actors based on 10 aptitude templates. So, from what I understand, a static name wouldn't work the way I want it to. BUT I don't understand all that much about CSB, as you can probably tell.
Is there any way to set a drop down value acording to a number value?
Like if someone is half health I need it to show the value: Critically Injured?
Do you mean changing the current selection or changing one of the dropdown options?
I need to customize the permissions on a character sheet tab as to whether it displays. Currently, there's a checkbox that selects whether it displays or not, so the visibility formula (referencing that checkbox key) is: powers_toggle -- what do I need to do so that, to see it, the checkbox must be true and the player viewing it must be the owner of the actor?
Current selection.
It's not released yet, but you can take a look at the code:
That would be difficult because Input Components cannot update fully-automatic.
Is there a way to initialize the rich text areas (essentially open and save them) to avoid this error?
Is there anything method that accomplish this?
Oh, so does that mean it's not possible in the current version? Looks like those functions will be very useful!
How do I use setPropertyInEntity to toggle a checkbox? I can set it to true no problem, but I can't set it back to false.
Initiative Formula: If the formula has a roll and a number (eg 1d20 +X) is the roll of all combatants stored separately and can be accessed or only the sum of this formula stored?
Only the total will be stored
Empty string would do that
Theoretically, setPropertyInEntity() could do that, but that is a big no no outside of Label Roll Messages (update-loop).
do percent symbols work fine, or would it be detecting it as a remainder?
guess I can just test this faster than waiting
Is there a way to allow players to re-order their item containers? Inventories are going to be messy otherwise
Actually no. But in next version it will be.
Amazing, looking forward to it
Is there a way to automatically update a value, such as when I add more con the max health updates automatically?
cause as it is, I have to still set it to what it should be, because its the max
The max-value allows formulas
it is set to a formula, but its not updating as I update the con, like just the displayed number, not the formulaic value
cause the formula behind it does go up, but it doesn't automatically change the display
along with this, is there a way to not allow certain people to edit the max values on their own?
Hello, I'm having a bit of a problem getting this condition to set properly. I'm trying to make it so that when you two-hand the weapon, you roll strength dice twice. Here is what I have so far:
${[((:str_score:+(2h_checkbox?'str_value':0)+:mod_value:):sameRow('dmg_die'):cs>=4)]}$
But it won't roll. I've tested it just without the (2h_checkbox?'str_value':0) portion and it works fine. What do? Thanks!
is there any errors popping up in the log for it?
such as not knowing how to convert the 2h checkbox or anything else?
yeah, it's calling syntax errors and unexpected values.
NS_ERROR_UNEXPECTED: 28 theme.min.js:4
SyntaxError: Unexpected operator ) (char 2)
SyntaxError: Value expected (char 1)
Uncaught (in promise) Error: Unbalanced group missing opening ( or closing )
[Detected 1 package: system:custom-system-builder]
${[((:str_score:+(2h_checkbox?'str_value':0)+:mod_value:):sameRow('dmg_die'):cs>=4)]}$
Only problem I could see is maybe an extra parentheses at the end. "cs>=4)"
cause
${[((:str_score:+(2h_checkbox?'str_value':0)+:mod_value:) the first two before str_score stop there.
:sameRow('dmg_die'):cs>=4)]}$ But the end here has nothing to close off
but I doubt that'd be the problem as you said when you remove the 2h_checkbox it works fine
no wait, I'm blind, its not an extra. I think
yeah, but it's probably unnecessary and just bogging up the line
Don't know if this will work for you or anything with your code. But I ran into something slightly similar
${[((:str_score:+(2h_checkbox?'str_value':0)+:mod_value:):sameRow('dmg_die'):cs>=4)]}$ is current
${100 + (equalText(class,"tank") ? ((100 + (8 * con_score))*0.2): (0)) Is what I had to do for something else.
so you could try
${[((:str_score:+(2h_checkbox?'str_value':(0))+:mod_value:):sameRow('dmg_die'):cs>=4)]}$ cause all I had to do to fix my case was make sure the default 0 was opened and closed (0)
I'm not really the best at code, so I just kept trying shit till it clicked into place
Same. Looks like that's not doing it either, but thanks for your help!
do you have a different formula to just return 2h_checkbox?'str_value':(0))+:mod_value: to see what it equals all on its own? so you can verify it returns what its meant to?
Ah, that is what you meant. Nope, you have to increase the current hp manually
The max-value is not editable by players.
gotcha. Not exactly what I meant, but I think I understand regardless
So this is my current code, realizing that I'm in a dynamic table now.
(:str_score:+:sameRow('2h_checkbox') ? (str_score):(0):+:mod_value:)
This line just calls for str to be the number of dice rolled and if the 2H checkbox is checked, add strength again.
When I just roll (:str_score:+:mod_value:) it works, and when I have ${sameRow('2h_checkbox') ? (str_score)}$ on a separate line it works on its own, calling 0 if unchecked, and your strength score if checked. But when I integrate it, it doesn't roll.
I looked into that, but can't for the life of me figure out where it's wrong. I've tried (:str_score + (sameRow('2h_checkbox') ? (str_score):(0)) + mod_value:) and it still won't work right.
You cannot use the ternary operator in Roll-Formulas (because of the colon). You have to construct your Roll Formula in a CSB-Formula before you can use that.
Oh ok, so do I need to make a separate formula on the sheet that's hidden and then call that formula?
Yeah
Or rather create a temporary variable in the Roll Mesaage
How would I create a temporary variable in the Roll Message? I'm unfamiliar with that process. Sorry, I'm not great with coding 😬
https://gitlab.com/custom-system-builder/custom-system-builder/#47-reuse-formula-results
In the end it should look like this:
${#Roll_Formula:= (...)}$
${[:Roll_Formula:]}$
That worked, thanks so much!
I cannot get a fulfilled promise to return at return a. The code is in a label text, not the roll message. The returned value to main is correct. I have tried numerous variations to correct this without succes. Anyone have any ideas? Thanks
async function main(){
const type = "Skill";
const modList = "${fetchFromActor('attached', "modList ", 0)}$";
const out = await game.macros.getName('Add Bonus to Skill').execute({modList:modList,type:type,attribute:"${name}$"});
console.info("myout",out) // indicates fufilled promise
return out;
}
const a = main();
console.info("out",a) //indicates a unfulfilled promise
return a;
@formal goblet Thanks. But I dont think this is the problem. I am getting a fulfilled promise from the macro.execute. I have edited my original code, adding comments to clarify where the issue is actually appearing.
It is the issue. Asynchronous tasks have to be async through the whole call-chain, which is not the case in keyed Labels
You forgot an await there as well:
const a = await main();
Thanks. I think, at some point I tried that too. The final solution I used is to send the desired output to a text box.
What would the formula for a fetchfromdynamictable be if I wanted :
All results in "Field 1" where the checkbox in "Field2" are checked?
There is an example foe that on the wiki but believe its something like isActive ? Fetch : no
Its an if else statement
fetchFromDynamicTable('dynamicTableKey', 'Field1', 'Field2', true)
Hey @glad spade, I checked an older chat where you were trying to fix the quantity property issue with item piles but never wrote back. Any progress on this issue? Thanks.
I searched around, but can't find anything. I just updated my CSB and world from v10 to v11 and everything on my sheets seem to work, so I'm messing around with adding some new stuff to them. Right now I'm trying to add buttons for Resting to heal, but I'm having an issue with setPropertyInEntity not working. I'm working with a fresh _template right now before moving it to my main one for characters, but here's the code:
${setPropertyInEntity('selected', 'txtTest1', "selected.txtTest1 * 2")}$
I keep getting the error:
at mathInstance.SymbolNode.onUndefinedSymbol (Formula.js:853:27)
at math.js:26377:89
at math.js:24320:51
at math.js:25781:50
at Object.evaluate (math.js:24162:45)
at r.evaluate (math.js:24139:55)
at Formula.computeStatic (Formula.js:858:27)
at processFormulas (ComputablePhrase.js:259:29)
at ComputablePhrase.computeStatic (ComputablePhrase.js:330:34)
at ComputablePhrase.computeMessageStatic (ComputablePhrase.js:371:26)```
This happens whenever I have Selected, Target, Self, etc. in the formula argument (including token names), but if I remove it and just reference ``txtTest1 * 2`` then it actually runs, but instead of changing anything in the sheet it just does the math of txtTest1 * 2 and posts the result as a roll to the chat.
The right prefix is target., not selected.
How is it possible for a RollableTable rolled from a Label to result in ERROR like this? Label roll formula is ${[#tablename]}$ and Table roll formula is 1d2
It does the same inside an Item or as label in the sheet.
EDIT: it was the text inside table rows...it did not like text like Hey...you're dead! 🤦🏻♂️
Have you tried in the latest Item Piles version?
Is this a Foundry Core Behavior or could CSB add a Var to store the roll result? (Would do a Feature Request then)
You can just create an Actor, which stores the latest roll results
Your version 2.8.4 ?
Quantity is still not showing up.
No errors.
Even tried in a new foundry install.
Oh, okay that does work! The examples on the readme made it seem like you used the same special values as you use in the 1st argument (self, target, selected, etc.)
Anyone know why the attribute can't go to negative value?
Alright try in 2.8.5
Is it for the bar only, or does it allow it to go negative on the character sheet?
This time, I can confirm it works
Question for whenever, is there a way to reference the label of a key for formulas so I can say what is selected jn chat. Or reference the label on which a dropdown list has selected?
Oh nice! It does work with the new version thx.
Hey, I’m totally new to using this, learning as I go. I’m trying to adapt the old palladium system to work with foundry, can anyone point me in the right direction of how to do this? And sorry if I’m in the wrong area to ask this
https://gitlab.com/custom-system-builder/custom-system-builder
Can't go wrong with a little reading just to get familiar.
Hi, is there a way to give players permission to alter other actors records within the formula?
For example as the GM I can damage a player in a roll, but players get alerts they cannot damage enemies unless given ownership
maybe a grant and remove ownership command?
Can't you call script to modify the target? Players can have permission to run macros and that should be run with GM clearance, so to speak.
So this has been me trying to use the update via roll in labels which was a way to avoid getting into macros...
Ah well...
Wouldn't know hot to do that other than macros 🤷🏻♂️
Yeah we are on the same page. It is just funny because I did all this building and testing and then once I invited players I was like OOPS!
That sounds like an issue with the user ability
I know the feeling
I dont have any issues running them as trusted player, but you maybe able to grant permission via script.. just not sure
Oh maybe I need to get into the weeds of what permissions a trusted player has so they can update but not 'spoil themselves' opening up enemies or folders
(not just for my table I love and trust them but for publishing for anyone to use)
There is a list of options in the Foundry API, I am sure there is away to set it. or make the macro public somehow lol
That is a limitation by Foundry. Only way I know is the module "Warpgate"
So I see a lot of modules get around similar issues by having a button in chat the GM clicks just gotta figure out how to add a 'roll' to those chats
that said you telling me about Warp Gate might be a game changer for our home game
One more question... does anyone know how I can 'publish' a world for Custom System Builder? I've adapted Liminal Horror and I want it to be searchable so liminal horror players can download it (and custom system builder as a dependancy)
(or are worlds basically compendiums now?)
You have to create an own module for that (not system because you can only have 1 system at all). Keep in mind that I cannot help in module-development.
Or you just publish the templates in our template-library
Turns out what I really needed but didn't know I needed was actor.roll() using /sheetRoll!
I was just going to ask this question but I'm not sure I understand your answer Martin.
I assumed if someone else wants to run their own campaign using my sheets and a pre setup world (scenes, actors, items) can't they just install CSB then insert the world data from my foundry folder?
That would also work (maybe, never tried)
I've copy and pasted world data myself without any issues, but not sure if that would work the same on a different PC.
Does /sheetRoll and actor.roll() support running the "Shift-Click" alternate label roll message on a sheet?
/**
* Add Chat command to perform sheet rolls from chat / macros
*/
Hooks.on('chatCommandsReady', function (chatCommands) {
chatCommands.register({
name: '/sheetAltRoll',
module: game.system.id,
description: 'Perform an alternative roll from a character sheet',
icon: "<i class='fas fa-dice-d20'></i>",
callback: (chatlog, messageText, chatdata) => {
postCustomSheetRoll(messageText, true);
return {};
}
});
chatCommands.register({
name: '/sheetRoll',
module: game.system.id,
description: 'Perform a roll from a character sheet',
icon: "<i class='fas fa-dice-d20'></i>",
callback: (chatlog, messageText, chatdata) => {
postCustomSheetRoll(messageText, false);
return {};
}
});
});
Thank you! Is there a corresponding actor.altRoll()
that can be used in scripts?
actor.roll() comes from Foundry while the chat-commands are registered by CSB
actually, it also comes from CSB...
I thought I saw it documented in the CSB
async roll(rollKey, options = {}) {
let { postMessage = true, alternative = false } = options;
let refRoll = rollKey.split('.');
let reference = null;
let [filterMatch, parentProp, filterProp, filterValue] =
refRoll.shift().match(/^([a-zA-Z0-9_]+)\(([a-zA-Z0-9_]+)=(.+)\)$/) ?? [];
if (filterMatch) {
let parent = foundry.utils.getProperty(this.entity.getRollData(), parentProp);
let index = Object.keys(parent).filter((key) => parent[key][filterProp] === filterValue)[0];
if (!index) {
throw new Error('Roll formula not found in character sheet');
}
reference = parentProp + '.' + index;
rollKey = parentProp + '.' + refRoll.join('.');
}
let rollType = alternative ? 'alternative' : 'main';
// Recovering value from data
let rollText = this.getCustomRolls()[rollType][rollKey];
There we go. alternative is the thing you´re looking for
So I can call it as actor.roll(rollcommand, true, true) to use and display the alt-label roll message?
That's awesome! Thank you!!
Uh, the 2nd arg is an object. So it´s more like this:
actor.roll(key, {
postMessage: true,
alternative: true
});
Oh perfect! Thank you!!
Is it possible to set the default value of a number field to a number that depends on a choice made in a dropdown list elsewhere?
If the formula for default-values works, yeah. But keep in mind that default-value != current-value.
Okay I have what I feel is very stupid question on my part, but how do I run the function fetchFromDynamicTable() within a script macro? I tried actor.fetchFromDynamicTable() but it said no such function
Fetch works the same in a script as it would in CBS
Whats script you running? It could be the execution
Either via Formula or ComputablePhrase. Check the sourcecode for both.
Was just doing this piece of code in a script
let secondary_list = actor.fetchFromDynamicTable('secondary_abilities', 'sec_title');
if (secondary_list.length > 0) {
console.warn("Number of Skills: " + secondary_list.length);
console.warn("Skill List: " + secondary_list);
}```
Question. So im attempting to use a parent sheet now to pull values for bullets within my campaign
${fetchFromActor('Parent Bullets',"fetchFromDynamicTable('parent_modifier_dyntable','parent_dyntable_mod_one','parent_dyntable_name',sameRow('weapon_magazine_bullet_type'))")}$
Now, one issue here. The filtered name which is currently shown in the above formula as sameRow('weapon_magazine_bullet_type') does not pull the value from within the item sheet. So all those keys are from the Parent Actor sheet but the sameRow is from within the item sheet which I imagine is causing the problem. Any way around this?
Interestingly, I found by adding a snippet of code above this as name:=sameRow('weapon_magazine_bullet_type') combined with the original formula above and then replacing thesameRow('weapon_magazine_bullet_type') with the new key that is named name it is able to find the value that I want. However, it now puts the value in my Label as the combined literal name of name and the value that I want from this dynamic table.
Any way I can get this to work? I want to fetch from a dynamic table from an actor sheet but the key that I use to filter my results will be from within the item sheet
Can you tell me how you are calling the script?
pulling up my instance, give me a second lol
I'm clicking it right now from the macro hotbar, but it will also be run from chat /macro rollDice
It doesn't, it is only part of a CSB-Formula.
Does the reference points stay the same when its called?
Wdym?
As a point of continuation, I will say @formal goblet this is the same thing I was doing the other day when I was asking questions and ive taken your advice to using a parent sheet instead but now this filtering issue is a bit of a problem
This is probably one of those things "Beyond my coding experience" to understand. I looked at sourcecode for Formula and see references there to fetchFromDynamicTable that seem to say it's importing it into Formula.js but no examples on how to use it. I thought Formula.fetchFromDynamicTable but I get Formula not defined
He is assigning a variable that does something.. that call is in CSB format so it should work.. HOWEVER looking at the script I belive you need ${}$ around it
Oh I didn't realize ${ }$ were used in scripts like that
looking through my scripts to validate
Martin would know better, I am here learning as well but like to help where I can
I find it helps me learn new things
I appreciate it. I have a 'fair' understanding of coding in general and I can look up things related to JS, but I really don't always understand how CSB/JS interact with scripts.
You have 3 things in a formula:
- fetchFromActor
- fetchFromDynamicTable
- sameRow
When entering fetchFromActor(), the formula within will be executed with the context of the target actor. So fetchFromDynamicTable() will have a look at the table parent_modifier_dyntable of the target-actor. Same goes with sameRow(), which will obviously not work.
If you need a formula with the context of the source-actor, then don't use double-quotes for the formula-part.
I need a formula that can pull from a parent actor that is filtered by a key from the source-actor
I learn much better by example and not sourcecode unfortunately
I learn by doing, so I get it! sourcecode hurts my head
And I struggle with the whole 'give a fish' vs 'teach to fish' and honestly I like to learn some things but sometimes just need to know what to change my syntax to. I tried ${ }$ around my code but that just got me unexpected token: '{'
You either need ComputablePhrase.computeMessageStatic(phrase, props, options) or Formula.computeStatic(formula, props, options), you cannot just use ${}$ randomly in a macro.
And well, you're going into stuff that actually needs some coding knowledge
I'll poke around in the references you gave. Thanks. I guess I didn't realize the complexity. I did a search first for fetchFromDynamicTable and saw nothing similar to what you listed, so I assume all those results were not related to macros.
Its not with fetch itself
Macros are pure Javascript, you cannot use the CSB-syntax there
Its how the script is implemented and how your wanted to push it in.
The code I linked is part of a much larger script where I use getProperty, setProperty, and other Foundry related functions to get values from a sheet and set values on the sheet and thought I'd be able to do the same with DynamicTables
fetchFromActor(actor, "fetchFromDynamicTable('table', 'targetColumn', 'filterColumn', '${filterValue}$')"). This would take the filterValue of the source-actor instead of the target-actor, because the injected CSB-Formula is outside the scope of fetchFromActor()
You can take a look at this one here: https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Tips-&-Tricks/Macro-for-updating-values
Will give it a look, thank you!
Amazing, thank you. Had no clue I could just throw some new ${}$ within the formula. That is great knowledge to know, thank you
Sorry I confused this situation
This looks like an alternative to get/setProperty which works fine for my needs. I'm not enttirely sure how to extrapolate this to Dynamic Tables, but I'll try to look around and see. If it's too much special coding I may have to forgo it.
I appreciate the help but this topic may be beyond me if I can't do it with functions
Is there a way to nest conditions? Like, make it so that anyone who's got the "Unconscious" condition is automatically "Prone" as well?
This would require your own world script
That's kinda what I thought. Thanks!
Would it be possible to use an item value on the visibility formula of a label on an item container?
I have created an equippable item. From the template the item has a checkbox "CanMakeStunDamage".
Then I have placed this item on an item container on an actor sheet. This works a intended.
Now I have added a column on this item container with a new label. This label has a roll formula for making stun damage. But I would like to see this label only if the "CanMakeStunDamage" is checked on the item. So I have added item.CanMakeStunDamage on the visibility formula of the label but that doesn't seem to work.
Does anyone know if Monk's enhanced journal is compatible with CSB in regard of the currencies? I can't make money work whit this modules. I did the same settings as for Item Pile but it does not work.
Tried this some month ago and was also not able to make it work with CSB.
Ok thanks, at least it's not a missuse from me
What did you try with item piles?
Your item piles now work perfect for me, thank you very much. 🫶
Set the item-price-attribute to “system.props.gmptown” and the currencies to “system.props.gold” / silver / cupper and so on.
Yes item pile works very good, amazing. I think monk's enhanced journal is just not compatible with CSB.
Cool you just said it didn't work so I was curious
Hello friends! I'm learning how to use the Custom System Builder. I would like to know if it is possible, perhaps with a little javascript knowledge, to make the Custom System Builder understand the card sheets, from the Foundry deck function, as equippableItemTemplate. So you can add them to item containers and return to the deck or hand. Is this possible, very difficult or completely crazy?
CSB has not touched the card-system at all, so you´re completely blind there.
I feared that. But thanks
I got /sheetRoll and actor.roll to work with Dynamic Tables. Before I spend too much time figuring it out, is /sheetRoll and/or the .roll() function usable on items attached to a character sheet? I didn't see any documentaton to imply item.roll() would work.
roll() is performed from the template-system, which is present in both actor and item. Just do item.templateSystem.roll()
Great, thanks. I am not familiar with the template-system but I'll look up some thing if I know it can be done!
I have an item with a dynamic table. Then I have inserted this item on an item container on an actor sheet. The item container has a roll label to open an user input template. How can I fill a dropdown list on the user imput template with the values of the dynamic table from the item?
As an example:
I have an item "Dagger". I can use this item with different attributes: "Dexterity" or "Strength". The item template has a dynamic table to add the usable attributes to the weapon. So I have added "Dexterity" and "Strength" to the "Dagger".
Then I have added the "Dagger" to an item container on the actor sheet. The item container has a roll label to perform an attack. If I open the "Attack" user input template I would like to give the player the choice to select "Dexterity" or "Strength", as added to the "Dagger".
item.dynamicTableKey
Thanks for your answer. I have tried to use "item." on the user input template but it looks like I have no access to the item data. The dropdown list on the user input template will be empty.
Question: I am creating a race and wanted to push that to the character sheet. How would that be accomplished?
What is the best way to implament this?
Currently, I have a manual entry on the character sheet that tracks the stat mods for Race. My goal is either 1, to remove that table all together and insert just a container with the race in it or 2 leave the table and push the race stats to that table.
I would love to lean towards the first since I feel like its less it has to calculate but either would accomplish what I need.
Once the first is created, I am sure its similar for other things like weapons
meh...
LOL meh, that answer says it all
The Example Template has an Item Template for Races
Cool, I will reload it then and take a look
OK pulled the example template but not seeing how it interacts with the sheet
The item container race doesnt reference anything
The magic happens in the Item Template Modifiers. All these modify the stats of the character sheet when it´s dropped. This is the behavior you usually want to have
So if I understand correctly, we have a field that these get pushed to, in this case, the base stats will add the modifiers to create a final result
field/fields
So is the original sheet referencing the item(race) fields is that how it works?
It's vice versa, the Item is actively manipulating the values in the character sheet.
OK, how is that done
BTW there isnt a race template in the example sheet, only the container.
Sheet Lib that is
Huh, do you have any Item Templates?
I have several item templates
Lets use this as an example because it comes directly from the sheet-lib
So I convert this armor template to a item, so now I have all the fields here ready to edit and drop into a container in my sheet.
Once this has been converted to an item and dropped onto the sheet. How does Armor Protection Standard get added to my value on the sheet itself?
Take a look at the modifiers in the template
OK so a direct reference to the item sheet by using the name IE
${item.Armor_Protection_Standard}$
correct?
Ok, yeah. That is the Item Container. That can show Item-stats without any issues
You can use item.itemKey in this case.
Just validating before I start making things and then find out they dont work lol
gotcha
so just a direct reference using the item.itemKey
if its in a dynamic table can I still reference the table?
Yeah, that does only work within the Container
ok let me play with it, I may have additional questions as I start adding on.
I feel fairly confident in what I have created so far inside the sheet but items are a different story.
You can take the Inventory Template as a starter
I would like to be able to at some point use an item to insert fields into a dynamic table.. but I think that will be in the future.
This will require a combination of Item Modifiers, fetchFromActor() and getRefFromDynamicTable()
Hey all. Question: I might have misunderstood but I think I remember someone trying to do a similar thing a while back. I am trying to make a ‘GM overview sheet’ that pulls all important info from the player sheets into one place. I have never used dynamic tables or the ‘fetchFrom’ function before. I need to know what goes in place of ‘Kiki’ here in order to pull the individual stats from all players. I think it’s something to do with ‘same row’(?) but I don’t know the correct syntax here.
fetchFromActor(sameRow('player_name'), 'pc_cou')
FABULOUS!! Second question, this sheet doesn't update in real time or upon refresh, it only updates its info when I go into its template, pick a random component, hit its save button, and then hit the refresh button in the sheet. What am I missing here?
So how do i set up the roll label so that the labels on the side (Power, Speed, Range, Durability, Precision, and Learning) would roll a formula depending on selection option on their respective dropdown menus on the right?
Hi, text formatting question: in a labels "Label roll message" I want to add an end-line / line break, but I can not for the life of me remember how to do so.
If you're talking about a line break in your text prompt that shows up when you roll I believe its <br>
Thanks! That is exactly what I was looking for.
${[:dropdownKey:]}$ if dropdownKey is already a valid Roll Formula. If not, you have to construct the Roll Formula with switchCase() before.
Normally it updates if you change any input field within the character sheet.
so how do i do that for multiple dropsown options?
Hello ! Is there is an option in CSB to change the name and icons of active effects ? And if there is, how to do so ? If the option is not available within the module is there an alternative way ?
Okay i got it working with this madness ${switchCase(powerdropdown, 'standpower_a', [3d6], 'standpower_b', [3d6k2], 'standpower_c', [2d6], 'standpower_d', [2d6k1], 'standpower_e', [1d6])}$ It just it rolls with all 5 formulas instead of 1 of them.
at the very least the result shown on the side will correspond to the selected dropdown option
${#roll_formula:= switchCase(powerdropdown, 'standpower_a', '3d6', 'standpower_b', '3d6k2', ...)}$
${[:roll_formula:]}$
I'll try to remember to report this on the git when I get home, if it's an actual bug, but I figured I'd post it here in the meantime:
Pressing Enter while a User Input Form is open will submit that form, but it's not submitting the currently selected text field. Ex. If a user input form has two number fields, and you click on field1 and fill in "5" then click on field2 and fill in "10" then hit the enter key, the form will submit field1 as "5" but will submit the default value for field2 instead of "10".
Ehh... Well, it´s kinda a bug but also not. For more context:
Actors and Items are updated when you change a value and remove the focus of an Input Component. The reason why we also need a focus-change is because every update is compute-intensive (because the Actor / Item recalculates every Formula). If we remove the part with the focus-change, every key-stroke would perform an update, in which you cannot change values in the meantime. That would lead to horrible UX.
Gotcha, that makes perfect sense. Maybe it's less of a bug report and more of a feature request then? Since they're submittable forms and they usually aren't going to be as chunky as, like, a character sheet, it might be nice to have a little update check prior to submitting the form on the enter press. A small thing for sure, but just something I ran into.
It´s technically a bug, so it should be submitted as such. But I´m not sure if we can fix this easily (at least for the User Input Template).
Alright, I'll submit it as a bug just so it's documented. Thanks!
Hey guys,
I´ve updated the Wiki of CSB. These are the changes:
- 1.1. Predefined values [NEW]
- 3.1.2 Variables [NEW]
- 3.1.8 Additional Syntax-Rules in Label Roll Messages [NEW]
- 3.3.4. Calling macros [UPDATE]: Added additional example with a more-complex scenario.
https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Guides/Formula-System
I´ve also included the Script of the additional example in a new page of the Wiki: https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Tips-&-Tricks/Script-to-call-macro-from-compendium
is the quotations around the dice stuff necassary?
Yeah, you have to mark it as a String, otherwise you´ll get a Syntax Error.
I cant seem to get the item stats to appear on the sheet. Here is what I got, what am I missing?
item has the following
_BaseRaceTemplate
base_mod_table
base_stat
base_race
this is used to call the above container - on the sheet ${fetchFromActor('attached', "getRefFromDynamicTable('base_mod_table', 'base_stat', 'base_race', 'fetchFromDynamicTable('base_mod_table', 'base_stat')')")}$
So the fetch should pull from the attached item from that table. Am I correct or do I need to replace attached with the location of the actual?
my guess is I am missing the pointer to the actual item
- These are not Item Modifiers, these are just normal Item props.
- As soon as you go out of the Scope of an Item Container, you either have to use Item Modifiers or a Script to get information from an Item.
fetchFromActor('attached', ...)can only be called within an Item.
So if I take the stats and convert them to item modifers then I could use this to adjust?
You can leave these stats as they are and reference them in your modifiers.
OK so use the item modifer as a helper cell .. That I can do
How would I call it on the sheet after its attached?
You don't
The Item handles the stat-changes on the character sheet
OK, then I assume I need to tie the modifer to the stat it increases... I think I get it
Key is the key on the sheet that changes, formula is what I can use to pull the change?
The structure of your item modifier would look like this:
{
"Priority": 0,
"Key": "${fetchFromActor('attached', "getRefFromDynamicTable('dynamicTable', 'targetColumn', 'filterColumn', 'filterValue')", 0)}$",
"Operator": "=",
"ValueFormula": "${modifier}$"
}
ValueFormula": "${modifier}$" = this would be what changes on the sheet right
Example ${STR}$ etc
Key is where the value is located on the item
how do i make it so this formula ${[:brawnsmod:d6]+[:roll_formula:]}$ only applies the roll formula on the right if a checkboxed is, well, checked?
I promise I am not dumb, but this is causing my head to break lol
if statement
checkboxes are either true or false
When constructing the roll_formula, you can concat the other part conditionally by using concat() and the ternary-operator.
i do know conditions are a thing, would it be easier to use that? <condition> ? <value if true> : <value if false>
That is the ternary-operator
${ checkboxKey ? [:brawnsmod:d6]+[:roll_formula:] : [:roll_formula:] }$
something like that
Don't do that
Oh?
first of all, the brawnsmod one is the one i want to go through regardless of if checked or not.
care to explain?
LOL I was just trying to give you an example
so what does concat() do in thsi scenario?
It concatenates strings together:
concat('Hello', ' ', 'World') returns 'Hello World'.
OK I think I understand what Martin is saying,
concat() will combine both the [:brawnsmod:d6]+[:roll_formula:] together in 1 roll vs trying to combine them with a +
the eval assuming would be done before the roll happens right?
Wouldnt the eval still be if and statment tho?
${ checkboxKey ? concat([:brawnsmod:d6]+[:roll_formula:]) : [:brawnsmod:d6]}$
Something like that? I am guessing without playing around with it tho
Still bad. You have executing actions [] in a conditional (see common pitfall for conditionals).
so you have to put the conditional in the concat? or the conditional outside of the concat? because this is obviosuly conditional type of thing.
What should be done instead:
${#roll_formula:= checkbox ? concat('+', switchCase(powerdropdown, 'standpower_a', '3d6', 'standpower_b', '3d6k2', ...)), ''}$
${[:brawnsmod:d6:roll_formula:]}$
The issue is that this concat() is within a conditional, so the rule still takes effect.
whats with the empty quotes at the end?
part of the concat
The false-part of the ternary. It is mandatory to provide both parts
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.
okay, how do i put a switchcase in this?
Why a switchCase()?
cuz i used the switch case for a roll formula earlier (the one with the power dropdown.
it just durability instead of power.
due to the checkbox is supposed to check if this applies or not. #1037072885044477962 message
yes
so where do i put the checkbox key, where it says checkbox or the question mark?
Checkbox
k, because i asked and i didn't roll any more die despite the checkbox being on.
Fixed
so for the last thing on the last do i put the comma after the last string or not. I'll assume not but want to be sure.
Nope
so i don't put the last comma there?
@formal goblet also now the die can't roll for whatever reason
Yeah
Check the console
here's the error i got.
if it helps, here's the defualt label roll message. ${#roll_formula:= stand_checkbox ? concat('+', switchCase(durabilitydropdown, 'standdurability_a', '3d6', 'standdurability_b', '3d6k2', 'standdurability_c', '2d6', 'standdurability_d', '2d6k1', 'standdurability_e', '1d6')), ''}$ ${[:brawnsmod:d6:roll_formula:]}$
Do not use linebreaks in Formulas
i didn't put line breaks in there, the dropdown values are just that long.
I see a \n in the Formula, that is a line-break
something like this? ${#roll_formula:= stand_checkbox ? concat('+', switchCase(durabilitydropdown, 'standdurability_a','3d6','standdurability_b','3d6k2','standdurability_c','2d6','standdurability_d','2d6k1','standdurability_e','1d6')),''}$ ${[:brawnsmod:d6:roll_formula:]}$
becauase if i did the above i jsut get the original dice again.
Yeah. You can use White-Spaces if you want, that is not an issue. Line-breaks are meh.
i did the above and it just gives me the original set of dice without adding the dropdown dice like i wanted.
Try out ${stand_checkbox}$ and see if you get something.
how do i add it to the above madness?
Just a separate Formula
Hey Martin, I am still confused.
You said earlier that the key on the item modifier was the key reference for the actor so in this case on the actor I have a test cell called ${testtest}$, then the value is what changes add or = so in this case it was I just did a direct override to 15 to see if it would adjust to the actor sheet. I am not seeing the change.
okay, how?
Remove ${}$ if the key is testtest
ok let me try that
${roll_formula:= ...}$
${[...]}$
${stand_checkbox}$
so what does ${stand_checkbox}$ do in this scenario. I feel like this might feel a tad too stripped down for me to get the point.
Returns the current value of stand_checkbox
okay, but how does that factor in to what i'm trying to do?
A simple check if the specified variable returns a value
Awesome thanks, that produced results, now to figure out the rest 🙂
okay, so do i add the checkbox formula to the above stuff with the concat or not?
Last question for the evening, I noticed that modifiers on a templete doesnt follow the items created from them
No, just add it at the beginning or the end of the Label Roll Message and check the result.
You don't see them in the Item, but they still apply
Nope
That wasn't a question 😅
LOL
and this is useful how?
Send me a screenshot of the Message created with the checkbox selected
Let me try then because that makes things funky
OK works like it should
Thanks Martin, I am headed to bed and will get stuff fixed tomorrow
This screenshot is the formula as of now with the stand checbox on, but it can't make it produce a message. Still not sure what the point of that was.
even ad a +a before the roll formula and it didn't help
here's the screenshot with the stand checkbox thing in but without the roll formula. and yes, it is true.
Remove the #-sign from the roll_formula
got something, in this case an error next to true.
Put the formula of the roll_formula in a Label_prefix without roll_formula:= . We use that for testing-purpouses.
so just ${stand_checkbox ? concat('+', switchCase(durabilitydropdown, 'standdurability_a','3d6','standdurability_b','3d6k2','standdurability_c','2d6','standdurability_d','2d6k1','standdurability_e','1d6')),''}$
and do i keep the og formula still in?\
Yep. If error, remove the switchCase-part and test again
Just this part is enough
well, it just reads as "ERRORHealth" now but in the template it lists the full formula as a prefix?
Normal. Every formula in the template will be fully displayed
Now this
okay, but in the char sheet it lists as "ERRORHealth" as show here.
so do i reput in the roll_formula:= or not?
No, remove the part with the switchCase()
does that include what's inside the switch case?
You cannot use := outside of Label Roll Messages
Yeah
soemthing like this ${stand_checkbox ? concat('+',),''}$
Without the comma after the plus
char sheet health button still reads as "ERRORHealth".
i wonder if tis the questio nmark that sthe issue here?
Replace the last comma with : ...
like this? ${stand_checkbox ? concat('+'): ...''}$
Without the 3 dots
it now reads as "+Health" so we might be getting somewhere.
Yeah, you can put the switchCase-part back in it...
so this? ${stand_checkbox ? concat('+', switchCase(durabilitydropdown, 'standdurability_a','3d6','standdurability_b','3d6k2','standdurability_c','2d6','standdurability_d','2d6k1','standdurability_e','1d6')):''}$
@formal goblet It reads as "+2d6Health" (2d6 being 'standdurability_c' option selected).
Purrfect, now Copy-Pasta
so this? ${roll_formula:= stand_checkbox ? concat('+', switchCase(durabilitydropdown, 'standdurability_a','3d6','standdurability_b','3d6k2','standdurability_c','2d6','standdurability_d','2d6k1','standdurability_e','1d6')):''}$ itno the label roll message?
@formal goblet i do be rolling 5 die rather then 4 so far (oddly it displays "+2d6" seperate from the roll itself shown here, which is weird but at least its not error).
its at bottom right.
Just add # again to hide it
worked as a chrm, i suppose we don't need "${stand_checkbox}$" no more.
Nope, only testing
I'd advice to go through the Wiki & Readme to gain some knowledge
Does anyone have a basic system with stats and hp implemented, i am trying to make the system Class 1-c using this module, and I work better tweaking existing material compared to building stuff from the ground up. Thanks in advance! 😊
Odd Question: If I have an Item which contains a select dropdown that the user can make a selection from on the item (key: effect_select), should I be able to reference the selected value in that dropdown using a ${ }$ expression elsewhere in the item?
I was trying to have some content display somewhere else on the item based upon what was selected in the dropdown using the ternary operator
${(effect_select=="value to check")?"Display A":"Display B"}$
However I get ERROR where the content should appear on the item.
I feel a little stupid. I have referenced the FAQ before but assumed this was such a weird niche question. My fault and thank you!!
Worked perfectly!
How can I fill a user input Dropdown with values from an array?
Something like this:
${#MyWeapons:=fetchFromDynamicTable('MyMeleeWeapons', 'MyWeaponsName')}$
${#?{SelectedWeapon:'Attack with:'|MyWeapons}}$
So instead of a text field with "Dagger,Sword" I would like to have a dropdown with both options.
Does anyone know of a simple "If item is attached" formula I can use for a visibility formula? Nothing I'm trying is working. I just want a label to be invisible unless the item is in someone's inventory.
Hello, for some reason I can't get status effects to work right. I have a label containing a number and referenced the key of the label in the active effect modifier (which simply adds another number to the value in the label). But whenever I activate/deactivate the status effect on the token nothing changes in the character sheet. Reloading the character sheet didn't fix it. Does anyone know what I did wrong?
Does it look simple, like this?
Make sure you don't have anything written in the Group section, otherwise you'll need to have it checked off in a Conditional Modifier List
this looks exactly like what I did
Make sure the label contains a number and nothing else, not even spaces. Maybe try making the label default to ${0}$ instead of just 0 as well, if it's just a straight number.
These are things that I had to do when I was messing with condition modifiers.
If that doesn't work, try posting a screenshot of your label's info page for when a dev gets here. I'm not exactly an expert, I'm just throwing out ideas because I messed with these recently lol
👀
Make sure that it is a prototype token. Otherwise the effect will never be displayed on the sheet.
how do I check if a token is a prototype token?
Only via item modifier, i think.
Double left-click the token (to open the token actor sheet)
What do you mean by item modifier?
Just to be clear with what I'm trying to do: I have a label on an item sheet that I want to be invisible unless the item is currently attached to a character.
This was my latest attempt, but it's resulting in the label always being visible: switchCase(fetchFromActor('attached', "lblStr"), '1', 'true', 'false')
Ah, I understood it vice versa.
Is the formula working if you place it in a label text?
Non-empty strings are always truthy 😅
Hmm... I just tried switchCase(fetchFromActor('attached', "lblStr"), '1', 'true', '') and it didn't work either. It looks like, if the fetch returns an error due to lack of actor, it's just always ending up visible. Is there any way to, like, catch the error? Sort of ike the Excel isError() function?
fetchFromActor() accepts a default-value 😅
I think I have the default value in that one I posted set to '' as an empty string and it wasn't working.
I figured out a work around though! I changed the conditions to switchCase(lblAttached, 'ERROR', '', 'true') and created a label called lblAttached that is ${!fetchFromActor('attached', "lblStr")}$
That was the default-value of switchCase(), not fetchFromActor()
OHHH! You are completely correct, thank you!
Okay, having issues with that now...
fetchFromActor('attached', "lblStr", false) isn't working. I've also tried replacing the false with 'false', "", and '' and none are hiding the label...
Ah, fetchFromActor() is bugged in visibility formula 😭 . I´ve fixed it for the next version
Damn. Okay, back to the work around it is! Thank you!
Unrelated question, while I'm here: Performance-wise, would it speed up the recalculating time on a sheet if I turned some of my labels into Hidden Attributes? I am guessing not, but I do have some labels that are doing nothing but acting as global variables for the sheet, so I figured I'd ask.
Not really, especially if they do not contain derived data.
The system has multiple calculation steps, in which the values of the Components are calculated. What the system does is:
- Calculate the values of Components iterative. If a value couldn´t be calculated (because it depends on a Component, which wasn´t calculated yet), save it into
uncomputedPropsand retry in the next cycle. - If the current cycle didn´t calculate anything (because
uncomputedPropsdidn´t change), stop and log alluncomputedProps
Yeah, that was my assumption but I figured I'd check. I just didn't know how much of the recalculating time was actually, like, re-rendering? So I figured that there was a very small chance that making those variables invisible, or hidden attributes, might do something.
Another help question, if anyone doesn't mind:
I have a clickable label on some items called lblItemStrAtk that does some roles and adds to them and posts the to chat. Pretty basic. I want to create a column on an item container that contains a clickable label that triggers item.lblItemStrAtk when clicked. Am I missing a way to do this?
Try %{linkedEntity.templateSystem.roll(rollKey);}%
And the console?
%{linkedEntity.templateSystem.roll('lblItemStrAtk');}%
Just in case I messed that part up, lol
No, it´s just a bit trickier than I thought
Thanks for helping look into it! Let me know if it turns out to be possible, haha!
Question, I have been able to add items and adjust fields using the modifier but when I unequip or remove said items the modifiers stay. How do I fix that
I sorta made some progress? The following code in a label will do exactly what it did before, posting "undefined" to the chat, but then it will do what I wanted to do and effectively click the label:
'lblItemStrAtk',
{postMessage: false}
);
let speakerData = ChatMessage.getSpeaker({
actor: entity,
token: entity,
scene: game.scenes.current
});
rollMessage.postMessage({speaker: speakerData});}%```
Yeah, the Label Roll Message will create a Message on its own. You can suppress that by throwing an Error at the end.
There will be an alternative with the next update.
How would I force throw an error in that?
throw 'Done';
Awesome! Well, that works as a workaround, for now, haha! Thank you!
The current dev-branch has that already if you really want to.
I think I'm good for now. I mostly use CSB for fun, casual stuff so it's not a big deal. One of my goals for the whole day was to be able to add the clickable labels on an equipped item to my hotbar. Like, each weapon has an "attack with this weapon" button and you can't add it to your hotbar normally with the right-click options that CSB has(it creates a macro assuming the button is on a character sheet instead, so it doesn't end up working).
I ended up just going with:
let weaponName = "Dagger";
let rollMessage = await actor.items.getName(weaponName).templateSystem.roll(
'attackRoll',
{ postMessage: false}
);
let speakerData = ChatMessage.getSpeaker({
actor: actor,
token: actor.getActiveTokens()?.[0]?.document,
scene: game.scenes.current
});
rollMessage.postMessage({speaker: speakerData});
and I'll just have to swap out the weaponName for each macro I make.
Anyone know how i can drop the decimal point value off a formula ? basically if its 1.2 i just want it to return 1.
I think that you can use "floor(value, 0) " replaceing value with your variable.
Ok, so something like this ?
${floor((Armor_Durability / Max_Armor_Durability) * 100 ,0)}$
works beautifully. Thank you my friend!
Question, any suggestions for a formula to calculate the distance between the selected token and the targeted token? I am trying to auto-calculate the range for a weapon attack to apply the correct range modifier automatically.
Does someone know how I can check if an active effect is active on a token? All I can return is the activeEffect list but can't find a way to test if one is active or not.
I don't think this is a CSB related thing, but this works for me:
if (actor.appliedEffects.find((element) => element.name == effectName) != undefined)
return true;
return false;
}```
function hasEffect(effectName) {
return !!actor.appliedEffects.find(effect => effect.name === effectName);
}
Oh, I did not know you could do that with an undefined error. Listen to the person who actually uses JS, @lyric swan! You get cleaner code, lol!
undefined is not an error, it's an actual value 😅
And I continue to not know what I'm talking about lol.
Apparently, I have an invisible label prop on one of my template sheets. I only found out because it happens to be throwing an error to the console whenever I reload that sheet. Do you know of a way to deal with it? I know the key for it.
It's a bug I've had happen more than once with Tables. Sometimes, if you drag things too fast between the spaces, they'll disappear into the ether until you delete the table.
Export, edit the json and import back
Will do, thanks
Thanks guys 
Bug or Feature?
I have created my own version of dropping items onto other items (ie item qualities and item attachments). I have found that, via JS, I can directly alter a keyed label (only tried with static values in a dynamic table). Is this intentional or a coincidental bonus. I ask because if this is unintentional, I will take a different tact in case this "feature" is written out in the future.
Unintentional. You'll lose the changes if you reload the sheet.
this is via item.update so I am affecting the json. it is persistent
I found it when I was using JS to update a text field. I changed the text field to a label, and quite by accident, found the code still affected the label as it did the textbox. The change was permanent across system reloads.
Looks like the visibility formulare of a column label on an item container don't work with item values:
item.WeaponRange>0 hides the label of every item on the list, even if the items WeaponRange is greater than 0.
Thats the its currently written to work. I think it will be updated when the next update rolls out (no eta). You will need to use a tertiary operator to hide and show values individually.
Is there a way to fetch the modifier value and apply it to a roll to hit roll in an item container?
Like if I roll let's say a hammer and that roll to hit is a 1d20. How do I have that roll add in my strength modifier?
So, the way I do it (and there may be better ways) is that I create a column in the Item Container for the roll. From there you can access the item values with item.<key> and your sheet elements normally. So if you have your stregth bonus in a number component with a key of str, and your hammer item has a hit roll text component with a key of hit, you can use ${[:item.hitRoll:+:str:]}$ in the Label roll message of a label component in the item container on the character sheet.
Can you show me?
You can dm me the screenshots as well, if you don't want to share here.
So if the hit component has the value 1D20, and the str component has the value 3, it would roll 1D20+3.
Hammer item example.
Roll component in the item container.
Ok, just another question for you because I think I am confusing myself. When you put that roll component in the iterm container and have it to str won't all other weapons then target the strength modifier?
How would I have different weapons use different modifiers?
Yes, the way I have it codded that is correct.
You can add another component to the Hammer that specifies the key of the modifier to use. Then add a conditional to the Roll formula in the item container to select the corresponding modifier key.
Here is an example
I see
And then that modifier calls back to the modifier in the sheet
Ok that makes so much sense
Thank you man
Sorry, another question for you because I am now trying to get this figured out.
You ref(mod) is targetting the modifiers within the sheet?
Yes, the Ref(mod) tells it to use the component key on the character sheet that matches the value in mod.
Without the Ref() function it would use the value in mod instead.
So I have this at the moment but its giving me an error every single time.
Got it
So sorry
I just saw the damn )
My co-dm added that when I was fucking with it thinking he fixed the formula.
Ok, cool, is it working now then?
Hehe, yeah that's how it goes.
One thing I do, is duplicate the sheet for versioning each time I get a new function / aspect to work.
@hardy smelt Hey man another question for you. Would you possibly have a way in your system already for ammo subtraction?
If so is there a way to have like each ranged weapon subtract a different amount from the ammuntion section?
Any idea why this keeps pasting the whole formula into chat, not just the part I need (how do I remove the red parts from showing up in chat)?
<div class="chat-trait"> ${#concat( ?{effect:'Chosen effect'|string(item.power_basic_name1)|string(item.power_basic_name2)|string(item.power_basic_name3)|string(item.power_basic_name4)|string(item.power_basic_name5)}, )}$</div> <div class="chat-powerdesc1"><br>Chosen effect: ${!effect}$</div> <div class="chat-powerdesc2"><br>${effect}$ == string(item.power_basic_name1) ? ${!item.power_basic_name1_desc}$ : ""</div>
Unmarked parts are plain text
Is there a way to subtract within an item container? I am trying to go off the example in the wiki, but it seems to not be working.
😅
Yup. That is the example I am trying to go off and I can't seem to get it to work :)
I am trying to subtract the uses after each time a player rolls to hit a body part.
Ok but it seems the if formula doesn't work at all it's just getting the reference and pasting it, not checking the actual 'effect' value.
If I put the whole if statement into a ${}$ nothing happens.
Can't see mto substract from there no matter what I do.
${#setPropertyInEntity('item', 'item.abil_uses', "item.abil_uses' - 1")}$
This is the formula I'm using for reference.
?
Figured it out. Thx
Still doesn't seem to substract the uses value.
${#mod:=item.abil_mod}$
<table>
<th><h3>Roll to Hit with</h3></th>
<th><h3>${item.name}$</h3></th>
<tr>
<td><h3>Roll to Hit Head</h3></td>
<td><h3>${Damage_Roll:= ([:item.abil_head:+:ref(mod):-5])}$</h3></td>
${#setPropertyInEntity('item', 'item.abil_uses', 'item.abil_uses - 1')}$
Here is the whole roll formula.
And the console?
Console is blank
Here is the fomula that I use in one of my sheets: ${setPropertyInEntity('self', sameRowRef('w_ammo_rem'), "sameRow('w_ammo_rem')-1")}$
And this is all in your item container?
Oops, sorry, that one is from a dynamic table, just a sec.
Here is the one from an item container: ${#setPropertyInEntity('item', 'wpn_remaining', "item.wpn_remaining-1")}$
Make sure you do not have any extra spaces, and are using the correct punctuation marks.
Is there a way to have the subtraction occur for let's say another item container?
Like when a bow is fired it targets the quiver item container and subtracts one arrow from the quantity?
So I can target only one item within the container.
You need a Script for that. You can alter this one here: https://gitlab.com/custom-system-builder/custom-system-builder/-/wikis/Tips-&-Tricks/Script-to-update-multiple-items
Where would I be placing the script once its made? Just for my own reference.
Hi guys, I'm trying to apply an effect to a token with a macro but I can't find a way to make it work, any clues?
I got this :
if (canvas.tokens.controlled.length === 0) {
ui.notifications.warn("Select a token !");
} else {
let token = canvas.tokens.controlled[0];
let actor = token.actor;
let effectData = {
label: "Invisible",
icon: "icons/svg/invisible.svg", // Remplacez par l'icône de votre choix
duration: { turns: 5, startRound: game.combat ? game.combat.round : 0 }, // Durée de l'effet
};
actor.createEmbeddedDocuments("ActiveEffect", [effectData]);
}
But this does not apply any effect modifier or other expected effect (like make the token transparent is the case of invisibility)
Okay, I got this to work last night and erased it, and I can't for the life of me figure out what I'm doing wrong wrong this time!
${fetchFromDynamicTable(fetchFromActor('attached', "tableLevelFeats"), 'txtFeatName')}$
This is in a DropdownList "dropdown options origin" on an item. I'm trying to get it to be a dropdown list of all txtFeatName values in tableLevelfeats
Switch to dynamic table options and use the parent.-prefix
THANK YOU! I was messing around with this last night and got it to work, but I couldn't remember what I did, lol.
Second question: I have an item containter in a dynamic table on a character. I want that table to filter out items by: If txtBagName on the item is the same as txtTableBagName in the same row of the dynamic table as the item container.
I thought that I could just add txtBagName is sameRow('txtTableBagName') to the filter list, but it's not working as I'd hoped...
Dynamic Tables and Item Containers do not work together
Damn. Yeah, I thought I remembered them not even being addable to dynamic tables when I was using CSB like a year ago, but it does let you add them now. Thanks, though!
I have a sheet with a item container for race, which has modifiers that update character attributes (works). I have an item container with skill items that use these attributes for internal calculations (works). These calculation results are displayed in the item container columns. If the race is dropped after skills (assumed PC creation flow), the skills columns dont update without a forced refresh. The same happens if race is deleted. This is a rebuild and this worked as desired before. Any suggestions?
Errors might interrupt further calculations, so look out for them in the console. I´d assert that your calculations are dependent on the modifiers of the race and cannot work without resulting in errors.
Ok. No errors. It seems that there is an update lag. I created a second race item with different stats. If I add race 1 (force update) and delete it, the skills dont update. When I add race 2, there is an update but its the "no race" values. When I delete race 2, then race 2's values appear.
Ok, that is indeed a typical update-anomaly. This one is harder to debug.
Great. So no suggestions on what to consider?
You have to understand the entire data-flow to take measures against it...
ok. thanks
Up? 🥺
Sry, no knowledge about active effects
ok thanks anyway, if I find how, i'll post it
Ok I figured it out :
// Apply an active effect to every selected token
// This effect will trigger any effect modifiers as long as the ID matches the actual effect ID in the system
let selected = canvas.tokens.controlled;
if (selected.length === 0) ui.notifications.warn("Select at least one token !");
else {
selected.forEach(token => {
let effectData = {
name: "Dead", // Actual name of the effect (can be changed as long as the ID is the right one)
icon: "icons/svg/skull.svg", // Icon of the effect (can be changed as long as the ID is the right one)
duration: { seconds: 60 }, // Duration of the effect in second (delete this line for unlimited)
origin: token.document.uuid, // ID of the source (selected token in exemple)
sourceName: "effect source", // Name of the source
disabled: false, // Is the effect active or not
description: "This does that...", // Description of the effect
flags: { core: { statusId: "dead" } } // The actual ID of the active effect (IMPORTANT !)
};
token.actor.createEmbeddedDocuments("ActiveEffect", [effectData]);
});
}
If you want to, you can event use Visual Active Effect + Core Settings Expanded + Effect Macro and do some cool stuff with effects that trigger macro when effect start, end, turn start... like this :
activeEffect.forEach(effect => {
effect.setFlag('effectmacro', 'onCreate.script', 'console.log("Dead effect created");'); // Macro onCreate
effect.setFlag('effectmacro', 'onDelete.script', 'console.log("Dead effect deleted");'); // Macro onDelete
// etc...
});
Btw Monks little details allow you to add and customize active effects too.
I'm having a little trouble with attribute bars. For some reason it doesn't allow me to modify the bar's value via right clicking the token and typing in the box. It lets me highlight the attribute box, but not type anything. How do I fix this?
Delete the complex attribute bars you have created and let the system create the ones you need (You only need a Number Field with a defined max-value).
Good to know, thanks. I'll add this later to the Wiki if you have nothing against it.
So I can't create my own custom attribute bars that allow math in the text box on tokens?
Yeah, custom attribute bars are using derived values only, so these are not editable. The ones created by the system are editable because they use direct references to the Number Fields, which are editable by the player.