(24-05-2015, 08:34 PM)Alanzote Wrote: I read, that's why I deleted the post. :/
I replied before you deleted it.
Is it resolved now?
YEP! Thx!
Another Thing, in E2 you could use the '*' to define all the models from that section, in Starfall how do I do that?
EDIT: I mean that I want to have all the corridors entitys in 1 array"
This is for Starfall optimization, because a lot of 'for' is really bad.
You can't use wildcards in find.byModel, but you can just use:
find.byClass( "prop_physics", function( Ent )
--The path should be everything up to the point you would have added * in E2
if Ent:model():find( "models/whatever/path/you/want" ) then
return Ent:owner() == Owner
end
end )
(24-05-2015, 09:34 PM)Person8880 Wrote: You can't use wildcards in find.byModel, but you can just use:
find.byClass( "prop_physics", function( Ent )
--The path should be everything up to the point you would have added * in E2
if Ent:model():find( "models/whatever/path/you/want" ) then
return Ent:owner() == Owner
end
end )
Probably because people have spawned tonnes of props. Might be better to get your constrained entities instead then.
local Constrained = ents.self():getConstraints()
local Corridors = {}
for i = 1, #Constrained do
local Ent = Constrained[ i ]
if Ent:class() == "prop_physics" and Ent:model():find( "models/whatever/path/you/want" ) then
Corridors[ #Corridors + 1 ] = Ent
end
end
Though that might also hit the ops quota if your ship has a lot of parts. Try it and see.
25-05-2015, 10:07 PM, (This post was last modified: 25-05-2015, 10:08 PM by Alanzote.)
(24-05-2015, 09:51 PM)Person8880 Wrote: Probably because people have spawned tonnes of props. Might be better to get your constrained entities instead then.
local Constrained = ents.self():getConstraints()
local Corridors = {}
for i = 1, #Constrained do
local Ent = Constrained[ i ]
if Ent:class() == "prop_physics" and Ent:model():find( "models/whatever/path/you/want" ) then
Corridors[ #Corridors + 1 ] = Ent
end
end
Though that might also hit the ops quota if your ship has a lot of parts. Try it and see.
Is there a way to slow it down? Still getting ops quota!
Well i can try to help. My ship has about 450 props and this just works fine. I am using the subMaterial lib from Rouing.
--@name Set Sub Material B
--@author Rouing
-- Function is designed to take material 1 and set it to material 2 instead of using an index
function setSubMaterialB(ent, mat1, mat2)
local mats = ent:getMaterials()
for i = 1, #mats do
if mats[i] == mat1 then
entetSubMaterial(i-1,mat2)
end
end
end
To go into red allert I am using this
function redAllert()
for I = 1,#Props do
setSubMaterialB(Props[I], "cmats/base_metal_light", "cmats/flash_red")
end
end
And to go back into green allert i use
function greenStatus()
for I = 1,#Props do
setSubMaterialB(Props[I], "cmats/base_metal_light", "cmats/base_metal_light")
end
end
I am getting all the props at the beginning with. I am getting this just ones so it saves ops.
Props = ents.self():getConstrained()
Maybe this helps you.
SuperPlayer
25-05-2015, 10:59 PM, (This post was last modified: 25-05-2015, 11:27 PM by Alanzote.)
(25-05-2015, 10:39 PM)SuperPlayer Wrote: Well i can try to help. My ship has about 450 props and this just works fine. I am using the subMaterial lib from Rouing.
--@name Set Sub Material B
--@author Rouing
-- Function is designed to take material 1 and set it to material 2 instead of using an index
function setSubMaterialB(ent, mat1, mat2)
local mats = ent:getMaterials()
for i = 1, #mats do
if mats[i] == mat1 then
entetSubMaterial(i-1,mat2)
end
end
end
To go into red allert I am using this
function redAllert()
for I = 1,#Props do
setSubMaterialB(Props[I], "cmats/base_metal_light", "cmats/flash_red")
end
end
And to go back into green allert i use
function greenStatus()
for I = 1,#Props do
setSubMaterialB(Props[I], "cmats/base_metal_light", "cmats/base_metal_light")
end
end
I am getting all the props at the beginning with. I am getting this just ones so it saves ops.
Props = ents.self():getConstrained()
Maybe this helps you.
SuperPlayer
Helped! But Quota execeeded! Just 2 more to go! How sad! =(
I have 407 props
THE MAX: 185
Well this what i am showing you now i have never tested so i dont know if it works
function redAllert()
for I = 1,#Props/2 do
setSubMaterialB(Props[I], "cmats/base_metal_light", "cmats/flash_red")
end
timer.simple(1,function()
for I = #Props/2 ,#Props do
setSubMaterialB(Props[I], "cmats/base_metal_light", "cmats/flash_red")
end
end)
end
Maybe it works. I dont know. But when i am in game again i will try to find a solution for you.