|
| 07 Mar 2013 02:12 AM |
Hello! I have a problem:
I have created a server script which monitors game.JointsService.ChildAdded, game.JointsService.DescendantRemoving, and game.Workspace.DescendantRemoving.
When any of these events are called on the server script, the server script updates its own internal structure, maintaining a dynamically searchable map of all of the links that a brick has. (Basically, in roblox, you can find what bricks a link has. But you can't find (quickly) what links a brick has. My script creates a map which allows me to quickly find what links a brick has)
Now, here is where my confusion comes.
Originally, I had a script in a tool (but not a localscript) which responded to user input, read data from the Joint Tracking script, and applied a change to all bricks connected to the brick that the player specified. The problem with this was, though, that the script did not end up working in multiplayer mode. As soon as I uploaded it to roblox, I ran into trouble -- Because my tool script is not a localscript, it can't receive any input from the player it belongs to!
So, the simplest solution would be to change my script to a localscript, right?
Well, I am not so sure about that.
First off, a localscript can't modify bricks (right? or am I mistaken about this?)
Second of all, a localscript can't access _G (which is how the link tracking script sends its data).
These two problems are very troublesome, BUT, I would be able to get around them if I knew two things:
How do I get a localscript to send a message to a Server script? How do I get a Server script to send a message to a player's localscript?
And, if you could, please also answer this question: Can a localscript modify bricks in any way? Or do world modifications have to be done on a server script?
If you could answer those three questions, I would be eternally grateful... Thank you! |
|
|
| Report Abuse |
|
|
velibor
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 1003 |
|
|
| 07 Mar 2013 04:34 AM |
To communicate between a Normal and a Localscript you will need to use Values. (For example use the Changed Event on a Model called 'Communicate' and get the Values out of that.)
I'm not sure or a LocalScript can change bricks. I guess it is possible. You also have guns that are creating there parts and weld them.
|
|
|
| Report Abuse |
|
|
|
| 07 Mar 2013 12:06 PM |
Thank you for the reply! I have been doing experiments, and deeply analyzing the API.
I have come across some interesting things (but I cannot test them until later today). As you said, I can use values to communicate, but there is a very special value, "BindableEvent". I think that this BindableEvent value may just be networked!
Why do I think that?
Well, BInableEvent has a very odd bug that causes Indices in tables that are sent to it to be "silently removed" when there are also keys in the same tables. This is odd to me, because theoretically, if we were simply passing around arguments in a simple event listening system, such oddities should not exist.
HOWEVER
If there were, say, a network object serialization algorithm, which takes all of the sent objects apart, converts them to transmittable bytecode, and transmits them, then that would very perfectly explain the odd bugs! That may not be the only explanation, but I find it a likely explanation! It follows that if the BindableEvent value has network serialization, it probably has networking too!
But this is all just theory. I will be trying this myself later, but do you know if BindableEvent will work for my needs?
I believe I have confirmed now that local scripts CAN edit the world (they have successfully moved them selves to different parts of the player's body, and the server has seen those updates) (They have also successfully created blocks in the world, but Idid not check if those blocks were seen on the server) (Also, if values are a way to communicate to server scripts, then it stands to reason that they are able to edit those values, and therefore anything else within the world)
Thanks a ton for your answer! Happy coding :)
|
|
|
| Report Abuse |
|
|
|
| 07 Mar 2013 12:13 PM |
LocalScripts can indeed edit the world, so long as its ancestor is of a client (Descendant of Player or Player.Character).
I'm not sure about BindableEvents. I never use them. Good luck!
When you find the answer, be sure to post here! I'm interested in a fix! |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2013 12:20 PM |
Oh, I see! What if they add an instance of "Part" to the player's hierarchy? When I did this, the "Part" object was instantly removed from my hierarchy and sent to the world hierarchy -- but I am not sure if the server ever saw the instance of "Part"
As for BindableEvent, will do! :D I'm planning on making a networking library for Roblox with whatever I can find that works. (Support for sending event to server, receiving event from server, and getting/setting non-function values from server _G variable)
That way, future programmers won't have to go to the trouble of setting up silly value systems/Silly BindableEvent systems (although the latter doesn't sound half bad).
Thankyou for your reply and information! |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2013 01:44 AM |
Unfortunately, it seems I was mistaken. After testing the BindableEvents, they are not transmitted over the internet. :(
Oh well, I'll find another way. |
|
|
| Report Abuse |
|
|
velibor
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 1003 |
|
|
| 08 Mar 2013 03:59 AM |
Flynn. Personal I will use a Model, like I said before. There you put your Values in and check or the Model has been changed.
About your LocalScript issue : We can do this
- Changer (Model) -- ObjectValue -- Value that needs to be Changed with a proper name.
This will work like the next : We put a new Value inside our Changed Model and change the ObjectValue (To the Object that we need to change)
About the new Value : - It needs to have the Name of the Property
Then we do the next
function Validate(Name, Value) Val = nil if type(Value) == "string" then Val = Instance.new("StringValue", Game:GetService("Workspace").Changer) elseif type(Value) == "number" then Val = Instance.new("NumberValue", Game:GetService("Workspace").Changer) end Val.Name = Name Val.Value = Value return Val -- Retuns our Value in a proper format. end
In the Model that we put in the Changer we do the next
script.Parent.Changed:connect(function() -- Your code here end)
This will Change the Brick of our Choose.
|
|
|
| Report Abuse |
|
|
|
| 13 Mar 2013 03:22 PM |
| I'm glad to have found this here! BindableEvent seems to be the closest thing in Roblox Lua to being able to add a method to an object of a pre-existing class. (Being able to make an inheriting class of, say, Part, with the new method(s)/properties isn't likely to happen soon, but a guy can dream.) But I simply could NOT get it to make the connection between a tool and a model it controls! Thanks for the clarification and research. It seems like something that should eventually be enabled/fixed, and it's good to know that the value-event method of simulating it, which I also decided upon, is a reasonable solution for now. |
|
|
| Report Abuse |
|
|