JadedChara / Terminus-game-dev

W.I.P. import for streamlining game development for easy testing. I'm working on establishing the functions first.
2 stars 1 forks source link

Current Workflow! #1

Open JadedChara opened 2 years ago

JadedChara commented 2 years ago
JadedChara commented 2 years ago

@Minion3665 I haven't found much help with this, but is it possible to nest socket.on statements in a function and still have them go into action the moment the function is called? I'm asking because I got the http portions to work that way, but I don't know enough about socket.io to know for certain. Essentially, I'm wondering if it's possible to declare what is in essence and OnEvent() in a function instead of having it normally in the code. Once called, would the OnEvent() be triggered like normal, or would the case have to be somehow active while the function is executing?

Minion3665 commented 2 years ago

@Minion3665 I haven't found much help with this, but is it possible to nest socket.on statements in a function and still have them go into action the moment the function is called? I'm asking because I got the http portions to work that way, but I don't know enough about socket.io to know for certain. Essentially, I'm wondering if it's possible to declare what is in essence and OnEvent() in a function instead of having it normally in the code. Once called, would the OnEvent() be triggered like normal, or would the case have to be somehow active while the function is executing?

Hey Chara, I'm presuming you're talking about registering event handlers. The answer is yes, you should be able to register a handler inside another handler which will then be run when the event is next dispatched.

If you have trouble doing this, give me a ping, some code and what you want it to do and I'll take a look at it for you

JadedChara commented 2 years ago

Thanks! I had trouble getting a straight answer out of google no matter what I searched. I'm going to try something where I don't need to reference the external function the handler is nested in, but it'll take a hot second to figure out.

JadedChara commented 2 years ago

I'm just gonna' merge initSetup and initServer. It makes more sense to do it that way, so that it processes linearly.

JadedChara commented 2 years ago

@Minion3665 I haven't found much help with this, but is it possible to nest socket.on statements in a function and still have them go into action the moment the function is called? I'm asking because I got the http portions to work that way, but I don't know enough about socket.io to know for certain. Essentially, I'm wondering if it's possible to declare what is in essence and OnEvent() in a function instead of having it normally in the code. Once called, would the OnEvent() be triggered like normal, or would the case have to be somehow active while the function is executing?

Hey Chara, I'm presuming you're talking about registering event handlers. The answer is yes, you should be able to register a handler inside another handler which will then be run when the event is next dispatched.

If you have trouble doing this, give me a ping, some code and what you want it to do and I'll take a look at it for you

Right now I'm struggling to get the client and server to communicate, and am frankly stumped. Would you be able to take a look?

There's a few minor errors with file setup, but I'm going to go back and adjust them accordingly. Right now I'm wondering why it's not registering connections. Repl.it Workspace

Minion3665 commented 2 years ago

@Minion3665 I haven't found much help with this, but is it possible to nest socket.on statements in a function and still have them go into action the moment the function is called? I'm asking because I got the http portions to work that way, but I don't know enough about socket.io to know for certain. Essentially, I'm wondering if it's possible to declare what is in essence and OnEvent() in a function instead of having it normally in the code. Once called, would the OnEvent() be triggered like normal, or would the case have to be somehow active while the function is executing?

Hey Chara, I'm presuming you're talking about registering event handlers. The answer is yes, you should be able to register a handler inside another handler which will then be run when the event is next dispatched. If you have trouble doing this, give me a ping, some code and what you want it to do and I'll take a look at it for you

Right now I'm struggling to get the client and server to communicate, and am frankly stumped. Would you be able to take a look?

There's a few minor errors with file setup, but I'm going to go back and adjust them accordingly. Right now I'm wondering why it's not registering connections. Repl.it Workspace

Sure thing, I'll hop on right now

Minion3665 commented 2 years ago

@Minion3665 I haven't found much help with this, but is it possible to nest socket.on statements in a function and still have them go into action the moment the function is called? I'm asking because I got the http portions to work that way, but I don't know enough about socket.io to know for certain. Essentially, I'm wondering if it's possible to declare what is in essence and OnEvent() in a function instead of having it normally in the code. Once called, would the OnEvent() be triggered like normal, or would the case have to be somehow active while the function is executing?

Hey Chara, I'm presuming you're talking about registering event handlers. The answer is yes, you should be able to register a handler inside another handler which will then be run when the event is next dispatched. If you have trouble doing this, give me a ping, some code and what you want it to do and I'll take a look at it for you

Right now I'm struggling to get the client and server to communicate, and am frankly stumped. Would you be able to take a look?

There's a few minor errors with file setup, but I'm going to go back and adjust them accordingly. Right now I'm wondering why it's not registering connections. Repl.it Workspace

Note: I sent a virtually identical message to this one on discord, you don't have to read both

I've taken a quick look; I presume what you're trying to do is get the webpage to connect to the websocket when it loads. Presuming that's what you're trying to do, you don't seem to be loading the script /static/script.js in your html file, or rather you load it but your server doesn't serve it so it results in a 404. As that appears to be the file you're putting your client code in, I'd assume that you need to serve that in order to get your browser to even consider connecting to the socket

You also seem to be requiring the server version of 'socket.io' as well as 'express' and a few other server modules in that file you might want to comment those out, as I doubt they'll do much to help your client code

Hopefully that gives you a couple of debugging pointers to get started with; I can't say if there are any more issues once you've fixed both of those, so if you're still having trouble then come back to here or on discord and I'll help you some more

JadedChara commented 2 years ago

Right now it's returning the webpage as it should, but I think there might be an issue with how I set it up to be served, though I am trying to figure out how to work with it without using __dirname. I've got initServer() and initSetup merged as well, but my current theory is that the page is being served before app.use() references the static folder, but I'm still fairly new to this.

EDIT: As of a few moments ago, I'm probably gonna' change up the file gen so it keeps the index.html in the same directory as my server-side stuff.

JadedChara commented 2 years ago

Okay, finally got it to work! Did a bit of research, and apparently it's a minor issue with Express, not being able to connect scripts to what you're serving. Now I'm getting back to the JSON-stash.

JadedChara commented 2 years ago

@Minion3665 Sorry to bother you, but I've hit another snag with managing player info. It's not overly critical, but I'm concerned about how it would process the info when I get to dealing with the chat-log. I've got it so it logs the data to the console for monitoring all the individual details regarding the player, but the primary issue is that when one uses the chatbox, it starts spamming the console instead of its usual clear/log loop. I'm not sure where this is being caused, but the bit that's bothering me is I'm worried it's a bug with the data itself. I haven't yet begun doing a test of rendering players, but I'm hoping it's just a mistake I made somewhere with the communication.

For clarification, there's an event listener on the chatbox, where socket.emit() sends the data corresponding to the individual user, and that gets bumped into the player's data. Each message sent will trigger an update in players[socket.id].msg. I've never had . . . whatever this is, happen before, so I'm a tad confused.

JadedChara commented 2 years ago

In the meantime, I've made some more updates. I'm partitioning different functions for easy accessibility, though I'm not yet sure on how they'll be referenced in other functions. Currently, I've got the communication between client and server mostly complete. Now I'm trying to figure out NPC mechanics and how to apply pathfinding. Probably will just apply a grid and test vectors to ensure they're uninterrupted. If a path is blocked by something that isn't the target, it will adjust the path until it can construct a new path to follow further along.

JadedChara commented 2 years ago

Currently reworking the functions to increase modular sections. Chat handlers, the account system, and 'temp' databases in the event of a server going down for maintenance. This way, it'll mostly just be front-end design the user is responsible for.

Player rendering will use the html canvas element, and the same with the chatbox for now, until I figure out proper overflow formatting and such. Definitely a process.

JadedChara commented 2 years ago

Clientside now roughly works, but I'm going to need to add support for other options later on. Right now it's set for basic config for top-view games.

JadedChara commented 2 years ago

Alright. Three.js is now fully implemented, but not incorporated into the package. Still tweaking some things so I can properly map out controls.

JadedChara commented 2 years ago

Bug with data fixed, but now I'm wondering how to import stuff client-side. Argh. I tried basic require statements and storing the files in the static folder for that, but it doesn't work.

JadedChara commented 2 years ago

Okay, I've got a workaround. I'll use a socket event for storing the listeners, so the first thing that's done is a ping to the server for establishing which movement and rendering handlers to use.

JadedChara commented 2 years ago

Ping has been implemented, and now I'm adding JSON config options, instead of passing multiple variables, so people can just run the function with the object, instead of a full set of separate things.

JadedChara commented 2 years ago

Ping has been implemented, and now I'm adding JSON config options, instead of passing multiple variables, so people can just run the function with the object, instead of a full set of separate things.

Alright, begun implementing JSON. Working on figuring out how to handle technical errors.