Fixed sleep function issue and writing to global variables.

This commit is contained in:
Raktbastr 2025-04-06 09:28:09 -05:00
parent dbd27cfa7d
commit fdd58af63e
4 changed files with 37 additions and 31 deletions

View file

@ -3,8 +3,10 @@ import { createRequire } from 'module';
const require = createRequire(import.meta.url);
var readlineSync = require('readline-sync');
const { exec } = require("child_process");
import { promisify } from "util";
const execPromise = promisify(exec);
import { food, foodRate, health, healthCap, locationA, locationB, name, radPoints, radSeverity, walkRate } from "./variables.js";
// Used for basic functions, not game specific
export function userInput(question) { // Basic user input functions, takes in the question to be asked.
@ -82,9 +84,12 @@ export function calcLocation() {
}
}
export function sleep(time) {
exec("sleep "+time);
export async function sleep(time) {
try {
await execPromise(`sleep ${time}`);
} catch (error) {
console.error("Error executing sleep command:", error);
}
}
function death() {