Advertisement
Gudu0

UMT Simulation JS

May 5th, 2025 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | Source Code | 0 0
  1. import oreData from './ore_data.js';
  2.  
  3. function updateOreVisual(tile) {
  4. const ore = tile.dataset.ore;
  5. if (ore && oreData[ore]) {
  6. tile.style.outline = '2px solid red';
  7. tile.style.backgroundImage = `url(${oreData[ore].img})`;
  8. tile.style.backgroundSize = 'contain';
  9. tile.style.backgroundRepeat = 'no-repeat';
  10. tile.style.backgroundPosition = 'center';
  11. } else {
  12. tile.style.backgroundImage = '';
  13. }
  14. }
  15.  
  16. export function runInputerTick() {
  17. const checkedOres = Array.from(document.querySelectorAll('#ore-selection-menu input[type="checkbox"]:checked'))
  18. .map(checkbox => checkbox.dataset.oreName)
  19. .filter(oreName => oreData[oreName] && oreData[oreName].type === 'ore');
  20.  
  21. if (checkedOres.length === 0) return;
  22. console.log("Running inputer tick");
  23. //console.log("Selected ores:", checkedOres);
  24.  
  25. const inputers = document.querySelectorAll('.tile.Input');
  26. //console.log("Inputer tiles found:", inputers);
  27. inputers.forEach(tile => {
  28. const computedPosition = getComputedStyle(tile).backgroundPosition;
  29. //console.log("Computed background position:", computedPosition);
  30. if (!computedPosition.startsWith('50% 0%')) return;
  31. if (tile.dataset.ore) return;
  32.  
  33. const selectedOre = checkedOres[Math.floor(Math.random() * checkedOres.length)];
  34. tile.dataset.ore = selectedOre;
  35. console.log(`Injecting ${selectedOre} into tile`, tile);
  36. updateOreVisual(tile);
  37. });
  38. }
  39. setInterval(runInputerTick, 1000); // inject ore every second
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement