Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 13 Apr 2012 09:30 PM |
I've recently been interested in developing a Wilderness Cell System for very large RPGs. This system dynamically generates cells when a player is in a certain radius of the cell. I've gotten it to work with a loop script that checks a block's magnitude, and sets a global boolean (global as in for all players to use, not script wide). I used Stealth Pilot's original cell system and modified it, but when I came to the PlayerCount variable I had a problem: Since its a loop script, it doesn't know when to stop adding to the variable...
So thats where I was a got a bit more curious. I wanted to know if anyone knew of a way to constantly check for new intruders to this region, then only add 1 to the value when they are in range, then subtract only 1 when they leave the area.
I have a working model here, except it uses a boolean. the problem with a boolean is that if 1 player is inside the region, and 1 is out, the boolean rapidly switches between true and false. This is why a number system is required, (or some other type of system that I haven't contemplated yet.) Free to take, keep it if you like. Any help would be greatly appreciated!
http://www.roblox.com/My/Item.aspx?ID=77423525 |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 13 Apr 2012 10:28 PM |
| Define cell for me, I am intruiged as well. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
| |
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 12:39 PM |
| Does anyone have any ideas? |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 12:44 PM |
Well if it keeps going and going, then add a break in the script. Seems I don't know the script, because you did not post it.
Here is a link to the roblox wiki to help you learn more about looping.
http://wiki.roblox.com/index.php/Loops |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 15 Apr 2012 12:45 PM |
| Can you elaborte what this is? Is it functional in the same way as a organism's cell? |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 01:48 PM |
@unkown1616
I posted a link to the model. I posted a link because it works as a system, there are multiple scripts and a variable included. Here is the loop code though, take a look:
distance = 150 bin = script.Parent base = bin.Base
print("Loading cell " .. bin.Name .. " detection system...")
while true do for i,v in pairs(game.Players:GetChildren()) do human = v.Character:FindFirstChild("Torso") if human ~= nil and (base.Position - human.Position).magnitude <= distance then while (base.Position - human.Position).magnitude <= distance do script.Parent.PlayerCheck.Value = true --print("A player has entered cell " .. bin.Name .. "!") -- This will spam the output, only turn this on for development. wait(1) end elseif human ~= nil and (base.Position - human.Position).magnitude >= distance then while (base.Position - human.Position).magnitude >= distance do script.Parent.PlayerCheck.Value = false --print("A player has left cell " .. bin.Name .. "!") -- This will spam the output, only turn this on for development. wait(1) end wait(0.02) end wait(0.02) end wait(0.02) end |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 01:56 PM |
@Eliuser12
Sorry, I didn't understand what you meant the first time.
In many popular RPG games, "Cells" are used to reduce in game lag. These are mostly used for rooms such as in houses or caves, but what I am looking at is a wilderness system. The wilderness system is much larger than the simple room cells, because the wilderness contain the room cells itself.
So what a "Cell" does is it basically deletes specified "unimportant" items when they are not needed, and loads them back up when a trigger is fired. So, for example: You look at a house (in the wilderness) and decide to go in. At this point, nothing is actually inside of the house, because the items inside are not needed. You take a step inside of the door, and the items inside are all there. They are there because when you walked in the door, a trigger fired and told the items to initialize. You decide that the house has nice mahogany chairs and decide to leave. You walk back outside the door. The items inside no longer exsist because the door was triggered to remove the items. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 01:58 PM |
@unkown1616
Also, a break would not work, or at least not to my knowledge because it doesn't know the difference between players, and so it has to keep adding because a player is in the region. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 08:45 PM |
bump
I hope there isn't anything against the rules against bumping. I just want to get some kind of an answer that works. |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 15 Apr 2012 08:57 PM |
So for example, a giver is technically a cell? It contains a weapon in lighting and pulls it back when needed?
Or is it simply something like a loadstring or coroutine to load a animal from scratch?
Btw, in lamens' terms, he means instances in an MMO. |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2012 08:58 PM |
| I'm how to fix it but I'm to lazy to type it out lol |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 09:14 PM |
@Eliuser12
So for example, a giver is technically a cell? It contains a weapon in lighting and pulls it back when needed?
Or is it simply something like a loadstring or coroutine to load a animal from scratch?
Btw, in lamens' terms, he means instances in an MMO.
Technically, a giver could be considered a cell in very odd terms, but the main things that make up a cell is the special entrance system, or its door, the objects needed to be loaded, and then an overall structure.
Yeah, an instance in an MMO would basically be what it is. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 15 Apr 2012 09:15 PM |
@bluetechdude2
Please post a helpful answer back, I've been dieing to get this to work. Otherwise, don't post anything at all next time, it really crushes a guy's hope to learn there is a way but he can't learn the way to do it! |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 15 Apr 2012 10:44 PM |
| Use lighting, load it one part at a time = no lag. I think magnitude might work, ie: someone comes within 100 studs, load instance. But that would make it difficult, although a solution is octagonal/decagonal cells, to some extent. You could also use raycasting to determine if a person could see or not. |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 15 Apr 2012 10:45 PM |
OH DER
You posted the script... |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 15 Apr 2012 10:47 PM |
I am very tired as of late.
So that script works? Then what's the problamo? |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2012 12:04 AM |
| Ill see what I can do for you. I won't garenty anything. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 16 Apr 2012 03:30 PM |
Yes, the script works fine, In single player that is.
But since the only way that I can think of making this script is with a boolean value, I have problems. If a person is in range of a cell, the value will switch to true, if someone is out of range, the value switches to false. So if I have 1 person in, and 1 person out, what happens? The cell generation system gets no where because the value is switching rapidly... |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2012 04:38 PM |
| Try keeping a table record of players that are within the cell radius. Then in a separate coroutine (sp?), make a function that constantly checks the table's length to see if any players are in the cell. In this way, the boolean only switches when all players in proximity are gone. Not comepletely sure if this would work though. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 16 Apr 2012 04:58 PM |
That was basically the way the original cell system worked. It used a number variable and added on to it each time a player entered. It would then subtract the number when people left.
Thats the main reason why I switched to a bool, I don't know how I would go about setting up a system that counts torsos in a radius... |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
| |
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 16 Apr 2012 09:25 PM |
What you're talking about is known as chunking. I have an example of this in which I made a long time ago here :
http://www.roblox.com/Maze-chunk-item?id=70729749 |
|
|
| Report Abuse |
|
|
Eliuser12
|
  |
| Joined: 27 Feb 2009 |
| Total Posts: 2717 |
|
|
| 17 Apr 2012 12:10 AM |
| Have two different variables for inside the cell. |
|
|
| Report Abuse |
|
|
Maxattax
|
  |
| Joined: 08 Jun 2008 |
| Total Posts: 120 |
|
|
| 17 Apr 2012 04:06 PM |
@Eliuser12
How would I use these variables? I'm not sure what you mean by this. |
|
|
| Report Abuse |
|
|