Expressions 2 questions thread

Since I’m new to expression gates and have tons of questions (that YouTube videos do not answer, and the wiki is hit and miss), I thought I’d make a thread.

I have two questions to start.

players()

The players() array, how do we loop through it or even get an array key from it. Something like this


PlayerList = players()
print(PlayerList:number(0))

always returns 0

Normal inputs vs strings?

What is a normal variable actually? Text screens and D-Latches require a “Normal” input, this does not work for me


Test:normal
Test = "A"

//Test it output

AFAIK:



Plys = players()

foreach (Key, Ply:entity = Plys)
{
    print(Ply:name())
}


Normal is the same as a Number (eg a variable is normally a number).

If you go to wiremod.com you can find an entire forum for E2 questions that will get you higher quality answers more quickly because of the number of E2 vets who visit the site.

All right thanks

A normal input is a number, variable or constant. A string is text, variable or constant. Sometimes the two do kiss though, and I can see how that gets confusing. This, however, is no such case. I advise not worrying about it, its more a matter of realizing you can do something than realizing you can’t. What you’re dealing with here is not such. Text screens accept string inputs. They may also accept normal inputs, I don’t remember.

If you look at your code, You set Test to be a normal variable, probably in @persist, or @output or something. That does not, however, change that you assigned a string to Test. Setting a variable type does not wave a magic wand and designate it as such, it just provides information needed to the compiler if your code does not supply that in itself. Whether or not you told it that Test was normal in the first line, the fact remains that Test is a string, or vice versa depending on the arrangement of your code and what is and isn’t persisted/outputed/etc. Essentially what you did was defined an apple and tried to pass it off as an orange.

As to arrays, I actually don’t have it totally memorized. If i am correct, it is more along the lines of:
print(Playerlist[0,entity]). That would print the entity name of the 0th player. If you wanted to, say, print the names of every player, I believe you could say



for(I=1,Playerlist:count()){
     print(Playerlist[I,entity]:name())
}


That would ideally be done with a foreach loop, I think, but the syntax escapes me and I don’t really want to start gmod right now.

Thanks man, the whole normal variable confused me. Without documentation on what a normal variable is, I figured it could be a string or integer, i.e. “normal”.

The problem I had with the players() array is that it comes back something like this (Gmod not loaded) :


[[Player[0][wutanggrenade]]

using :name() just seems weird, but I guess that is how it works