Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import oreData from './ore_data.js';
- function updateOreVisual(tile) {
- const ore = tile.dataset.ore;
- if (ore && oreData[ore]) {
- tile.style.outline = '2px solid red';
- tile.style.backgroundImage = `url(${oreData[ore].img})`;
- tile.style.backgroundSize = 'contain';
- tile.style.backgroundRepeat = 'no-repeat';
- tile.style.backgroundPosition = 'center';
- } else {
- tile.style.backgroundImage = '';
- }
- }
- export function runInputerTick() {
- const checkedOres = Array.from(document.querySelectorAll('#ore-selection-menu input[type="checkbox"]:checked'))
- .map(checkbox => checkbox.dataset.oreName)
- .filter(oreName => oreData[oreName] && oreData[oreName].type === 'ore');
- if (checkedOres.length === 0) return;
- console.log("Running inputer tick");
- //console.log("Selected ores:", checkedOres);
- const inputers = document.querySelectorAll('.tile.Input');
- //console.log("Inputer tiles found:", inputers);
- inputers.forEach(tile => {
- const computedPosition = getComputedStyle(tile).backgroundPosition;
- //console.log("Computed background position:", computedPosition);
- if (!computedPosition.startsWith('50% 0%')) return;
- if (tile.dataset.ore) return;
- const selectedOre = checkedOres[Math.floor(Math.random() * checkedOres.length)];
- tile.dataset.ore = selectedOre;
- console.log(`Injecting ${selectedOre} into tile`, tile);
- updateOreVisual(tile);
- });
- }
- setInterval(runInputerTick, 1000); // inject ore every second
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement