Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 13 14 15 16 17 18 Next »
Starfall Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pages (5): 1 2 3 4 5 Next »
Threaded Mode
Starfall Help
24-05-2015, 07:36 PM,
#1
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
Starfall Help
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.

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
24-05-2015, 08:00 PM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Starfall Help
(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
EntConfusedetSubMaterial( 0, "cmats/light" )
end
Find
Reply
24-05-2015, 08:01 PM,
#3
Blackhawk Offline
GMod Admin
Posts: 204
Threads: 9
Joined: Sep 2013
RE: Starfall Help
1) No there isn't.

2)Yes use a for loop:

local Array -- your array with entities
for I=1, #Array do -- loop through all objects in your array
Array[I]ConfusedetSubMaterial(0, "material name") -- you can replace setSubMaterial by any other function for entities
end

EDIT: Person was faster lol
Find
Reply
24-05-2015, 08:05 PM, (This post was last modified: 24-05-2015, 08:06 PM by Alanzote.)
#4
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: Starfall Help
Thanks! =)

(24-05-2015, 08:00 PM)Person8880 Wrote:
(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?

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
24-05-2015, 08:12 PM,
#5
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Starfall Help
Explain exactly what you are tracking for changes. It's rarely a good method when you're checking a global value for changes.
Find
Reply
24-05-2015, 08:13 PM, (This post was last modified: 24-05-2015, 08:20 PM by Alanzote.)
#6
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: Starfall Help
(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"

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
24-05-2015, 08:20 PM,
#7
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Starfall Help
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.
Find
Reply
24-05-2015, 08:22 PM, (This post was last modified: 24-05-2015, 08:24 PM by Alanzote.)
#8
Alanzote Offline
TSCM Member
***
Posts: 123
Threads: 40
Joined: Oct 2013
RE: Starfall Help
(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]ConfusedetSubMaterial(5, "phoenix_storms/pack2/redlight")
end
end
if Alert == 0 then
for I = 0, #Corridors do
Corridors[I]ConfusedetSubMaterial(5, "models/debug/debugwhite")
end
end
end)

[Image: stargate_kawoosh_animation_HD_by_SergeyDruid.gif] [Image: kecepatan-cahaya-light-speed-warp-drive2....gif?w=640]
Find
Reply
24-05-2015, 08:25 PM,
#9
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Starfall Help
Ok, instead of checking the value for changes (an E2-ism, not a good thing in Starfall), try this:
function ChangeAlert( NewAlert )
Alert = NewAlert
--Run stuff that needs to happen when alert changes here
end
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.
Find
Reply
24-05-2015, 08:33 PM,
#10
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Starfall Help
Read my last sentence again.

You have:
for I = 0, #Corridors do
you should have:
for I = 1, #Corridors do
Find
Reply
« Next Oldest | Next Newest »
Pages (5): 1 2 3 4 5 Next »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.