#Custom System Builder

1 messages · Page 40 of 1

sturdy mesa
#

I know it's possible to drag labels to the shortcut bar and execute them directly from the shortcut. However, I would like to know if it's possible to make the codes from a label execute automatically at the beginning of each turn in combat, for whoever's turn it is.

I've heard about world scripts and things like that, but I have no idea how to do it. Could someone give me some guidance?

tribal tapir
#

I am a bit of a javascript novice...👉👈

patent dust
#

Hi there! I'm really bad at writing label roll messages. Can anyone help me? I need to write a roll message to create a button. When the player push the button it shoud appear a new window asking to the player how many dice he wants to roll with a number of sides decide by the player. I have no clues 😦

formal goblet
plucky canyon
#

I've been looking at doing the same thing, and in macro-polo they pointed to the Requestor module which is basically a small piece of code for this very thing.

What I want to do is a bit more complex so I've put it on ice for the moment, but for your needs it should be fairly simple.
https://foundryvtt.com/packages/requestor

fallen coral
#

Is there a way for me to check the inner loops required to load an item? refreshing a character is taking too much time and I see a lot of loops to finish a process, sometimes 6 loops

#

I would like to structure it better to require less loops

formal goblet
fallen coral
#

It takes around 5 seconds to alter anything in a character sheet, and it gets worse the more items a character has

#

Don't give up on me

formal goblet
#

I can only explain, how the computation loops work...

  • The computation loop only applies to computable Components (Labels and Meters). All other values are computed when the Component is being rendered.
  • When the loop starts, there are no computed values (obviously), so all computed values start with undefined
  • The loop fetches a formula from the list and tries to compute it
  • If the formula contains a dependency to a value, that is undefined, the computation will be aborted and the next formula will be fetched
  • If the formula contains no undefined values, it will be computed and removed from the computation loop.
  • The loop iterates multiple times (best case: 1 time, worst case: x times where x is the maximum dependency depth of the formula with the biggest dependency depth overall)
fallen coral
#

Hm... would it make any difference if I duplicate (now) the fields that depend on other values? Like... does the order of creation have any impact on this?

formal goblet
#

I've never tested this, but according to the JS-Spec, the order is dependent on the browser

formal goblet
fallen coral
#

not sure I have the knowledge to understand this though. What bothers me is once an item is computed successfully, it tries to compute it again thus increasing the loading time

#

happens to every item more than once. I feel there is something I might be doing wrong

#

In total, happens 14 times to every single item

formal goblet
fallen coral
formal goblet
fallen coral
#

will try to disable all the modules and start from that

#

Nope, those 14 computing times are definitely my fault

formal goblet
#

Do you use setPropertyInEntity()?

fallen coral
#

having more than one item displayer could have cause ths?

fallen coral
#

not that much

formal goblet
fallen coral
#

The items have a single field they retrieve from the character

formal goblet
#

Updating a character causes 2 updates, updating an attached item causes 6 updates at my side

fallen coral
#

my console hides item update...

#

almost sure it is a character sheet problem

fallen coral
#

Also, each of these value fields checks if the item itself is added to the character, case not those values become 0

formal goblet
fallen coral
#

Right, I might be lacking some vocabulary to express myself due to undertand little to nothing coding-wise. In terms of adding computing loops or renewing a loop process (considering I'm getting 14) would having those 5 item modifiers cause any of those issues I mentioned considering those values depend on having that item not only added to the character but also in a separate dynamic table (which defines what is equipped and what is not equipped)?

formal goblet
#

I know most parts of CSB, but Foundry is still a big black box for me

fallen coral
#

Hm, but usually CSB regular behavior wouldn't check a modifier than compute than another modifier etc etc, would it?

formal goblet
fallen coral
formal goblet
fallen coral
fallen coral
#

Cause I'm getting almost non of those

#

Well... I forgot I sent the gif

#

Yeah, none exactly

#

Is there a way to use that await approach to define labels that depend on other fields?

formal goblet
#

No 😅

fallen coral
#

I have no idea how to deal with this 🤔

formal goblet
fallen coral
#

I'm trying to recreate the template isolating panels and reloading a character with that template. The problem, I'm guessing, is that while trying to avoid this exact problem in the future most (if not all) labels that depend on other fields have a fallback value determined by a ternary size/count > 0 ? label : ''

#

and once all the panels are in place, the problem which seems to be gone will return

#

🙄

fallen coral
#

I might have forgoten a hidden label that becomes hidden

formal goblet
#

Within an already going update

fallen coral
#

Even if it was pressed once and never again? The thing is, I have a questionary that becomes hidden and once a Finish button is pressed it passes all the answers to labels that are supposed to hold the values

#

6 fields in total, that are passed

formal goblet
formal goblet
#

No issue with that. Label Roll Messages are completely ignored in the loop

fallen coral
#

I recreated my template and the new character loads fine, then I duplicated my previous template and it loads fine. Maybe the token?

#

No... it depends on how many items the character has. More than two increases the loading time...

timid marten
#

Still looking for some help on this one, was my condition supposed to work?

formal goblet
timid marten
#

returns this

#

oh

#

it does the maths

#

lol

#

instead of showing 6/7

formal goblet
#

I think that is actually correct

timid marten
#

I want it to show 6/7 tho

#

also it doesn't detect weither the check is checked or not

formal goblet
#

But I also have to say, that multi-conditionals are not possible in the lookup()

#

But it's interesting, that it converts the 6/7 to a number. Haven't seen that

timid marten
#

where can I put this script ?

#

I would need it to update every second automatically tbh

formal goblet
timid marten
#

so in a label it's good?

formal goblet
#

y

fallen coral
#

Would a label roll trigger a computing loop before it is clicked?

formal goblet
fallen coral
#

Would this trigger then:
${#?#{Item_quantity_Popup}}$

<p><strong>Atualizou a quantidade do item ${sameRow('name')}$ em ${item_qtd_mod_value>0 ? concat('+',string(item_qtd_mod_value)) : (item.item_qtd + item_qtd_mod_value)<0 ? item.item_qtd : item_qtd_mod_value}$</strong></p>

%{
const itemName = '${sameRow('name')}$';
const item = entity.items.find(item => item.name === itemName);

if (item) { item.system.props.item_qtd = Math.max(0,Number(item.system.props.item_qtd) + Number(${item_qtd_mod_value}$));
await item.update({ 'system.props.item_qtd': item.system.props.item_qtd });
} else {
console.log('Item não encontrado');
}

return item?.system.props.item_qtd ?? '';
}%
restantes

formal goblet
#

item.update

fallen coral
#

even if it is a popup thing then

formal goblet
#

Update is update

fallen coral
#

right

formal goblet
#

If you want to perstist values, you can only do that via an update

fallen coral
#

Is there a way to prevent it to load if the item is not an ammunition?

formal goblet
#

Wdym with load?

fallen coral
#

like skip that code entirely?

#

sorry what

formal goblet
#

You could build in an early return

fallen coral
#

can you help me with that? I have a field called item_type and I can figure the equalText part. I would like to know how to create that early return

#

Wait 🤔 wouldn't it need to compute it anyway to check the item type?

formal goblet
fallen coral
#

Cause at least one loop for each item is being created from that label roll stored directly in the dynamic table

#

or am I mistaken?

formal goblet
#

Label Roll Messages are completely ignored in a normal update-loop. They only trigger when you actually perform a roll

formal goblet
fallen coral
#

So it isn't causing a loop when I refresh the character sheet

formal goblet
#

No, completely irrelevant when you not click it

fallen coral
#

Got it

#

Each item is computing loops 4 times it would be great to decrease it even further

formal goblet
#

So that the Actor is dependent on Items, but not vice versa

fallen coral
formal goblet
brittle moth
#

Soon™

silver lake
#
?{Sphere:'Spheres?'[number]|0}?
${setPropertyInEntity('self', (sameRow('ACO')), "sameRow('ACO') - Sphere")}$

sameRow('ACO') is connectedto a dropbox in the same dynamic table, that dropbox is connected to another dynamic table. Everything comes out correctly in chat, but it doesn't lower the value of the number field sameRow('ACO') represents. It even detects the value correctly.

formal goblet
silver lake
#

the value within the Dynamic Table the dropbox is referring to.

#

the value that is meant to be lowered

formal goblet
#

Give an example of that value

silver lake
#

20?

#

here

#

I'll show you the whole thing and a screenshot of how itcomes out. It's better than me trying to explain without understanding it well :P

formal goblet
#

That would mean, that you're trying to update the key 20

silver lake
#
${#concat(string(?{Act:'Actions?'[number]|(sameRow('ACost'))}), string(?{Roll:'ROLL'|'2d10',"Normal"|'3d10kh2',"Advantage"|'4d10kh2',"Domination"|'3d10kl2',"Disadvantage"|'4d10kl2',"Submission"}), string(?{method:'METHOD/DETRIMENT?'[number]|0}), (?{Sphere:'Spheres?'[number]|0}), (?{Energy:'Energy Spent ='|"CNothing","None"|"CStam","Stamina"|"CWill","Willpower"}))}$

Aspect: ${#Aspect:= ref(AspectLocked)}$ ${#AspectDice:= equalText(Energy, 'CNothing') ? 0 : 1}$ ${AD:= [:AspectDice:d:Aspect:]}$

${sameRow('ACN')}$
${(floor(([:Roll:]) + (((sameRow('ACS'))/10)*2))) + (floor(((ref(sameRow('ACCS')))/10)*2)) + (AD)}$
BEAT ► ${(sameRow('GT1GM')) - (Sphere*5) - (method*5)}$
${Energy}$ = ${setPropertyInEntity('self', Energy, "equalText(Energy, 'None') ? ref(Energy) : ref(Energy) - 1")}$
${sameRow('ACO')}$ - ${Sphere}$
${sameRow('ACO')}$ = ${setPropertyInEntity('self', (sameRow('ACO')), "sameRow('ACO') - Sphere")}$
Actions Used = ${Act}$
Actions Left = ${setPropertyInEntity('self', 'Actions', Actions - Act)}$
${CharName}$
${CharSurname}$
silver lake
formal goblet
#

Yep, the 2nd arg of setPropertyInEntity() expects a key/reference/path, not a numeric value

silver lake
#

to solve it

#

Maybe, I add a ref there somewhere?

#

I'll try that.

formal goblet
#

Your issue is, that setPropertyInEntity() knows, that it should update a value in the same actor, but not which value. You haven't specified that correctly.

#

The 2nd arg must be something like 'Dexterity', 'Speed' or 'Weapons.0.Damage'

silver lake
#

What could I write to specify that it should pull the value indicated on the key ACO

#

CSpheres is a number field

#

I don't know what ARG means, at least not in a programming context.

formal goblet
silver lake
#

Gotcha. So the second arg in this case would be "sameRow('ACO') - Sphere"?

#

And the first one would be the first sameRow('ACO')?

formal goblet
#

No, it must match your Component key and it must be a string

#

Because Component keys cannot be numbers

silver lake
#

So what you mean with 'Dexterity', for example, is adding fetchFromDynamicTable(OddityTable, CSpheres)?

formal goblet
#

setPropertyInEntity('self', 'Strength', 3) would update in the own Actor the key Strength with the value 3

silver lake
#

instead of pulling from the dropbox?

#

But how can I indicate sameRow('ACO') any more clearly?

#

Cause if I write "Spheres" there, it won't know what I'm talking about

formal goblet
#

sameRow() returns the value of the cell, but that's not what you need. You need a path/reference to that cell. And that's, where sameRowRef() comes into play.

silver lake
#

Oh, so I add a ref to the end of sameRow and problem fixed?

#

Ref, in the samerow, pulls a name refering to the Variable, then?

formal goblet
#

That's an entirely different function. Even one letter makes a huge difference

silver lake
#

I hope you understand that I know nothing of JS. I made this whole system with spit and gum, through sheer unga bunga determination.

#

So I thank you for your patience

#

You've always been pretty cool

#

Besides making the cool system

formal goblet
silver lake
#

Which is every once in a while when I have the time

#

and then I forget everything I learned

#

again

#

every time

#

it's hell

#

but I can't help it. I have some strange neurological issues.

#

Besides, when I have the time, I can either make the system and have it, or learn JS and not make the system. xD

#

And I used to program in C++ over a decade and a half ago, and I was young, and that made me develop a strong mental block for Programming. I really hate doing it, and respect who can.

#

Sadly, when I added Ref though, it still doesn't deduct the value. But let me try something.

formal goblet
#

The basic concepts you'll need are not JS-specific, every Object-oriented language in the basics would suffice

#

At least CSB tries to be friendly to non-programmers as well, but you'll hit a wall with more-complex scenarios.

silver lake
#

I understand. I just have a really hard time comprehending what some things mean. My brain processes things in a particular way, it's annoying. But eventually I'll just have to re-read it all and learn again, even if it fades.

#

So, there is this problem that I've ran into plenty of times before, but it seems to be also affecting the situation here

#

I added the Ref, and now what it does is it defaults the dropbox, and doesn't change the value.

#

And this problem is something I have with dropboxes connected to another dynamic table, where whenever the value of those variables changes in those dynamic tables (someone levels up a skill), the dropboxes in the abilities all have to be re-set.

#

cause they go blank again

#

I'm still in FoundryV11 btw.

#

Cause I fear that if I were to upgrade, I'd have to remake all of the systems again.

#

CSB 3.0.0

formal goblet
#

Are your dropdown option keys distinct from each other (that means that each option is unique)?

silver lake
#

The keys are a dynamic table

#

but yes

#

every entry is unique

#

the values sometimes end up the same, when someone has two skills on the same level, and that makes it so that the dropbox defaults to the first one in alphabetical order with the same level. So to fix that when two skills would have the same level we add a ".1" to the end of it, and so on.

formal goblet
silver lake
#

It's cause the value comes from the level

#

I don't know if there is any other way I could do that, since it is a dynamic table.

formal goblet
#

Dynamic Tables usually have a column with entries, which are unique at most times (like a name)

silver lake
#

But this one about lowering a value on another dynamic table doesn't have the same value as any other. The macro in question I mean.

silver lake
formal goblet
silver lake
#

I'm trying really hard to undertand that. I'll send you an example of what I think you mean based off of that macro I sent you before, where in the roll I use other values from dropdowns, specifically ACS

#
//${#concat(string(?{Act:'Actions?'[number]|(sameRow('ACost'))}), string(?{Roll:'ROLL'|'2d10',"Normal"|'3d10kh2',"Advantage"|'4d10kh2',"Domination"|'3d10kl2',"Disadvantage"|'4d10kl2',"Submission"}), string(?{method:'METHOD/DETRIMENT?'[number]|0}), (?{Sphere:'Spheres?'[number]|0}), (?{Energy:'Energy Spent ='|"CNothing","None"|"CStam","Stamina"|"CWill","Willpower"}))}$

//Aspect: ${#Aspect:= ref(AspectLocked)}$ ${#AspectDice:= equalText(Energy, 'CNothing') ? 0 : 1}$ ${AD:= [:AspectDice:d:Aspect:]}$

//${sameRow('ACN')}$
${(floor(([:Roll:]) + ((((first(fetchFromDynamicTable(sameRow('ACS')))))/10)*2))) + (floor(((ref(sameRow('ACCS')))/10)*2)) + (AD)}$
//BEAT ► ${(sameRow('GT1GM')) - (Sphere*5) - (method*5)}$
//${Energy}$ = ${setPropertyInEntity('self', Energy, "equalText(Energy, 'None') ? ref(Energy) : ref(Energy) - 1")}$
//${sameRow('ACO')}$ - ${Sphere}$
//${sameRow('ACO')}$ = ${setPropertyInEntity('self', (sameRow('ACO')), "sameRow('ACO') - Sphere")}$
//Actions Used = ${Act}$
//Actions Left = ${setPropertyInEntity('self', 'Actions', Actions - Act)}$

//${CharName}$
//${CharSurname}$
#

Like that?

#

wait, no

#
//${#concat(string(?{Act:'Actions?'[number]|(sameRow('ACost'))}), string(?{Roll:'ROLL'|'2d10',"Normal"|'3d10kh2',"Advantage"|'4d10kh2',"Domination"|'3d10kl2',"Disadvantage"|'4d10kl2',"Submission"}), string(?{method:'METHOD/DETRIMENT?'[number]|0}), (?{Sphere:'Spheres?'[number]|0}), (?{Energy:'Energy Spent ='|"CNothing","None"|"CStam","Stamina"|"CWill","Willpower"}))}$

//Aspect: ${#Aspect:= ref(AspectLocked)}$ ${#AspectDice:= equalText(Energy, 'CNothing') ? 0 : 1}$ ${AD:= [:AspectDice:d:Aspect:]}$

//${sameRow('ACN')}$
${(floor(([:Roll:]) + ((((first(fetchFromDynamicTable(sameRow('ACS'), CSpheres))))/10)*2))) + (floor(((ref(sameRow('ACCS')))/10)*2)) + (AD)}$
//BEAT ► ${(sameRow('GT1GM')) - (Sphere*5) - (method*5)}$
//${Energy}$ = ${setPropertyInEntity('self', Energy, "equalText(Energy, 'None') ? ref(Energy) : ref(Energy) - 1")}$
//${sameRow('ACO')}$ - ${Sphere}$
//${sameRow('ACO')}$ = ${setPropertyInEntity('self', (sameRow('ACO')), "sameRow('ACO') - Sphere")}$
//Actions Used = ${Act}$
//Actions Left = ${setPropertyInEntity('self', 'Actions', Actions - Act)}$

//${CharName}$
//${CharSurname}$
#

Man I'm really lost.

formal goblet
silver lake
#

Would that be the Dynamic Table I'm pulling from?

#

Or an Example Template you've made?

#

I don't know what you are referring to

formal goblet
#

A Template I've made

silver lake
#

sorry.

#

I don't think so?

#

Hey, can you give me a link to support you? I remember that I ran into a problem when I tried it first. I think I couldn't use my bank or something, but now I use paypal.

formal goblet
#

If you upgrade to a newer version, you'll even be able to download it as a module from the package manager

silver lake
#

It's cause that would take a very long time that I don't have between sessions.

formal goblet
silver lake
#

Exporting the current systems to the newer version, is that a big barrier?

#

Maybe after the new year's eve.

formal goblet
#

E.g.

  • Item Filters
  • fetchFromDynamicTable() -> lookup()
  • fetchFromDynamicTableRef() -> lookupRef()
silver lake
formal goblet
silver lake
#

Probably essential module-related

#

but I'll try again once the season's over.

silver lake
silver lake
#

Found your Kofi

silver lake
#

I'll look into it, thank you.

formal goblet
silver lake
#

okay okay

silver lake
#

but I take it it's for both of you.

formal goblet
#

I haven't set up anything and it goes to Linked alone

#

But I have no financial struggles anyway

silver lake
#

Well, still. Thank you Martin

formal goblet
#

Np

silver lake
#

I'm sure I'll eventually pop by to annoy you guys again while having forgotten everything I learned.
But then again, maybe not, this template could really save my ass actually.

formal goblet
#

Yep. Maybe I should also upload the work I've done with Shadowrun-6, because that one is insanely worked out (in german though). But that one might pose legal issues...

silver lake
#

Do most people use CSB to make already existing unsuported systems? Or is it just as common to make your own system, like me?

formal goblet
#

I think the Templates itself aren't the big issue. But the Items with full description from the rule books...

silver lake
#

I thousands of items and extra stuff from my world that I have written up in my articles, but I don't know if or when I'll get it all in the VTT.

silver lake
#

I'm having a difficult time figuring out how to apply:
${first(fetchFromDynamicTable('Attributes', 'Total', 'Attribute', Attribute_Selection))}$

to

${setPropertyInEntity('self', (sameRow('ACO')), "sameRow('ACO') - Sphere")}$

#

So that I can point the 'ACO' dropbox to a name rather than its value.

#

And make this change the value of the selected item from the dynamic table in the dropbox

silver lake
#

I'll be looking more at the template tomorrow to see if there is an example of this.

peak jacinth
#

is there a way to use switch statements inside panels, specifically? I want to make a simple panel that displays a number depending on the value of a specific number field. I know how to reference the number field, but I just don't know if there's a way to change what the panel shows depending on the referenced value

#

or... actually, let me be specific:

I have two number panels, named charCurrStamina and charMaxStamina. I want the panel to display a 0 if charCurrStamina/charMaxStamina > 0.5, a -1 if charCurrStamina/charMaxStamina <= 0.5 and also > 0.25, OR a -2 if charCurrStamina/charMaxStamina <= 0.25. is there a way to do that?

formal goblet
formal goblet
peak jacinth
#

Sorry if this is a dumb question, but would that be something like,

(charCurrStamina/charMaxStamina) <= 0.5 && (charCurrStamina/charCurrStamina) > 0.25 ? "-1"
(charCurrStamina/charMaxStamina) <= 0.25 ? "-2")}$```
#

Wait - I think I misunderstood what a ternary operator is... let me try that again.

silver lake
formal goblet
peak jacinth
#

Oh, wait - but, ternary operators can only return one of two different results, right? So that wouldn't work if I need three possible results, would it?

#

Or is it possible to 'nest' ternary operators together?

silver lake
#

I'll be going to bed now, but I'll check in again tomorrow. All the love.

formal goblet
peak jacinth
#

Okay, that worked wonders! But now I'm wondering if I can pull from the character name field to refer to them directly in the label? Right now I have this:

${charCurrStamina/charMaxStamina > 0.5 ? charName " is feeling fine." : charCurrStamina/charMaxStamina < 0.25 ? charName " is feeling exhausted. -2 modifier on all rolls." : charName " is feeling tired. -1 modifier on all rolls."}$

'charName' is the text field containing the character's name, but for some reason, it won't let me display whatever's in that text field. Is there some syntax I'm missing?

formal goblet
peak jacinth
#

Omg, that worked! Thank you!

fallen coral
#

Does item.equipped affect anything or is it just a value to check? Like, would this prevent an item modifier to work or anything similar?

formal goblet
fallen coral
#

I cannot make this toggle a checkbox in the item, what am I missing? I'm runnin this from an item displayer label, using the checkbox in item displayer trick
%{
const itemName = '${sameRow('name')}';
const item = entity.items.find(item => item.name === itemName);

if (item) {
item.system.props.item_equipped = !item.system.props.item_equipped;
await update(item);
} else {
console.log('Item not found');
}

return item?.system.props.item_equipped?? '';
}%

formal goblet
#

Besides that, verify your properties in the console

fallen coral
#

Also, I know there is an explanation on this in the wiki but I didn't understand the use cases. Now you used double quotes... What does that mean? It is ignored by the target actor, I didn't get it

fallen coral
formal goblet
fallen coral
#

item_equipped

formal goblet
formal goblet
fallen coral
formal goblet
fallen coral
#

I see... thanks

oblique gyro
#

Hey folks! I'm trying to put together a character sheet for a Persona-inspired game I'm gonna run, and I'm hitting a snag trying to get a weapon menu to work on the character sheet. No matter what I do, I can't get the roll to work when it takes into account the variables decided from the dynamic table.

The idea is that when players click the roll button, it calculates the accuracy (2d6 + a stat of the player's choice, referred to as "Aspects", chosen via a dropdown + the weapon's to-hit bonus) as well as the damage (weapon damage + any damage bonus the weapon has, after which the damage type is listed). You can see my attempt at this on the right in the picture.

Does anyone have any advice on how to get this working? I'll need to recreate it as well for a later section on spells.

#

I figure someone has gotten this sort of thing to work before, so if anyone has any answers I'm all ears.

earnest imp
# oblique gyro Hey folks! I'm trying to put together a character sheet for a Persona-inspired g...

"I can't get the roll to work when it takes into account the variables decided from the dynamic table."

The reason why this happens is because CSB may need to take more than one cycle to calculate a value in a dynamic table, and during that same cycle, your component may already be calling for that value you needed which is not calculated yet, which might cause a race condition error on your end

#

throwUncomputableError is probably what you need, try looking into it

oblique gyro
earnest imp
#

No better way to learn to code than to build the systems you like with coding

#

🙏

timid marten
# formal goblet y

My script is done but how can the label text detect it's JS?

// Fetch the "inv_munitions" table from the actor
const items = fetchFromActor('attached', 'inv_munitions');

// Check if "items" exists and is an array
if (!items || !Array.isArray(items)) {
  return 0; // Return 0 if the table is empty or undefined
}

// Find the item named "Chargeur de 9mm" with "loaded" set to true
const item = items.find(i => i.name === 'Chargeur de 9mm' && i.loaded === true);

// If no valid item is found, return 0
if (!item) {
  return 0;
}

// Return the "muns" value of the found item
return item.muns || 0; // Return 0 if "muns" is undefined
earnest imp
timid marten
#

ty!

oblique gyro
formal goblet
oblique gyro
charred spire
#

Can I make a custom character sheet generator?

timid marten
#

can't seem to make a script work :( Idk what I'm doing wrong

earnest imp
#

%{}% for javascript and ${}$ for CSB function

#

_ _
or if you want something a bit more convenient, like calling for the actor table the item is attached to via pure javascript, you can try entity.entity.parent.system.props.inv_munitions

timid marten
#

I tried this but it still returns errors, did I get it wrong?

%{
  // Fetch the "inv_munitions" table from the actor
const items = ${fetchFromActor('attached', 'inv_munitions')}$;

// Find the item named "Chargeur de 9mm" with "loaded" set to true
const item = items.find(i => i.name === 'Chargeur de 9mm' && i.loaded === true);

// If no valid item is found, return 0
if (!item) {
  return 0;
}

// Return the "muns" value of the found item
return ${item.muns}$ || 0; // Return 0 if "muns" is undefined
}%
formal goblet
# oblique gyro I can't just do something like `Attack Roll: ${ entity.throwUncomputableError([2...

throwUncomputableError() is only need, when you meet the following criteria:

  • You access props via the entity-object
  • The props you access are part of a computable Component (Label or Meter)

Basic usage:

%{
const potentiallyUndefinedProp = entity.system.props.defense;

if (potentiallyUndefinedProp === undefined) {
   entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
}

// Do your remaining stuff here
}%
oblique gyro
formal goblet
crimson girder
#

Hmmm do you have some examples you can show me?

charred spire
#

Can I make a custom character sheet generator?

formal goblet
charred spire
formal goblet
charred spire
formal goblet
charred spire
#

the base stats I wish were random, because I fill it out manually

charred spire
formal goblet
# charred spire Can I create a macro like this?
MDN Web Docs

The Math.random() static method returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1, with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or r...

charred spire
formal goblet
patent dust
patent dust
charred spire
patent dust
formal goblet
charred spire
# charred spire

Hmm I thought of something now. If I could make a button that changed these base stats values ​​just by clicking on it (placing limits and such), would that be possible?

formal goblet
charred spire
patent dust
#

Hello guys! A question about dice rolling and dice modifiers
Let's say I use the expression 4d6cs=1. The result will be the number of dice resulting with a 1. But I need to show the total result too, because I want to check it against a character's statistic.
In other words: I want to rolll 4d6, count the number of 1s and check the total of all the dice against the Strength of a character. Is it possible to do that with a single roll and a single formula?

patent dust
#

I suspected it 😦

timid marten
formal goblet
patent dust
timid marten
formal goblet
timid marten
#

and it still returns 0

formal goblet
timid marten
#

so the one at "parent"?

formal goblet
#

There and after find()

timid marten
#

%{ const itemName = 'Chargeur de 9mm'; return entity.entity.parent.items.find(i => i.name === itemName && i.system.props.loaded).system.props.muns ?? 0; }%

like this?

formal goblet
#

Yep

#

Check the console with the error

timid marten
#

Logger.js:33 Custom System Builder | Cannot read properties of null (reading 'items') TypeError: Cannot read properties of null (reading 'items') at eval (eval at processFormulas (ComputablePhrase.js:128:40), <anonymous>:5:29) at processFormulas (ComputablePhrase.js:128:132) at async ComputablePhrase.compute (ComputablePhrase.js:157:34) at async ComputablePhrase.computeMessage (ComputablePhrase.js:257:9) at async Label._getElement (Label.js:107:26) at async Label.render (Component.js:143:25) at async Panel.renderContents (Container.js:43:25) at async Panel._getElement (Panel.js:97:33) at async Panel.render (Component.js:143:25) at async TemplateSystem.getSheetData (templateSystem.js:337:41) at async CharacterSheet.getData (actor-sheet.js:49:19) at async CharacterSheet._render (foundry.js:5838:18) at async CharacterSheet._render (foundry.js:6572:5) at async CharacterSheet._render (foundry.js:7158:5)

formal goblet
timid marten
#

Logger.js:33 Custom System Builder | Cannot read properties of undefined (reading 'system') TypeError: Cannot read properties of undefined (reading 'system')

formal goblet
#

And now it doesn't find the item

crimson girder
#

so i think in order to do the thing i want to do i need to be able to select the item from a dropdown but you can't normally use itemdisplayer from a dropdown. I think i would need a custom for that which i suppose would be the lookup function right?

formal goblet
formal goblet
crimson girder
#

hmm mthe options it gives for options origin are custom, dynamic table, and formula

formal goblet
crimson girder
#

ok it does work but not when i try to use the item name since i guess im using that as the item reference column label

#

it works when i use any other value

charred spire
#

{
"setPropertyInEntity(actor, 'data.baseatk', Math.floor(Math.random() * 6))"
}
i try this, but not work '-'
where's the problem?

formal goblet
crimson girder
#

ok that works

charred spire
crimson girder
#

now i just need to call the values from that to the sheet

#

which i think i can figure out

formal goblet
charred spire
#

{
"setPropertyInEntity(actor, 'baseatk', floor(random() * 6))"
}

?

formal goblet
#

With the random function having a range from 0 to 100

charred spire
crimson girder
#

hmmm guess not cause im getting an error message

#

this is what i put in the label

#

${first(lookup('AtkCalc', 'WSpd', 'Name', WCalcs))}$

formal goblet
crimson girder
#

that did it

formal goblet
timid marten
#

should I put "AMMO" back?

#

instead of muns?

formal goblet
timid marten
#

It works, but when I uncheck the "loaded" checkbox it results in an error instead of 0

timid marten
#

All good, thank you!

crimson girder
#

hmmm ok i got th3e values assigned but one of thme is returning an error

#

this is what it returned

#

its ods because the rest of the values output fine, its just dodge that isnt

formal goblet
crimson girder
#

hmmmm i wonder... could it be because the value is dependent on a calculation that originates from the itemdisplayer?

crimson girder
#

heres what it said for props

formal goblet
# crimson girder

You should try to fix uncomputed props whenever possible, because these indicate flaws in your calculations

#

Something like a typo in a key

crimson girder
#

whats odd is the error only exists in the drawn value

#

oh wait i think i see it

#

its not calculating in the battle speed value

#

ok i fixed it

#

i just had to put the calculation for battle speed into the formula for dodge

crimson girder
#

so now its not fetching the associated value from the actor

#

its just returning the default value of 0

#

Hit: ${roll1:=[1d100] <= (CAcc - fetchFromActor('target', 'CDodge', 0))}$
Crit: ${roll2:=[1d100] <= (CCrit - fetchFromActor('target', 'CAvoid', 0))}$

#

thats the formula

worthy bolt
#

Hello, so uhm, im getting an bug that i can't open "prototype token" button

#

Even right-click doesn't work

formal goblet
worthy bolt
#

When i reload the actor sheet to the template sheet, "Prototype token" option just doesn't work

formal goblet
worthy bolt
#

Does i need backup anything before doing it?

#

just to make sure

formal goblet
#

No, cache only stores temporary data

worthy bolt
#

aight

#

still not working

crimson girder
#

hmmm ok looks like its working now

formal goblet
#

Do you have any errors in the console when loading a template?

worthy bolt
formal goblet
#

F12

worthy bolt
#

only this one

formal goblet
#

Even when only loading a template?

worthy bolt
#

This is when i load a template

formal goblet
#

No other red stuff?

worthy bolt
#

nop

formal goblet
#

Huh

#

I've never seen this error message you have, so...

worthy bolt
#

ima try loading this excatly template on another world, hold on

#

it was all working fine like 30 minutes ago

#

when i did a small update on the CSB-template

formal goblet
#

Create a new template and load that instead with a new Actor

#

I want to verify, if it is actually this template

worthy bolt
#

No, its not

#

still not opening when i load

formal goblet
#

Then new world I guess...

worthy bolt
#

aight

#

damn

#

probably because i added modules after the template? idk

#

like i did nothing after updating the template

formal goblet
#

Which modules?

worthy bolt
#

all of these

#

the red one i didnt

formal goblet
worthy bolt
#

Tokenize everything good, didnt try with libWrapper

crimson girder
#

ok i think i'm getting this now

formal goblet
#

Whatever it is, a new world should give us more hints

worthy bolt
#

oh, aight

crimson girder
#

hmmm ok so i figured out how to update values but now i have a different issue

#

i got the attack button to output whether it hits or not but now i need it to deal damage based on whether it hits or crits. I figured out I need to use setPropertyInEntity but how do i code the If statement

formal goblet
timid marten
formal goblet
timid marten
#
%{
const itemName = 'Chargeur de 9mm';
return entity.entity?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO ?? 0;
}%
formal goblet
#

Ah wait, putting inside an Item...

timid marten
#

retuns 6 on sheet, returns 0 on item

formal goblet
#

That's a different context. On items, you need to add the parent. after entity.entity.

crimson girder
#

so something like this?

#

${setPropertyInEntity('target', 'HP_Value', 'roll1 <= (CAcc - fetchFromActor('target', 'CDodge', 0)) ? target.HP_Value - CDmg')}$

formal goblet
#

entity is always the template system of the current entity

formal goblet
#

Surround the whole 3rd arg with double-quotes instead

#

And the ternary-operator comes with a mandatory else-case

crimson girder
#

so the else in this case should just be target.HP_Value ssince if it misses, nothing changes

timid marten
#

one small issue tho

#

it doesn't update instantly

#

I need to refresh the item sheet

#

any way to fix this?

formal goblet
timid marten
#

yes

#

value is set here

#

and read here

#

(two different items)

formal goblet
#

Then you have to make a check for an undefined value and throw an error, so that it computes at the next loop (see this example: #1037072885044477962 message)

crimson girder
#

${setPropertyInEntity('target', 'HP_Value', "roll1 <= (CAcc - fetchFromActor('target', 'CDodge', 0)) ? target.HP_Value - CDmg : target.HP_Value")}$
${setPropertyInEntity('target', 'HP_Value', "roll2 <= (CCrit - (CCrit - fetchFromActor('target', 'CAvoid', 0))) ? target.HP_Value - (CDmg * 2) : target.HP_Value")}$

formal goblet
#

You should capture the result of the first one and use it in the second one

#

Because the updates happen all after the whole expression

crimson girder
#

hmmm it might be easier to do crit first then

timid marten
#

the value can be anything

#

right?

#

anything undefined

#

so something that doesn't exist

#
%{
const potentiallyUndefinedProp = entity.entity.parent?.props.broken;

if (potentiallyUndefinedProp === undefined) {
   entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
}


const itemName = 'Chargeur de 9mm';
return entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO ?? 0;
}%
formal goblet
timid marten
#

tried this

#

it returns the error like it should

#

Failed data preparation for Actor.LffVmcc7RLgjtBeA.Item.tA27OaGR2wVZMN3o. Cannot read properties of undefined (reading 'broken')

#

but the value is broken now

#

it shows a blank label instead of the ammo count

formal goblet
timid marten
#

oh mb

#

still broken though

#
%{
const potentiallyUndefinedProp = entity.entity.parent?.broken;

if (potentiallyUndefinedProp === undefined) {
   entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
}


const itemName = 'Chargeur de 9mm';
return entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO ?? 0;
}%
formal goblet
#

Will broken ever become not undefined?

timid marten
#

no, I thought it was the point to give an undefined value

#

it's never set anywhere

formal goblet
#

When the computation loop starts, all Labels and Meters are undefined and are calculated one after another. Sometimes, when a Label depends on a value, that is not calculated yet, it will throw an internal error to abort computations for exactly that Label. The computation will resume with the next iteration of the loop and the label will try again to resolve the dependency.

That's the whole purpose, why we have to check for undefined, because that value might not be ready yet

#

We have to check, if AMMO is undefined or not

timid marten
#

oh

#

I thought we just sent an error to refresh everything

#

I see now

formal goblet
#

No, it instructs the system to wait until this dependency is resolved

#

But if it never resolves, it will throw a real error

timid marten
#

this should be it then?

%{
const itemName = 'Chargeur de 9mm';
return entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO ?? 0;

const potentiallyUndefinedProp = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO;

if (potentiallyUndefinedProp === undefined) {
   entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
}
}%
#

it works, but it doesn't refresh until I refresh the item sheet

formal goblet
#

The lower half of your code will never be executed

#

There's a return

timid marten
#

mb I'm so used to python

#

😭

formal goblet
#

Shouldn't python also have functions?

timid marten
#

yes but not using brackets will result in a function ending at return and then keeping reading other lines

#

iirc

#
%{
const itemName = 'Chargeur de 9mm';

const potentiallyUndefinedProp = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO;

if (potentiallyUndefinedProp === undefined) {
   entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
}

return entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props.AMMO ?? 0;
}%```
#

tried this

#

but now it's broken

#

Logger.js:33 Custom System Builder | Couldn't compute 'potentiallyUndefinedProp' Error: Couldn't compute 'potentiallyUndefinedProp'

#

else return after the if would fix it?

formal goblet
#

Because you have an edge-case for an Item, that is not attached to an Actor (and also one, if the Item couldn't be found)

#

So you want to return 0 if Item not attached or Item not found.

#

AFTER THAT you should check for undefined

#

My steps would be

  • Save the props instead of AMMO in a variable
  • If variable undefined -> return 0
  • If variable.AMMO undefined -> throw error
  • else return variable.AMMO
timid marten
#

I see

#

I'll write something alongside this and come back to you then

#

thank you for your support

#

💙

#

I wrote this

#
%{
const itemName = 'Chargeur de 9mm';

const itemprop = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props;

if (itemprop === undefined) {
return 0;
} else if (itemprop.AMMO === undefined) {
entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
} else return itemprop.AMMO;
}%
#

is it good?

formal goblet
timid marten
#

yeah I just edited it

potent fossil
#

hey !
quick question, I was wandering if there is a way to extract a data from a character in an atached item ?

formal goblet
crimson girder
#

ok ive given up on the damage for now, im trying to get it to update a weapon's uses based on the number of attacks

formal goblet
#

Hmm, we might need to check for loaded aswell, because it is in a different entity

timid marten
#

it does check for it tho

#

&& i.system.props.loaded

formal goblet
#

But we're not throwing on undefined there

crimson girder
#

${setPropertyInEntity('item', 'UsesF', "item.UsesF - 1")}$

timid marten
#

oh I need to check the undefined for it too?

crimson girder
#

so i think this means i heed to define the item in question

formal goblet
#

Ah wait, is the Formula within an Item Displayer?

crimson girder
#

no, the item is

formal goblet
#

The item.-prefix is only allowed in Item Displayers 😅

crimson girder
#

ahh

timid marten
# formal goblet But we're not throwing on `undefined` there

like this?

%{

const itemName = 'Chargeur de 9mm';

const itemprop = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props;

if (itemprop === undefined) {
return 0;
} else if (itemprop.loaded === undefined) {
return 0;
} else if (itemprop.AMMO === undefined) {
entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
} else return itemprop.AMMO;

}%```
crimson girder
formal goblet
crimson girder
#

hmmm

formal goblet
#

You could do a find on loaded === undefined and throw on hit, before you do a find on Items, that are actually loaded

timid marten
#

I'm kind of lost here tbh

crimson girder
#

ok this should be my last question for now

#

to update the right weapon XP, I need to find a way to compare the names in three separate keys to determine which value to update

formal goblet
# timid marten I'm kind of lost here tbh
const items = entity.entity.parent?.items.filter(item => item.name === itemName);

if (!items) {
return 0;
}

if (items.find(item => item.system.props.loaded === undefined)) {
// throw
}

items.find() //continue with the rest
crimson girder
#

well i have the name to compare, but i dont know how to do a comparison of the three names to it and them to use that to output that to the corresponding variable

timid marten
#
%{
const itemName = 'Chargeur de 9mm';

const items = entity.entity.parent?.items.filter(item => item.name === itemName);

if (!items) {
return 0;
}

if (items.find(item => item.system.props.loaded === undefined)) {
// throw
}

items.find()

const itemprop = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props;

if (itemprop === undefined) {
return 0;
} else if (itemprop.AMMO === undefined) {
entity.throwUncomputableError("Couldn't compute 'potentiallyUndefinedProp'", 'example.labelText.script');
} else return itemprop.AMMO;
}%```

returns an error
formal goblet
formal goblet
#

And you can continue with items.find(...) instead of starting from entity again

crimson girder
#

so i have three keys

  • Weapon1
  • Weapon2
  • Weapon3
    these keys have a weapon type assigned to them eg being Sword, Lance, Bow, etc
    Each of those keys have a weapon exp bar
  • WExp1
  • WExp2
  • WExp3
    which is associated with it specifically
timid marten
#
%{
const itemName = 'Chargeur de 9mm';

const items = entity.entity.parent?.items.filter(item => item.name === itemName);

if (!items) {
return 0;
}

if (items.find(item => item.system.props.loaded === undefined)) {
entity.throwUncomputableError("Couldn't compute 'item.system.props.loaded'", 'example.labelText.script');
}

items.find()

const itemprop = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props;

if (itemprop === undefined) {
return 0;
} else if (itemprop.AMMO === undefined) {
entity.throwUncomputableError("Couldn't compute 'itemprop.AMMO'", 'example.labelText.script');
} else return itemprop.AMMO;
}%```
#

this still returns an error

formal goblet
#

Which one?

timid marten
#

Custom System Builder | undefined is not a function TypeError: undefined is not a function

formal goblet
crimson girder
#

i have a value assigned to the active weapon that i need to compare to the first three keys and use that to determine which of the three associated values to update

formal goblet
crimson girder
#

the equipped weapon has a type

#

which ive already called to the sheet

formal goblet
#

I know what you have, but you still haven't told, how you decide, which value should be updated. I'm missing the conditional logic

crimson girder
#

so im comparing CWeapon to Weapon1, 2, and 3

#

if C weapon is Sword and Weapon2 is Sword, then WExp2 would update

formal goblet
#

Alright, now that makes sense

#

And if CWeapon doesn't match any of these 3?

crimson girder
#

then nothing would happen but the idea is that you should be attacking with a weapon you are proficient with

timid marten
# timid marten same issue as before, it doesn't update https://gyazo.com/20d94cb378191f610b5c65...
%{
const itemName = 'Chargeur de 9mm';

const items = entity.entity.parent?.items.filter(item => item.name === itemName);

if (!items) {
return 0;
}

if (items.find(item => item.system.props.loaded === undefined)) {
entity.throwUncomputableError("Couldn't compute 'item.system.props.loaded'", 'example.labelText.script');
}

const itemprop = entity.entity.parent?.items.find(i => i.name === itemName && i.system.props.loaded)?.system.props;

if (itemprop === undefined) {
return 0;
} else if (itemprop.AMMO === undefined) {
entity.throwUncomputableError("Couldn't compute 'itemprop.AMMO'", 'example.labelText.script');
} else return itemprop.AMMO;
}%```
formal goblet
# crimson girder then nothing would happen but the idea is that you should be attacking with a we...

The script must be adjusted, if you work with Items, but that's the basic logic:

const props = entity.system.props;
const keys = ['Weapon1', 'Weapon2', 'Weapon3'];

const weapon = keys.map(k => ({k, v: props[k]})).find(weapon => weapon.v === props.CWeapon);

if (weapon) {
  const wpnNum = weapon.k.slice(-1);
    entity.entity.update({'system.props.WExp' + wpnNum: props['WExp' + wpnNum] + 1}); // increase by 1
}
crimson girder
#

it shouldnt be an issue wince all the associated variables are on the character sheet proper

formal goblet
#

I have to sleep, so you're on your own

crimson girder
#

thanks for all your help!

timid marten
#

gn!

silver lake
#

I tried to apply, but I don't know how to add first(fetchFromDynamicTable())
to this ${setPropertyInEntity('self', (sameRowRef('ACO')), "sameRow('ACO') - Sphere")}$

#

I mean, this needs to pull information from a dropdown connected to another dynamic table options, so that I can lower the current value. But it setProp.. doesn't grab numbers, so how can I do this?

#

Been brainstorming it for some time now, but I just have a really hard time wrapping my head around it.

silver lake
#

Is it possible in this system for a dynamic table roll to pick and deduct a value from another dynamic table?

#

This is a summary of what I've been asking

#

If it is possible, how?

sturdy mesa
#

Can someone help me with Polyglot on CSB?

I need the data path to languages on CSB, how do I do this?

quasi summit
#

The end of the year is coming. 🎄
I propose to elect @formal goblet the** best one-man-support-team** 🏆 of the year for a Foundry VTT System.
And also in the categories: patience 🥇 , kindness 🥇, availability 🥇 and knowledge 🥇.

normal ore
#

I agree. What this guy does to help the community isn't in the comic

wooden pond
#

Heya folks.

I'm only beginning to dip my toes into this and its been ages since I did any amount of coding at all, so I am rusty and might ask very simple stuff. I tried to figure out how to do it with the FAQ and by spending the last 30-odd minutes crawling through code bits on here, but yeah, so far no luck 😄

I have a unit which has a manpower and a manpower_max number field within a panel called unitstats

I now want to set up a simple Attribute Bar that has those two values in them, but I can't quite figure out how to do it. Can anyone give me a quick help here? 🙂 Thanks

formal goblet
formal goblet
#

You actually shouldn't manually set up attribute bars, because these are read-only by design

ionic wing
#

I'll delete my response, thanks for the tip

#

I came here because I have a question concerning the items. Is there a way to display an item in the chat with CSB?

formal goblet
ionic wing
#

Sorry, my question was poorly phrased. I would like to display an item in the chat during a label roll. For context, my weapons have an item displayer that contains "conditions" applicable through these weapons, those conditions are items. I would like to create a label roll that display the "condition" item in the chat based on the result of the roll. I don't know if it is possible in the system.

wooden pond
formal goblet
wooden pond
#

Fair point, still means I need to know how to get that number from another entry, though

formal goblet
formal goblet
pure blade
#

Hi, im new on foundry, and installed the custom system builder, but it asks me for the missing dependencies, so i wanted to know where i can find them ❤️

formal goblet
pure blade
#

Thanks! it worked

open umbra
#

Is there documentation on getting started with CSB?

open umbra
#

Thanks!

worthy bolt
#

I was wondering, is there anyway to make an XP table for monster?

#

So when an combat ends it auto gives my players XP

#

or is that just complex to do?

formal goblet
#

You need a script for that

#

Or even better, a module

worthy bolt
#

any module that you recommend?

#

or no idea

formal goblet
#

I don't know one

silver lake
# formal goblet Your dropdown would need to hold exactly that value. But that wouldn't be bad, b...

I couldn't understand what this means
I tried to apply, but I don't know how to add first(fetchFromDynamicTable())
to this ${setPropertyInEntity('self', (sameRowRef('ACO')), "sameRow('ACO') - Sphere")}$
I mean, this needs to pull information from a dropdown connected to another dynamic table options, so that I can lower the current value. But setProp.. doesn't grab numbers, so how can I do this?
Been brainstorming it for some time now, but I just have a really hard time wrapping my head around it.
Is it possible in this system for a dynamic table roll to pick and deduct a value from another dynamic table?
This is a summary of what I've been asking
If it is possible, how?

#

Just bumping my question.

silver lake
formal goblet
#

Ah wait, you use a old version of CSB... Replace the following functions:

  • lookup() -> fetchFromDynamicTable()
  • lookupRef() -> fetchFromDynamicTableRef()
silver lake
#

Okay, I'll try!

#

Thank you Martin

#

Doing some balancing and will get right to it

silver lake
#

Maybe it's using more functions that didn't exist in the 3.0.0?

formal goblet
silver lake
#

But I do think I learned something from this, and I'll try to replicate it on my system

silver lake
#

it's just that it's very long

#

one moment

formal goblet
silver lake
#

Don't even know what module that is, but I'll look into it in a second. I think you taught me what's up

silver lake
#

fetchFromDynamicTableRef

#

as undefined

#

This error is from the snippet

formal goblet
#

I see, the name should be getRefFromDynamicTable()

silver lake
#

Oh, okay

formal goblet
#

Damn, it's not that long ago and I'm aldready forgetting deprecated function names

silver lake
#

So for each fetchFrom..Ref I replace it with getRefFromDynamicTable?

formal goblet
#

Yeah

silver lake
#

I'm going to try and update in january when I have some time

silver lake
#

Works on the snippet!

#

Applying the corrections to my system

silver lake
#

Oh, all I needed to remove was the name.

#

Ok! I'm being able to edit the value, but with first(fetchFromDynamicTable('OddityTable', 'CSpheres', sameRow('ACO')), 0) - 1 it first resets the value to 0 then deducts one.

#

So it goes to negative 1.

#

CSpheres being the value. ACO the dropdown, Oddity Table the table.

#

I've removed the , 0 but that just makes it so that it doesn't work.

silver lake
# formal goblet Yeah

Also I'm having a rough time pulling a dropdown value to this mess of a label I have:

${(min(0, ((ceil((10 + (floor((((ref(sameRow('ACCS'))))/10)*2)) + ((floor((((fetchFromDynamicTable('SkillList', 'SLevel', sameRow('ACS')))/10)*2)))))/5)) - (ceil((sameRow('GT1GM', 0))/5)))*2))/2}$
#

it gives me hundreds of the Scalar values

#

errors

#

Before I could pull from it just fine, when it was just sameRow('ACS'), but now that the dropdown is no longer connected to the value I have to use the fetchFrom, so it gives me scalar value errors.

#

This is a label that summs all the skills of the character, and an average roll, to display how hard for them it is, and therefore how many resources they can spend to auto-succeed.

silver lake
#

Which is the most important thing

formal goblet
# silver lake Ok! I'm being able to edit the value, but with `first(fetchFromDynamicTable('Odd...

Your use of fetchFromDynamicTable() differs from mine. Mine has 4 input arguments, while yours has only 3. fetchFromDynamicTable() cannot accept 3 arguments. It must be either 2, 4 or 5, but never 1, 3 or more than 5. The reason behind this is, that the 3rd and 4th value declare together, by what you want to filter (the 3rd one specifying the filter column and the 4th one specifying the filter value)

silver lake
#

I removed it cause it wasn't working

formal goblet
#

I forgot, how your Dynamic Table looks like

silver lake
#

But I added it back, but it's still just setting it to 0 then reducting 1

#

I could stream my screen, but I imagine it's better for you if I screenshot, yeah?

formal goblet
#

y

silver lake
formal goblet
# silver lake

The thing is, that the filterColumn must be a valid column key. I don't see the column 'Skill' in any of your table

silver lake
#

Has to be a column then, I thought they were all keys. I thought columns were just names for visuals.

#

Thanks, lemme try

#

Oh wait

#

you're referring to skill

#

That is not the Dynamic table we're talking about

silver lake
#

But it might be the same

formal goblet
silver lake
#

okok

#

I'll try

formal goblet
#

Or the column, it should collect the values from.

#

One of those 2

silver lake
#

I already added it back. Same issue:
first(fetchFromDynamicTable('OddityTable', 'CSpheres', 'Skill', sameRow('ACO')), 0) - Sphere")

#

Oh wait

formal goblet
silver lake
#

That's why I said wait xD

#

I must've been doing something else wrong before

#

Cause it only started working when I removed the column

#

but when I added it back in I added the wrong column

#

I messed around a lot with adding first, fetch or getRef so I guess I got lost along the way

#

It's working

#

Everything seems to be in order now

#

I have a few kinks that you already told me how to solve that I'll be polishing now

#

thank you @formal goblet

#

Some of these new functions finally unlocked in my brain. I'm medicated after a surgery so I'm a bit slower than usual today, but progress was made!

#

a lot of it.

formal goblet
silver lake
#

I understand!

#

Which is more than usual for me with JS

#

Gotcha, thank you!

worthy bolt
silver lake
#

Rather, I do not know. It does say V11+

silver lake
charred spire
# formal goblet sure

I used setPropertyInEntity('self', 'baseatk', floor(random(0, racialatk) * 1)) and for other attributes too and it worked very well, thank you very much!
But testing it, it gives the impression that it never reaches the maximum value, for example, the maximum atk would be 15, if I press the button for this command several times, many times, the maximum it reaches 14, it even does one before or just just the random one who hasn't gotten to it yet?

formal goblet
silver lake
formal goblet
formal goblet
silver lake
silver lake
formal goblet
#

Maybe something like this?

${?{Oddity:'Oddity?'|"${!fetchFromDynamicTable('Odditytable', 'CSpheres', 'OddityName', 'something').join('"|"')}$"}}$
silver lake
#

What would the something be referring to? Just any other key in the DTable?

charred spire
#

I found out, it was the floor, I tried the ceil, and it was better. Before I had put +1 after 'racialatk' it had worked too, but using ceil, I already eliminate this and I don't need to put 0 too

formal goblet
#

If there should be no filter, you can remove the last 2 args

silver lake
#

So the value I want to deduct?

#

Oh okay!

silver lake
#

I'll come back to this tomorrow

#

Got a lot of stuff. Thank you Martin!

silver lake
charred spire
#

${setPropertyInEntity('self', 'basehp', ceil(random(10, racialhp) * lvlpokemon))

setPropertyInEntity('self', 'baseatk', ceil(random(0, 4) * lvlpokemon))

setPropertyInEntity('self', 'basedef', ceil(random(0, 4) * lvlpokemon))

setPropertyInEntity('self', 'basesatk', ceil(random(0, 4) * lvlpokemon))

setPropertyInEntity('self', 'basesdef', ceil(random(0, 4) * lvlpokemon))

setPropertyInEntity('self', 'basespe', ceil(random(0, 4) * lvlpokemon))
}$

I tested this and it was good, but I actually wanted it to be distributed from 1 to 4 points (per level) in the attributes, randomly. Instead of being a value for each attribute individually, be the score to be divided between the 6 attributes, per level.
I tried to use gpt chat but was unsuccessful. How do I do this?

ionic wing
#

Hello,
I ran into an issue when I tryed to setup an hidden attribute in a character which is calculated based on a dynamic table.
The calculation is as follow (i'm trying to take the max value in the table for the lines with name value "choc") :
"${max(lookup('list_conditions', 'conditions_severite', 'conditions_nom', 'choc').toSpliced(0,0,0))}$

It works, but in my consola I receive tons of warning props were not computed (see image) when I try to add a line in the dynamic table and the performances seems really poor. Did anyone ran into the same issue?

formal goblet
fallen coral
#

Trying so solve as many yellow messages as possible. Is this something to worry about?

worthy bolt
#

is it possible to make those separators without CSS?

charred spire
formal goblet
charred spire
fallen coral
formal goblet
fallen coral
#

Thanks

charred spire
formal goblet
charred spire
formal goblet
fallen coral
#

Any idea why would this throw an uncomputed props error?
<i class="${item_ok ? 'fa-solid fa-dice-d20' : 'fa-solid fa-square-xmark' }$ " style="color: ${item_ok ? 'black' : 'red' }$; background-color: #e0d9ca;"></i>
Context: This is a field in an item displayer. item_ok checks a checkbox in the character sheet

formal goblet
fallen coral
#

Label text

formal goblet
#

Seems fine

fallen coral
#

How to debug?

formal goblet
#

Check the error in the console (including the props in the error message)

fallen coral
#

Should I expand anything in particular?

formal goblet
fallen coral
formal goblet
fallen coral
#

also, ths value is correct btw

#

no, it checks a checkbox

#

There are three checkboxes, it checks one depending on the item

formal goblet
#

And keep in mind, that item_ok is a string and not a boolean

fallen coral
formal goblet
#

equalText()

fallen coral
#

${not(item.item_usa_custo) ? true : ${item.item_usa_custo_tipo}$ ? true : false}$

formal goblet
#

That's why you use equalText in the target formula

fallen coral
#

So I pass variable and not(variable)

#

Thanks, I totaly forgot the sameRow 😅

stiff forge
#

I have a label roll message in my CSB-powered game that rolls a 1d6 which explodes once on a "6". However, I would like it to subtract 1 from the total if it does explode, for a net roll result range of 1-11 (instead of 2-12). Is there any way to do this on a label roll message?

Here is my existing label roll message code:
${attack01name}$ ToHit=${[1d6xo6] + attack01rank + ?{Modifier|0}}$

vocal sorrel
#

Hello, I've been trying to figure out this dialog/confirmation pop-up for my rolls but my execution is clumsy at best. Basically, on the sheet I can select a "Rolltype", Regular, Attacking, Defending or Healing, for when the player wants to do a check with an Attribute. Each of the rolls is a separate rollable label that you can cycle between with those buttons on the left (see image), these are just tabs aligned and made invisible by some CSS (the entire Nerve box is clickable), just so that the player doesn't have to reload the sheet every time they switch between Rolltypes.
Each roll (which there are 4 for each attribute to a total of 24 different rollable labels) opens up a specific dialog with a confirmation window (and there is one for each rollable label, yes, there are 24 different User Input Templates.)
I really think this is way too jank, but I haven't been able to come up with a better idea, so if you guys have any suggestions for how I should remake this entire thing, I would really appreciate them.

vocal sorrel
#

This is how the roll message looks like, and its how it is for every rollable label.

willow birch
# charred spire

Hmm a pokemon template, You have tried PTU/PTA and pokerole before or? Because I think all of them have systems for foundry. Not to diss your project ofc! Just as an fyi 🙂

charred spire
willow birch
plucky canyon
#

I have a script that outputs an array of numbers between 1-5 (basically an exploding d6, that replaces the exploding 6 with two more dice), that returns an array. I'm pretty sure CSB can't handle arrays so I'm trying to figure out how I could get that array back into CSB.

Is there a way to take the output to fill several CSB variables? Somehting like, result1:=array[0], result2:=array[1], etc.

I'm suspecting not, but want to check before scripting it all.

plucky canyon
wooden pond
#

I got a label which serves as a dice-roll button. In the label roll message I have the following:

Attacking with ${item.weapon_name}$<br><br>

${[:item.weapon_atks:d100cs>=(:item.weapon_acc: + fetchFromActor('target', "acc_penalty", 0) + ?{accMod:"Own Accuracy Modifier"[number]})]}$ hits achieved

Sadly it doesn't work. It seems any time I have some form of addition after the cs>= it just... doesnt do anything anymore, not even send any kind of message. Can someone help me out here? 🙂

formal goblet
fallen coral
#

Is it possible to use a label from an item displayer to create a number field using script or anything similar, and have that label inheriting the mouse hover functionality (+1, -1)? I would like to manually control the item quantity from the player sheet, updating the item sheet takes too long

#

I'm using an edited code I found here to create a label that works as a meter, so I thought maybe that is possible?!
<div class="custom-system-meter" style="width: 111px;"> <span class="custom-system-meter-fill" style="width: ${(item.item_qtd * 100) / 50}$%; max-width: 100%; background-color: #384d4d;"></span> <span class="custom-system-meter-content">${((item.item_qtd * 100) / 50)==0 ? '0%' : concat(string(item.item_qtd),' / ', '50')}$</span> </div>

formal goblet
fallen coral
#

I'm guessing I will need to reference it elsewhere

wooden pond
#

Okay I gotta ask for some serious help on this one, been 3 days of hammering my head against a wall and not progressing.

I have need to roll a dicepool against a value composed from different sources.

SourceA is from an item on the actor.

SourceB is from a number field on the actor.

SourceC is from a targetted actor.

What would be the code to make a functional roll as follows:

Roll x d100 (that part is already done) against a target number of (SourceA + SourceB + SourceC), then output the amount of successes.

formal goblet
wooden pond
#

Yes

formal goblet
wooden pond
#

🙏

oblique gyro
wooden pond
#

Not at all, want me to just copy the code I am working with in here?

oblique gyro
#

That'd be really great, sure!

wooden pond
#

${#accBase:= item.weapon_acc}$
${#accModSelf:= acc_mod_for_attacks}$
${#accModTgt:= fetchFromActor('target', "acc_mod_defending", 0)}$
${#targetValue:= accBase + accModSelf + accModTgt}$

Base Accuracy: ${accBase}$<br>
Own Accuracy Modifier: ${accModSelf}$<br>
Target Accuracy Modifier: ${accModTgt}$<br>

The unit scored ${[:item.weapon_atks:d100cs>=:targetValue:]}$<br><br> hits. The AP value of the weapon is ${item.weapon_ap}$```

Literally just finished it in - finally - working order, thanks primarily to @formal goblet who shall be my Hero of the Day 🙏
oblique gyro
wooden pond
#

item displayer!

#

I chose to set my weapons up as items in the end, since its more modular

#

I am doing whats basically a wargame in Foundry 😬

oblique gyro
#

hey, if it works it works, right? I'm working on a conversion of a fanmade Persona TTRPG system and if this works out, I might use something similar for the sheet's spell list too

wooden pond
#

Is there a specific provision on how to get the name of an actor with the fetchFromActor function? Or do I need to use Foundry's basic scripting for that?

wooden pond
wooden pond
fallen coral
#

I'm trying to bind the custom number field value to something. Is it possible to use a structure similar to actor.system.props to point to a row-column inside an item displayer?

#

Perhaps there's another way...

#

Would something like this work, presumably? data-bind="value:${sameRow('item_qtd')}$"

oblique gyro
wooden pond
#

You need to drag an item in from the main panel on the right

oblique gyro
formal goblet
fallen coral
oblique gyro
# wooden pond

Real quick, one thing that my system requires is weapons have damage dice rather than flat numbers like yours. How do I factor that in when calculating a roll?

fallen coral
#

I mean, what I'm trying to accomplish is to track the usage of an ammunition exclusively from the item displayer, cause refreshing the item takes too long

formal goblet
fallen coral
wooden pond
fallen coral
formal goblet
fallen coral
formal goblet
#

That would work, yeah

oblique gyro
# wooden pond Uuuh... you could try setting the dice expression as either one text field and t...

Just to be sure, did I do this incorrectly (about doing modular damage dice amounts)?


${#accBonus:= item.weapon_accuracy_bonus}$
${#damDiceNumber:= item.weapon_damage_dice_number}$
${#damDiceFaces:= item.weapon_damage_dice_type}$
${#damBonus:= item.weapon_damage_bonus}$
${#damType:= item.weapon_damage_type}$
${#traits:= item.weapon_traits}$

Damage calc: ${[[damDiceNumber]d[damDiceFaces]] + damBonus}$```
wooden pond
wooden pond
#

Hmm 😕

oblique gyro
#

that's a real damper on things, that's kinda an important part of this whole system... gonna need to figure this out either here or in a dynamic table (which might just be my better bet just cuz it's immediately editable on the sheet). Thanks though

fallen coral
#

what is the formula to manually reload the character sheet? I cannot find it anymore. I'm getting the weird glitch where a field doesn't change when I update a value it was supposed to receive

wooden pond
oblique gyro
#

now if only I could figure out how to make this work with a dynamic table. I'm glad this functions, but having to make every weapon/spell an item is probably going to get very tedious.

oblique gyro
wooden pond
# oblique gyro you're a legend

${#accBonus:= sameRow('weapon_accuracy_bonus', 0)}$
${#damDiceExpression:= sameRow('weapon_dice_expression')}$
${#damBonus:= sameRow('weapon_damage_bonus',0)}$
${#damType:= sameRow('weapon_damage_type')}$
${#traits:= sameRow('weapon_traits')}$

Damage calc: ${[:damDiceExpression:] + damBonus}$```
#

You need to create the respective columns in the table then as shown

#

That way you might be able to also express the damage as a single entity (i.e. "3d8")

#

If not you just need to split it up again and follow the formula there. Lemme know if it works? 🙂

oblique gyro
wooden pond
#

🫡

oblique gyro
#

seems to work unedited! I'mma throw some more stuff on for further player-facing detail but this is perfect, thank you so much!

wooden pond
#

🫡

oblique gyro
wooden pond
#

Very glad to hear it! 😄

bright flume
#

How are you meant to do else if in formulas?

bright flume
formal goblet
bright flume
#

Ooo

#

I have been trying to do this for hours and I am not getting anywhere even with help from above 😭

${distances:= {% return distance = canvas.grid.measureDistance(canvas.tokens.controlled[0], Array.from(game.user.targets)[0]).toFixed(1);
}%}$

${srange:= item.2_sh_range}$

${attack:= (srange >= distances ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$

formal goblet
bright flume
#

%{ return distance = canvas.grid.measureDistance(canvas.tokens.controlled[0], Array.from(game.user.targets)[0]).toFixed(1);
}%

${srange:= item.2_sh_range}$

${attack:= (srange >= distance ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$

Still getting errors D;

formal goblet
bright flume
#

I did, got the same errors so I got rid of the other bit

${distances:= %{ return canvas.grid.measureDistance(canvas.tokens.controlled[0], Array.from(game.user.targets)[0]).toFixed(1);
}%}$

${srange:= item.2_sh_range}$

${attack:= (srange >= distance ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$

<br> <br>
Target Defence: ${target:=
fetchFromActor('target', "defence")}$

#

And same errors with this

%{ return canvas.grid.measureDistance(canvas.tokens.controlled[0], Array.from(game.user.targets)[0]).toFixed(1);
}%

${srange:= item.2_sh_range}$

${attack:= (srange >= distance ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$

<br> <br>
Target Defence: ${target:=
fetchFromActor('target', "defence")}$

formal goblet
bright flume
#

They do align (I noticed it shortly after, but exact same issue so I never tweaked it)

formal goblet
bright flume
#

Distance bit does work, as the target is 3.2 tiles away

#

${distances:= %{ return canvas.grid.measureDistance(canvas.tokens.controlled[0], Array.from(game.user.targets)[0]).toFixed(1);
}%}$

${attack:= (item.shrange >= distances ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$

I also shortened it

#

${attack:= (item.shrange >= distances ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$ That is the issue, somewhere, somehow

#

With just this
${attack:= (item.shrange >= 3.2 ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$

#

Custom System Builder | Unexpected type of argument in function largerEq (expected: Array or DenseMatrix or SparseMatrix or Matrix, actual: number, index: 1) TypeError: Unexpected type of argument in function largerEq (expected: Array or DenseMatrix or SparseMatrix or Matrix, actual: number, index: 1)

formal goblet
#

Check every variable in there with typeOf(variable) and make sure, that none of them is of type Array or Matrix

bright flume
#

${(item.shrange >= 3.2 ? item.2_sh_accuracy : item.2_l_accuracy) + experience + [1d10]}$
Even this has that error, I removed the variables. The rest are just number fields

formal goblet
timid marten
#

I just need the value to update instantly on the item sheet without having to manually refresh 😭

The weirdest part is that it refreshes on the item displayer instantly from the actor sheet, but it doesn't on the item sheet

timid marten
#

and I don't get why :/

timid marten
#

oh so maybe it's an issue on the system's side? 🤔

fallen coral
#

not sure... one thing I noticed is equalText and count to evaluate certain things behave (in time) differently

#

so... who knows

formal goblet
#

Could be. It could even go beyond the systems control

fallen coral
#

I gave up and, in my case, instead of having the label to update, I simply wrote "+ / -", the roll function updates at least 😅

fallen coral
formal goblet
sturdy mesa
#

I want to write an visibility formula to hide my item container if the item container is empty

Can someone help me?

fallen coral
sturdy mesa
#

I want to hide my panels if the item container is empty

fallen coral
#

You pass the item container and the column, then you compare it to a value (remember lookup returns an array [n])

#

Use a ternary if you need and you are good to go

sturdy mesa
#

Thanks

violet orchid
#

Hi, could anyone here explain how can I create a module with compendium packs based on templates from CSB? I have created an Item template and want to populate a compendium with items based on that template when I activate my module.

bright flume
#

Does anyone have a formula that can determine the amount of grid tiles between a token, and its target?

I have one that only gets the distance in a straight line between the token and its target (meaning diagonal targets are further than straight targets)

The ones I have seen are MeasureDistance (the one I found from Neojoker), Measuredistances (seems to be the one I want but I have no idea how to set it up) and MeasurePath (most up to date one for V12, but I know even less about it)

raven tree
#

Ok something simple - I am trying to pass a variable to a Macro then creates a popup which allows the player to alter the variables and roll - its not getting the parameter

I have used the snipet on the Custom Builder Wiki - to construct the Character Sheet Label Roll:

%{return await game.macros.getName('COPS Roller').execute({stat:'${Fortitude_Score}$'})}%

Then declared the parameter in the Macro here (with a catch - to identify if the parameter is not being recieved:

(async (params = {}) => {
if (typeof params.stat === "undefined") {
ui.notifications.error("No stat value provided to the macro.");
return;
}

const initialDicePool = params.stat;

What have I got wrong ? its something simple I know that much

fallen coral
#

Is it possible to edit the visual of a single panel tab? I mean... it's title/name visual properties

low cape
#

Hey there! Is there any way to refresh items that are already in the scene/a players inventory when I've made changes to the template.
For example: I alter the calculation of health regeneration for food in its template. I then hit "Reload all item sheets" which makes all of the food items in my item menu accept the change. However, the food items already in my characters' inventories must be manually reloaded

low cape
# bright flume Does anyone have a formula that can determine the amount of grid tiles between a...

use canvas.tokens.controlled[0] for the token and game.user.targets.first() for the target.

Here's an example function I've written to return the distance to me in ft (tiles are 5ft)

${#dist:=%{
let controlledToken = canvas.tokens.controlled[0];
let targetToken = game.user.targets.first();
let weapon_range = ${weapon_range}$;
let set_range = ${set_range}$;

if (controlledToken && targetToken) {
    let dist = canvas.grid.measureDistance(controlledToken, targetToken);

    if (set_range && dist > weapon_range) {
        ui.notifications.warn('This weapon does not reach that far!');
        throw new UncomputableError('This weapon does not reach that far!');
    } else {
        return Math.floor(dist / 5) * 5;
    }
} else {
    ui.notifications.warn('No actor or target selected!');
    throw new UncomputableError('No actor or target selected!');
}

}%}$

bright flume
#

Sadly doesn't work. Diagonals still give wrong values

#

6 distance

#

The formula gives 8 range

#

(And it is the same with 5ft per grid. Diagonals are longer than normal)

#

Ayyyyy

#

I got it :D

#

I changed the core settings to be "Exact"

#

Then changed your formula to round instead of floor the value

#

Now the distance showed is the same as the formula makes :D

low cape
#

No worries lol

bright flume
#

I am getting a "Uncomputable token "target"" error with this:

${#pen:= (item.ap >= fetchFromActor('target', 'armour') ? setPropertyInEntity('target', 'hp', (target.hp - dam)) : " na")}$

${pen}$

Can anyone help me out here?

violet orchid
#

Does anyone know how I can reload a character sheet (or even a single computed prop) via JS? I have module code that updates an item, but the item displayer in my character doesn't show changes until i manually reload or make another change.

violet orchid
#

I tried
await actor.reloadTemplate(actor.system.template);
and this works in console, but not in the code i'm running from a hook on createItem.

#

I have a roll label message that creates a message in chat with some data.
Then my hook runs, checks conditions, and if they are met does item.update({ "system.props.readyIn": parseInt(abilityData.cooldown) });
This updates my item properly. But the item displayer that has a column ${item.readyIn}$ does not show the updated value until I reload manually or run await actor.reloadTemplate(actor.system.template); in the console (providing correct id's)
I have verified that actor is the correct actor I want to reload.

#

Can anyone explain why this is happening? Is my await actor.reloadTemplate just not firing because it is inside a hooked function?

violet orchid
#

This is even more wierd:

const itemTemplateId = game.items.getName(itemTemplateName).id;
entity.items
    .filter(item => item.system.template === itemTemplateId)
    .forEach(item => {
        const newCd = Math.max(item.system.props.readyIn - 1, 0);
        item.update({'system.props.readyIn': newCd});
    });```
I have a button with the following code wrapped in %{}%.
The script properly updates my items, but not every item on the item displayer is shown with new values. Some get updated, others do not.  The column label is just  `${item.readyIn}$`
formal goblet
violet orchid
#

I also tried await item.update() but it didn't fix the issue

formal goblet
#

I'm not that deep in the update-lifecycle of foundry

#

forEach() is not async

formal goblet
violet orchid
#

Thing is, the items do update properly. I'm trying to find a workaround so that my item displayers properly show the current value.

fallen coral
#

Values seem to update properly but they are not rendered idk

#

You can create a label outside the item displayer and use find to see if this is related exclusively to the item displayer

formal goblet
#

It's somewhere inbetween "it renders too early" and "it updates too late"

violet orchid
#

I have checked the console and found that after item.update() CSB logs that all props have been computed.

fallen coral
#

This thing is so strange considering the amount of loops required to compute items

fallen coral
violet orchid
#

I really hope there is another way instead of having my players click this:

#

(just made this to test if it works)

formal goblet
violet orchid
#

Yeah I know, but I would still prefer to not have to make such a button

formal goblet
#

And the input argument is optional. It will reload the current template with no args

#

Ik, but I don't know a proper solution

violet orchid
#

Ok so I tried making a hook on updateActor but just got an infinite loop (it works though). Now I'm wondering if there is some other way to force a refresh of this single property in the item displayer once.

formal goblet
violet orchid
formal goblet
#

Yeah

#

It's always either of these 2

timid marten
violet orchid
#

So this is what's happening:

  • my actor is being updated (I checked that the diff contains the updated item displayer values)
  • then props are calculated (accoring to the logs)
    But the item displayer still shows the old value for abilityCooldown and the html is not changed
#

Are the logs lying? Is "All props computed" not actually logged when the actor sheet is refreshed?

formal goblet
timid marten
#

Is it possible to write a script inside a label that refreshes a sheet every 5 seconds?

violet orchid
#

I set the logger to debug, but I only geet "All props computed" a bunch of times and no additional information. Also after the update has completed

violet orchid
#

Ok something very wierd is happening (or I don't understand how the item displayer works):
So I logged this, and in the scope there is item but that object contains a jumble of props: some from my actor, some from other items.
It's like the scope is totally incorrect.

#

Does the item displayer work with many different item templates with duplicated props?

#

At this point I think I'll just html.find() that dynamic row and change the html manually via javascript XD

formal goblet
violet orchid
formal goblet
#

@brittle moth any idea on that case?

violet orchid
#

So the last thing I tried is document.querySelector('div[data-name="abilities.WdqSUXDy0WYnCqvN.abilityCooldown"]').innerHTML = 'WTF';
I know this is stupid, but it changed the column for a second, then promptly changed it back to the incorrect old value.

#

The item displayer just simply refuses to let me display the updated item property

oblique gyro
#

Is there a way to change the font the character sheets use?

brittle moth
brittle moth
violet orchid
bright flume
#

Can anyone tell me why this isn't working?

${(accuracy >= hit ? setPropertyInEntity('target', 'hp', "target.hp - dam") : "Attack deals no damage...")}$

If accuracy is lower than hit, "Attack deals no damage..." displays no problem.
If accuracy is equal to or higher than hit, it gives this error:

"Custom System Builder | Unexpected type of argument in function subtract (expected: Array or DenseMatrix or SparseMatrix or Matrix or number or BigNumber or Fraction or Complex or string or boolean, actual: Unit, index: 1) TypeError: Unexpected type of argument in function subtract (expected: Array or DenseMatrix or SparseMatrix or Matrix or number or BigNumber or Fraction or Complex or string or boolean, actual: Unit, index: 1)"

formal goblet
bright flume
#

"Unit"

formal goblet
#

Well, that's the wrong type

bright flume
#

Aha

#

Nice

#

Thank you!

formal goblet
#

How is it calculated?

bright flume
#

"dam" is a label inside the actor that just shows how much damage the item it is tied to does;

So I will just swap it for the actual number field inside the item.

#

I am now getting a "Cannot convert "ERROR" to a number Error: Cannot convert "ERROR" to a number" error

#

${(accuracy >= hit ? setPropertyInEntity('target', 'hp', "target.hp - item.it_dam") : "Attack deals no damage...")}$

formal goblet
#

What does ${item.it_dam}$ return?

bright flume
#

1, the damage of the item

formal goblet
#

${fetchFromActor('target', "hp")}$ ?

bright flume
#

Bruh, I am blind af

#

I just looked at the targets hp, it had "error" instead of a number ;D

#

It is working now :D

#

If I wanted to add a And condition, is it &&?

formal goblet
bright flume
#

nice :D

#

The dopamine levels in my brain are spiking, thank you everyone for the help!

oblique gyro
#

Quick question - How do I make a stat on a character sheet get added to an initiative roll on the combat encounters tab?