Okay, so I have heavily reduced the code, its a little different now, but it does the same thing.
game-socket.js
//Start Fight Action
socket.on("fight", () => {
combat(io, socket, app);
});
action-timer.js
const combat = require("./combat/combat");
module.exports = (type, io, socket, app) => {
if (type == "combat") {
app.online.actionTime = setTimeout(() => {
combat(io, socket, app);
}, 1000);
} else if (type == "tradeskill") {
}
};
combat.js
const startAction = require("../action-timer");
module.exports = (io, socket, app) => {
//Run another combat
console.log("COMBAT");
startAction("combat", io, socket, app);
};
Error:
action-timer.js:5
combat(io, socket, app);
^
TypeError: combat is not a function
at Timeout.app.online.actionTime.setTimeout [as _onTimeout] (C:\Users\wjpop\Desktop\kog\funcs\action-timer.js:5:7)
at listOnTimeout (timers.js:327:15)
at processTimers (timers.js:271:5)
I figured it out, weird that I had to do this, as normally it doesn't need to be done like this but action-timer.js should be like so:
module.exports = (type, io, socket, app) => {
const combat = require("./combat/combat");
if (type == "combat") {
app.online.actionTime = setTimeout(() => {
combat(io, socket, app);
}, 1000);
} else if (type == "tradeskill") {
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.