diff options
| author | historia <[not public]> | 2026-07-09 22:15:54 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-09 22:15:54 -0400 |
| commit | ecba7f726f70b37126d852c38c7e3eec7b04d730 (patch) | |
| tree | 9129215c6e5015336fde1116395336d82bb952d1 /internal/admin/static/objecteditor.js | |
| parent | b3d4c616f59ad2519f3a0b77e3b47d6571cd2486 (diff) | |
| download | thehouseoficarus-ecba7f726f70b37126d852c38c7e3eec7b04d730.tar.gz | |
feat: old standalone trigger systems completely unified into trigger->condition->action system
Diffstat (limited to 'internal/admin/static/objecteditor.js')
| -rw-r--r-- | internal/admin/static/objecteditor.js | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/internal/admin/static/objecteditor.js b/internal/admin/static/objecteditor.js index 9c5a279..1abccbf 100644 --- a/internal/admin/static/objecteditor.js +++ b/internal/admin/static/objecteditor.js @@ -86,21 +86,17 @@ var SECTIONS = [ ] }, { - id: 'on_use', label: 'On Use', labelHint: '(what happens when you use items on this)', path: 'on_use', isArray: true, fullWidth: true, interactionStyle: true, interScope: 'inline', + id: 'on_use', label: 'On Use', labelHint: '(what happens when you use items on this)', path: 'on_use', isArray: true, fullWidth: true, interactionStyle: true, detect: function(d) { return d.on_use && Array.isArray(d.on_use); }, fields: [ ['item_id', 'Item ID', 'search', 'e.g. keycard (empty = bare use)', '', null, 'items'], - ['condition', 'Condition', 'inter_cond'], - ['action', 'Action', 'inter_act'], ] }, { - id: 'on_look', label: 'On Look', labelHint: '(what happens when you "look <this>")', path: 'on_look', isArray: true, fullWidth: true, interactionStyle: true, interScope: 'inline', + id: 'on_look', label: 'On Look', labelHint: '(what happens when you "look <this>")', path: 'on_look', isArray: true, fullWidth: true, interactionStyle: true, detect: function(d) { return d.on_look && Array.isArray(d.on_look); }, fields: [ ['item_id', 'Item ID', 'search', '(optional — only fires if you carry this item)', '', null, 'items'], - ['condition', 'Condition', 'inter_cond'], - ['action', 'Action', 'inter_act'], ] }, ]; @@ -517,8 +513,6 @@ function renderArraySection(sec, data) { showRemove: function(idx) { return 'removeArrayItem(\'' + sec.id + '\',' + idx + ')'; }, showField: function(secId, idx, key) { return 'showInterField(\'' + secId + '\',' + idx + ',\'' + key + '\')'; }, hideField: function(secId, idx, key) { return 'hideInterField(\'' + secId + '\',' + idx + ',\'' + key + '\')'; }, - addCondition: function(secId, idx) { return 'addInterRootCondition(\'' + secId + '\',' + idx + ')'; }, - addEffect: function(secId, idx) { return 'addInterAction(\'' + secId + '\',' + idx + ')'; }, renderField: function(sec, f, data, idx, optStyle) { return renderField(sec, f, data, idx, null, optStyle); }, onAdd: function() { return 'addArrayItem(\'' + sec.id + '\')'; }, }); @@ -822,10 +816,15 @@ function addArrayItem(cardID) { var sec = SECTIONS.find(function(s) { return s.id === cardID; }); if (!sec || !sec.isArray) return; var arr = objectData[sec.path] || []; - var empty = {}; - sec.fields.forEach(function(f) { - empty[f[0]] = f[2] === 'checkbox' ? false : (f[2] === 'number' ? 0 : ''); - }); + var empty; + if (sec.interactionStyle) { + empty = {steps: []}; + } else { + empty = {}; + sec.fields.forEach(function(f) { + empty[f[0]] = f[2] === 'checkbox' ? false : (f[2] === 'number' ? 0 : ''); + }); + } arr.push(empty); objectData[sec.path] = arr; renderCurrent(); @@ -915,13 +914,7 @@ function showInterField(secId, idx, key) { function addInterRootCondition(secId, idx) { var sec = SECTIONS.find(function(s) { return s.id === secId; }); if (!sec) return; - ie_addRootConditionGroup(sec.path, idx); -} - -function addInterAction(secId, idx) { - var sec = SECTIONS.find(function(s) { return s.id === secId; }); - if (!sec) return; - ie_addEffectToInteraction(sec.path, idx); + ie_addRootConditionGroup(sec.path, idx, 'entry'); } function hideInterField(secId, idx, key) { @@ -932,8 +925,8 @@ function hideInterField(secId, idx, key) { ced_syncDOMToData(objectData); ie_syncAllInteractions(objectData, SECTIONS); if (objectData[secPath] && objectData[secPath][idx]) { - if (key === 'condition' || key === 'action') { - delete objectData[secPath][idx][key]; + if (key === 'condition') { + delete objectData[secPath][idx].condition; } else { objectData[secPath][idx][key] = ''; } @@ -1030,8 +1023,10 @@ function saveObject() { var cleanedCond = ie_cleanCondition(dataItem.condition); if (cleanedCond) item.condition = cleanedCond; } - if (dataItem.action && typeof dataItem.action === 'object') { - item.action = dataItem.action; + if (dataItem.lock) item.lock = true; + if (dataItem.steps && Array.isArray(dataItem.steps)) { + var cleanedSteps = dataItem.steps.map(ie_cleanStep).filter(function(s) { return Object.keys(s).length > 0; }); + if (cleanedSteps.length > 0) item.steps = cleanedSteps; } } if (Object.keys(item).length > 0) arr.push(item); |
