And that's what nescolona's code does.
BUT they would all be in the same lua script, so
a asks b who it knows,
b asks c who it knows,
c asks d who it knows,
d asks e who it knows,
e asks f who it knows,
and f asks g who it knows.
Now
F tells e it knows g
e now knows g
e tells d that it knows f AND g
d now knows f and g
d tells c it knows e f and g
c now knows e f and g
c tells b it knows d e f and g
b now knows everyone which it reports to a
And that's what nescolona's code does.
"If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
-- Niels Bohr
Right, so why can't that code be a function pre-coded into expression 2?
If he can make it in e2 it could be in e2 already.
Okay I figured out what was wrong. (Aside from not initializing Set1, Set2, or Done) I forgot that I had guess that if array R was empty, then (R[1,entity]) would end up false. Wrong. So, I changed the tests to while/if (R:count()) to see if the array is empty or not. Then it worked.
Also I got off my ass and added the array of already scanned props as a blacklist. That bug I mentioned earlier shouldn't occur. Yay!
[highlight=e2]Color = vec(randint(0,255),randint(0,255),randint(0,255))
Done = 0
Set1 = array()
Set2 = array()
Scanned = array()
Set1[1,entity] = entity()
while (!Done) {
while (Set1:count()) {
WasScanned = 0
N = 0
while (!WasScanned & N < Scanned:count()) {
N++
if (Scanned[N,entity] == Set1[1,entity]) {
WasScanned = 1
}
}
if (!WasScanned) {
Set1[1,entity]:setColor(Color)
R = Set1[1,entity]:getConstraints()
while (R:count()) {
Set2ushEntity(R[1,entity])
R:remove(1)
}
}
ScannedushEntity(Set1[1,entity])
Set1:remove(1)
}
Done = 1
while (Set2:count()) {
WasScanned = 0
N = 0
while (!WasScanned & N < Scanned:count()) {
N++
if (Scanned[N,entity] == Set2[1,entity]) {
WasScanned = 1
}
}
if (!WasScanned) {
Set2[1,entity]:setColor(Color)
R = Set2[1,entity]:getConstraints()
while (R:count()) {
Set1ushEntity(R[1,entity])
R:remove(1)
}
}
ScannedushEntity(Set2[1,entity])
Set2:remove(1)
}
}
selfDestruct()
[/highlight]
While you're right R=E:constrainedToAll() or some such could be implemented into E2, since I can do it in E2 already, it would be redundant. I know there's loads of redundant stuff in E2 already, but do we need to add more?
Last edited by nescalona; 08-03-2009 at 03:18 AM.
I think that function could be too expensive if you have large contraptions.
"If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
-- Niels Bohr
Lol I tested it and it is crazy expensive. I'll try and separate the coloring over several ticks. Looks like making an E2 function might be a good idea.
Last edited by nescalona; 08-03-2009 at 04:17 AM.
F'ING HELL
alright guys i made the program way shorter
[highlight=e2]Color = vec(randint(0,255),randint(0,255),randint(0,255))
entity():setColor(Color)
R = entity():getConstraints()
I = 0
while(I < R:count()) {
R[I,entity]:setColor(Color)
}
[/highlight]
:dots:
That's right. E:getConstraints() gets all entities constrained to E, and all entities constrained to those entities, etc. etc.
In other words I wasted a long time because E2's documentation sucks ass. Thanks for not properly describing E:getConstraints(). :winner:
Last edited by Matte; 08-03-2009 at 04:26 AM. Reason: Constrain your language.
If you think the documentation suck ass, why don't you update it?
"If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
-- Niels Bohr
I do when I find something in error (rare). If information is just missing (more common), I ask a dev to add it or try to figure out the missing info on my own by testing.
The wiki description for that function is fixed now
Sorry about the outburst
...FUCK! I thought the same thing... WHHAAAAAAAA!
(\__/) Expression 2 Resources: E2 Beginner's Guide | E2 Formatting Guide | E2 Function Reference | E2 Examples | Me
(='.'=) PM me code and I'll send it back optimized if possible. (I find it fun dammit!)
(")_(") Drunkie referring to an E2: "It's obvious that Chinoto made this, his coding style is all over it."
Bookmarks