Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 02:24 PM |
I have a table designated to store thousands of Vector3 values as the game progresses, and HopperBins used by multiple players (probably 6 players per server at this rate). I'm pretty sure that lag will be a huge problem-- not to mention, the game, just like the table I'm talking about, will contain thousands or even tens of thousands of parts.
I'm pretty sure it would work just fine with minimal computer sweat, but on the other hand this table is likely to be looped through every couple of seconds or maybe even more often, which would inevitably be a huge burden to the servers (and/or the clients). So, how would I be able to have a table in _G with potentially thousands or tens of thousands of Vector3 values, while having minimal lag while doing so? Or how would I approach the solution in a different way? |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 26 Dec 2012 02:42 PM |
What are you storing them for?
Well anyhow,
Lag ~= Memory usage Scripters ~= Scripting Helpers |
|
|
| Report Abuse |
|
|
Droban
|
  |
| Joined: 12 Aug 2012 |
| Total Posts: 157 |
|
|
| 26 Dec 2012 03:29 PM |
| I'm not sure which ways of storing it are fastest, but I do not think that's your problem. There's likely a better way to do the task you are attempting. What are you trying to do, and how how does this fit into it? |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 04:05 PM |
@sn0x I'm fed-up of your replies to my threads remonstrating that I posted in the wrong section. I know you've been foruming here for a month at most, but I've been in both Scripters and Scripting Helpers for years by now and have memorized the typical behaviors (and its evolution) of both forums and I know where to post my threads. I actually prevent myself from posting here as much as possible due to Sorcus's bias in regards to moderation towards me. Just like your bias, it's pretty clear that I've been avoiding making new threads here because I haven't done so even though I want to spark some good conversations around here. I don't see you telling other, more respected people to post questions in Scripting Helpers, continuing to expose your blatant bias towards me.
Also, did I say that lag had anything to do with memory usage? I've made it more than obvious that the main source of lag would be from having the table looped through as often as every couple of seconds due to this table being a vital part of the game.
So, please, proceed to get the hell out because you're a horrible person.
@droban Thanks for actually *trying* to help! *cough* SN0X *cough* Yes, there probably is a much better way to approach my problem, and I've been thinking the same during my entire scripting process.
I'm currently creating a game where you can mine blocks, similar to what Minecraft has to offer, or comparing with games on Roblox, Epic Mining would be a great comparison. To prevent mined blocks from creating new blocks where it's not supposed to be, I was planning on storing the Vector3 positions of the mined blocks into that table. Another option of mine was just making the mined blocks invisible and the CanCollide false, but OH GOD THE LAG. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 04:05 PM |
@oxcool I'll give you 20k RIGHT NOW if you tell me what clans have to do with this thread. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2012 04:10 PM |
| You could try and make a more efficient way of telling the game which area you don't want blocks in. You could make something go through all the Vector3s and determine if it can group any into an area. Then you could cut down on the number of values in the table. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 04:17 PM |
@prehistoricman What do you mean by 'group any into an area'? |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2012 04:23 PM |
Like if you have
Vector3.new(1, 0, 0) Vector3.new(2, 0, 0) Vector3.new(3, 0, 0) Vector3.new(4, 0, 0)
You group to
Range.new(Vector3.new(1, 0, 0), Vector3.new(4, 0, 0))
Or even
Vector3.new(1, 0, 0) Vector3.new(2, 0, 0) Vector3.new(3, 0, 0) Vector3.new(4, 0, 0) Vector3.new(1, 1, 0) Vector3.new(2, 1, 0) Vector3.new(3, 1, 0) Vector3.new(4, 1, 0) Vector3.new(1, 2, 0) Vector3.new(2, 2, 0) Vector3.new(3, 2, 0) Vector3.new(4, 2, 0)
To
S.q.u.a.r.e.new(Vector3.new(1, 0, 0), Vector3.new(4, 0, 0), Vector3.new(1, 2, 0), Vector3.new(4, 2, 0)) |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 04:28 PM |
| But while 'compressing' all the Vector3 values, wouldn't it have to loop through to find compressible values? It might not be worth the overcomplication and I'm pretty sure there would be a much easier way. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 26 Dec 2012 04:29 PM |
| If you break it up into chunks, then you only will have to loop through small sections of the data. Also, if you reset the mine every once in a while, you'll be good. |
|
|
| Report Abuse |
|
|
Droban
|
  |
| Joined: 12 Aug 2012 |
| Total Posts: 157 |
|
|
| 26 Dec 2012 04:52 PM |
My solution would be much faster, and require little to no looping:
When you remove a block, check for blocks on all of its 6 sides. For every one that exists, 'attach' something to those blocks in some way that tells it 'do not put anything here when you are destroyed.'
One way of doing this is to add Vector3Values to all the surrounding blocks. Actually, this is probably the way I'd do it. And instead of Vector3Values, use IntValues to specify which side of the block is empty. When you remove that block, just check its children to see which sides not to place new mining blocks at. This is a fast solution that doesn't require a bunch of looping and doesn't leave information that isn't needed.
|
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 04:56 PM |
| Hmm, the idea of Vector3Values in each block seems like a pretty good idea. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2012 04:57 PM |
| A precarious problem solver by Droban! |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2012 05:27 PM |
| Do these blocks need to have a preset existence, or can you randomly generate them as you go? |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
|
| 26 Dec 2012 05:37 PM |
@Tenal,
When their clan needs a 'skript0r', they sometimes come here. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 05:42 PM |
@oxcool Yeah sure, a game related to clicking blocks is related to clans. Idiot. |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 06:08 PM |
That's up for you to decide. Either way this thread is easily classified as a scripting question and regardless of what the usage of it is for, it still abides. I can't even believe this is being discussed, and I should post as an alt now on; I'm sure response will be much, much more positive.
Now get the freaking freak out. |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 06:13 PM |
Well, you have absolutely no proof that that's true. Die. |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 26 Dec 2012 06:38 PM |
| It's possible, but am I doing it? |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 26 Dec 2012 06:39 PM |
"this table is likely to be looped through every couple of seconds or maybe even more often, which would inevitably be a huge burden to the servers (and/or the clients)."
Sort the data, so that you don't have to loop through all of it every time.
Clearly you're not going to be doing something with all of the data every frame, because that would just be too expensive. So, you must be doing something with only some portion of the data.... so why not keep track of which portion of that data that is as you go, rather than finding it over and over again every frame?
Whenever you need more performance in computing, before you think about doing optimization, organizing your data better is usually the answer. |
|
|
| Report Abuse |
|
|