![]() |
|
Starfall Help - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: Starfall Help (/thread-937.html) |
Starfall Help - Alanzote - 24-05-2015 1- Is there like a if(changed()) in Starfall? 2- Is there a way to select all entitys in an Array and execute a command in them?(Such like setSubMaterial?) Thank you for your attention, Alanzote. RE: Starfall Help - Person8880 - 24-05-2015 (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:
RE: Starfall Help - Blackhawk - 24-05-2015 1) No there isn't. 2)Yes use a for loop:
EDIT: Person was faster lol RE: Starfall Help - Alanzote - 24-05-2015 Thanks! =) (24-05-2015, 08:00 PM)Person8880 Wrote:But I am not using a local and I need to see if it changed, so How do I do that?(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. RE: Starfall Help - Person8880 - 24-05-2015 Explain exactly what you are tracking for changes. It's rarely a good method when you're checking a global value for changes. RE: Starfall Help - Alanzote - 24-05-2015 (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" RE: Starfall Help - Person8880 - 24-05-2015 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. RE: Starfall Help - Alanzote - 24-05-2015 (24-05-2015, 08:20 PM)Person8880 Wrote: What sets the value? What needs to watch it for changes?When you start the chip, the value is 0 and by chat commands the value is changed. EDIT: NIL PROBLEM
RE: Starfall Help - Person8880 - 24-05-2015 Ok, instead of checking the value for changes (an E2-ism, not a good thing in Starfall), try this:
This way you don't need to be checking for changes, and you can happily change the alert anywhere in the code with ChangeAlert().As for the nil value problem, Lua "arrays" (arrays are just tables with number keys in Lua) start at index 1, not 0. So you need to start I from 1. RE: Starfall Help - Person8880 - 24-05-2015 Read my last sentence again. You have:
you should have:
|