Skip to content

Commit b33d1d9

Browse files
help updates and clear image
1 parent 4b50eda commit b33d1d9

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

ProximityTrigger/ProximityTrigger.js

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,17 @@
8686
`{{--cardstyles|-cl=List all card styles}} ` +
8787
`{{--cardstyle|-C [StyleName] [property] [value]=Edit or create a card style}} ` +
8888
`{{--delete|-D [Name]=Delete a monitored trigger}} ` +
89-
`{{--help|-h=Show this help}}`);
89+
`{{--help|-h=Show this help}} ` +
90+
`{{=**Dynamic Message Content**}} ` +
91+
`{{**Dice Roll Syntax**=Supported dice notation:}} ` +
92+
`{{Basic Rolls=1d6, 2d20, 3d8 (XdY format)}} ` +
93+
`{{With Modifiers=1d20+5, 2d6+3, 1d8-2}} ` +
94+
`{{Complex=1d20+1d4+3, (2d6+2)*2, 1d100/10}} ` +
95+
`{{Limits=1-100 dice, 1-1000 sides per die}} ` +
96+
`{{**Character Attributes**=Supported attribute names:}} ` +
97+
`{{Core Stats=hp, maxhp, ac, level, gold/gp, inspiration}} ` +
98+
`{{Abilities=str/dex/con/int/wis/cha (and modifiers)}} ` +
99+
`{{Examples={playerName.hp}, {monitoredName.ac}, {playerName.gold}}}`);
90100
}
91101

92102
/**
@@ -278,8 +288,8 @@
278288
if (state.defaultImagePath && state.defaultImagePath.trim() !== '') {
279289
return state.defaultImagePath;
280290
}
281-
// Final fallback
282-
return '';
291+
// Final fallback - return null to indicate no image
292+
return null;
283293
}
284294
/**
285295
* Gets the effective name for a token - either the token's name or the character it represents.
@@ -994,7 +1004,7 @@
9941004
* @param triggerDistance - Trigger distance in token body widths
9951005
* @param tokenIds - Array of Roll20 token IDs representing this trigger
9961006
* @param timeout - Cooldown in ms before re-triggering (0 = permanent)
997-
* @param img - Portrait/image URL
1007+
* @param img - Portrait/image URL (null to hide image)
9981008
* @param messages - Array of possible messages
9991009
* @param cardStyle - Card style name for this trigger
10001010
* @param mode - Operating mode: 'on', 'off', or 'once'
@@ -1190,8 +1200,11 @@
11901200
case 'cardstyle':
11911201
// List all styles for user to pick
11921202
const styleList = state.cardStyles.map(s => `{{[${s.name}](!pt -e ${safeName} cardStyle ${s.name})}}`).join(' ');
1203+
const currStyle = npc.cardStyle || 'Default';
11931204
sendChat('Proximity Trigger', `/w ${who} &{template:default} ` +
1194-
`{{name=Select Card Style for ${npc.name}}} ${styleList}`);
1205+
`{{name=Select Card Style for ${npc.name}}} ` +
1206+
`{{Current: ${currStyle}}}` +
1207+
`${styleList}`);
11951208
break;
11961209
case 'triggerdistance':
11971210
const currDist = npc.triggerDistance;
@@ -1208,14 +1221,15 @@
12081221
case 'img':
12091222
const imgUrl = npc.img || 'https://raw.githubusercontent.com/bbarrington0099/Roll20API/main/ProximityTrigger/src/ProximityTrigger.png';
12101223
sendChat('Proximity Trigger', `/w ${who} &{template:default} {{name=Set Image URL for ${npc.name}}} ` +
1211-
`{{Current: [Link](${npc.img || 'none'})}} ` +
1212-
`{{New URL=[Click Here](!pt -e ${safeName} img ?{Enter new image URL|${imgUrl}})}}`);
1224+
`{{Current: ${npc.img ? `[Link](${npc.img})` : `None`}}} ` +
1225+
`{{New URL=[Click Here](!pt -e ${safeName} img ?{Enter new image URL ^'clear' to remove^|${imgUrl}})}}`);
12131226
break;
12141227
case 'mode':
1228+
const modeList = ['on', 'off', 'once'].map(m => `{{[${m.toUpperCase()}](!proximitynpc -e ${toSafeName(npc.name)} mode ${m})}}`).join(" ");
12151229
const currMode = npc.mode || 'on';
12161230
sendChat('Proximity Trigger', `/w ${who} &{template:default} {{name=Set Mode for ${npc.name}}} ` +
12171231
`{{Current: ${currMode}}} ` +
1218-
`{{New Mode=[Click Here](!pt -e ${safeName} mode ?{Enter new Mode ^on, off, once^|${currMode}})}}`);
1232+
`${modeList}`);
12191233
break;
12201234
default:
12211235
sendChat('Proximity Trigger', `/w ${who} Unknown property "${property}".`);
@@ -1260,8 +1274,9 @@
12601274
}
12611275
break;
12621276
case 'img':
1263-
npc.img = value;
1264-
sendChat('Proximity Trigger', `/w ${who} ${npc.name} image URL updated${tokenInfo}.`);
1277+
const clear = value.toLowerCase().trim() === 'clear';
1278+
npc.img = clear ? null : value;
1279+
sendChat('Proximity Trigger', `/w ${who} ${clear ? 'Removed' : 'Updated'} ${npc.name} image url${clear ? '' : ` to "${value}"`}${tokenInfo}.`);
12651280
break;
12661281
case 'cardstyle':
12671282
const style = state.cardStyles.find(s => s.name.toLowerCase() === value.toLowerCase());
@@ -1371,7 +1386,7 @@
13711386
{ name: 'Whisper', attr: 'whisper', value: cardStyle.whisper },
13721387
{ name: 'Badge', attr: 'badge', value: cardStyle.badge }
13731388
];
1374-
const propertyLinks = properties.map(prop => `{{[${prop.name}: ${prop.attr == 'badge' ? (prop.value || 'None').slice(0, 16) : (prop.value || 'None')}](!pt -C ${toSafeName(cardStyle.name)} ${prop.attr})}}`).join(' ');
1389+
const propertyLinks = properties.map(prop => `{{[${prop.name}: ${prop.attr == 'badge' ? (prop.value || 'None').slice(0, 16) : (prop.value || 'None')}](!pt -C ${toSafeName(cardStyle.name)} ${prop.attr})}}${prop.attr == 'badge' && prop.value ? ` {{[Link](${prop.value || 'None'})}}` : ''}`).join(' ');
13751390
sendChat('Proximity Trigger', `/w ${who} &{template:default} {{name=Edit Card Style: ${cardStyle.name}}} ` +
13761391
`${propertyLinks} ` +
13771392
`{{[Delete Style](!pt -C delete ${toSafeName(cardStyle.name)})}}`);
@@ -1401,8 +1416,11 @@
14011416
promptMessage = 'Enter text color ^any CSS color^:';
14021417
break;
14031418
case 'whisper':
1404-
promptMessage = 'Enter whisper mode ^\'character\', \'gm\', or \'off\'^:';
1405-
break;
1419+
const whispers = ['off', 'gm', 'character'].map(w => `{{[${w.toUpperCase()}](!pt -C ${toSafeName(cardStyle.name)} ${property} ${w})}}`).join(" ");
1420+
sendChat('Proximity Trigger', `/w ${who} &{template:default} {{name=Set Whisper for ${cardStyle.name}}} ` +
1421+
`{{Current: ${currentValue}}} ` +
1422+
`${whispers}`);
1423+
return;
14061424
case 'badge':
14071425
promptMessage = "Enter URL for Badge Image ^'clear' to remove^:";
14081426
break;
@@ -1412,7 +1430,7 @@
14121430
return;
14131431
}
14141432
sendChat('Proximity Trigger', `/w ${who} &{template:default} {{name=Set ${property} for ${cardStyle.name}}} ` +
1415-
`{{Current: ${property == 'badge' ? (currentValue ? currentValue.slice(0, 30) : 'None') : (currentValue || '')}}} ` +
1433+
`{{Current: ${property == 'badge' ? currentValue ? `[Link](${currentValue || 'None'})` : `None` : (currentValue || '')}}} ` +
14161434
`{{${promptMessage}=[Click Here](!pt -C ${toSafeName(cardStyle.name)} ${property} ?{${promptMessage}|${currentValue}})}}`);
14171435
}
14181436
/**

0 commit comments

Comments
 (0)