(24-05-2015, 07:36 PM)Alanzote Wrote: 1- Is there like a if(changed()) in Starfall?
Forget everything about how E2 works. You don't need if (changed()), if (clk()) etc. as everything's event driven.
If you want to detect changes to wire inputs, you use the "input" hook. Other things you should also be using events for, you'll have to post exactly what you want to do for me to be able to give you the right events to use.
(24-05-2015, 07:36 PM)Alanzote Wrote: 2- Is there a way to select all entitys in an Array and execute a command in them?(Such like setSubMaterial?)
If your array of entities is called Ents, then:
for i = 1, #Ents do
local Ent = Ents[ i ]
--Do whatever it is you want to each entity in here, e.g
EntetSubMaterial( 0, "cmats/light" )
end
local Array -- your array with entities
for I=1, #Array do -- loop through all objects in your array
Array[I]etSubMaterial(0, "material name") -- you can replace setSubMaterial by any other function for entities
end
EDIT: Person was faster lol
24-05-2015, 08:05 PM, (This post was last modified: 24-05-2015, 08:06 PM by Alanzote.)
(24-05-2015, 07:36 PM)Alanzote Wrote: 1- Is there like a if(changed()) in Starfall?
Forget everything about how E2 works. You don't need if (changed()), if (clk()) etc. as everything's event driven.
If you want to detect changes to wire inputs, you use the "input" hook. Other things you should also be using events for, you'll have to post exactly what you want to do for me to be able to give you the right events to use.
But I am not using a local and I need to see if it changed, so How do I do that?
(24-05-2015, 08:12 PM)Person8880 Wrote: Explain exactly what you are tracking for changes. It's rarely a good method when you're checking a global value for changes.
I want to check if the var Alert Changed.
EDIT: In the loop thing I get: "attemp to index a nil value"
(24-05-2015, 08:20 PM)Person8880 Wrote: What sets the value? What needs to watch it for changes?
If you're setting the value yourself, then you can just run the code that needs to run when it's changed at the point you set the value.
For the nil value, post exactly what you have for the loop and the array.
When you start the chip, the value is 0 and by chat commands the value is changed.
EDIT:
NIL PROBLEM
timer.create("Alert", 0.5,0, function()
if Alert == 1 then
for I = 0, #Corridors do
Corridors[I]etSubMaterial(5, "phoenix_storms/pack2/redlight")
end
end
if Alert == 0 then
for I = 0, #Corridors do
Corridors[I]etSubMaterial(5, "models/debug/debugwhite")
end
end
end)