Skip to content

Commit

Permalink
Add backup slot count setting
Browse files Browse the repository at this point in the history
Also increase default to 10 slots. Testing at 30 slots didn't seem to cause any lag. Ofc I can make it higher if I want to, but I don't think anybody would be using more than 30 holograms at once...
  • Loading branch information
SuperLlama88888 committed Jan 12, 2025
1 parent 59e819c commit 883d410
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion HoloPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
if(q.distance_from_camera > 60 || q.time_stamp - v.hologram_backup_requested_time <= 600) { // 10 blocks leeway for automatic backups, and 30s after players request a backup
// one by one, check each backup slot. if it's empty, we take that spot; if not, try to find which backup slot was set the earliest.
t.earliest_backup_time_stamp = q.time_stamp + 9999; // all backups should be less than this
t.earliest_backup_index = -1;
for(let i = 0; i < $[backupSlotCount]; i++) {
if(v.hologram_backup_index == -1) {
if(t.hologram_backup_empty_$[i] ?? true) {
Expand All @@ -697,6 +698,9 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
}
}
if(v.hologram_backup_index == -1) { // none are empty, so overwrite the earliest backup
if(t.earliest_backup_index == -1) { // will only happen when the backup slot count is 0
return 0;
}
v.hologram_backup_index = t.earliest_backup_index;
}

Expand Down Expand Up @@ -1002,7 +1006,7 @@ export function addDefaultConfig(config) {
SPAWN_ANIMATION_LENGTH: 0.4, // in seconds
WRONG_BLOCK_OVERLAY_COLOR: [1, 0, 0, 0.3],
CONTROLS: {},
BACKUP_SLOT_COUNT: 5,
BACKUP_SLOT_COUNT: 10,
MATERIAL_LIST_LANGUAGE: "en_US",
PACK_NAME: undefined,
PACK_ICON_BLOB: undefined,
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h1 data-translate="app_name">HoloPrint</h1>
<label><span data-translate="settings.ignored_blocks">Ignored blocks:</span> <input type="text" name="ignoredBlocks" placeholder="block_1 block_2 etc." data-translate-placeholder="settings.ignored_blocks.placeholder"/></label>
<details>
<summary data-translate="settings.advanced">Advanced</summary>
<label><span data-translate="settings.backup_slot_count">Backup slot count:</span> <input type="number" min="0" max="30" step="1" value="10" name="backupSlotCount"/></label>
<label><span data-translate="settings.opacity_mode">Opacity mode:</span> <select name="opacityMode">
<option value="multiple" selected data-translate="settings.opacity_mode.in_game_controls">In-game controls</option>
<option value="single" data-translate="settings.opacity_mode.fixed_opacity">Single option</option>
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ async function makePack(structureFiles, localResourcePacks) {
TEXTURE_OUTLINE_OPACITY: formData.get("textureOutlineOpacity") / 100,
DO_SPAWN_ANIMATION: formData.get("spawnAnimationEnabled"),
CONTROLS: Object.fromEntries([...formData].filter(([key]) => key.startsWith("control.")).map(([key, value]) => [key.replace(/^control./, ""), JSON.parse(value)])),
BACKUP_SLOT_COUNT: +formData.get("backupSlotCount"),
MATERIAL_LIST_LANGUAGE: formData.get("materialListLanguage"),
PACK_NAME: formData.get("packName") || undefined,
PACK_ICON_BLOB: formData.get("packIcon").size? formData.get("packIcon") : undefined,
Expand Down
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"resource_packs.reset": "Resource packs reset!",
"resource_packs.upload_local": "Upload a local resource pack:",
"settings.advanced": "Advanced",
"settings.backup_slot_count": "Backup slot count:",
"settings.heading": "Settings",
"settings.ghost_block_scale": "Ghost block scale:",
"settings.ignored_blocks": "Ignored blocks:",
Expand Down

0 comments on commit 883d410

Please sign in to comment.