# Wire E2 code for weather

What is wrong with this E2 code? It’s a code for random rain and so on.

[lua]
@name weather
@inputs Time
@outputs Reset
@persist Rain Sunny Storm Estorm
interval(1000)

Rain==random(1,100)
Sunny==random(1,10)
Storm==random(1,1000)
Estorm==random(1,10)

if(Rain==50) {concmd(“weather_select rain”)}
if(Sunny==50) {concmd(“weather_sunny”)}
if(Storm==50) {concmd(“weather_storm”)}
if(Estorm==50) {concmd(“weather_endstorm”)}

if(Time==240) {concmd(“weather_night”)}
if(Time==480) {concmd(“weather_day”)}
if(Time==481) {Reset==1}
[/lua]

This is the Lua section, we don’t deal with wire E2 problems. Try wiremod.com

this would just take a sec to help me with so why don’t do that instead of complaining?

I’m not complaining, I am just saying that you are posting in the wrong place and are more likely to get help on the wiremod forums. With an attitude like that, you won’t get help on either of the forums.

[editline]10:17PM[/editline]

Also, I don’t know anything about wire.

Okey, i’m sorry then.

I may not know the intricacies of E2, but I do know a logical problem when I see one.
First of all you’re doing the classic equality error, but in reverse. Usually it’s people using one = for a comparison, here you’ve used 2 for an assignment.

Rain=random(1,100)
Sunny=random(1,10)
Storm=random(1,1000)
Estorm=random(1,10)

Now for your conditions you’re checking to see if two numbers are equal. In this case you’ve got as much a chance of
Rain==50 being true as Rain==1 being true.
Instead you would probably want to replace the == with >= or <=.
The last part with the time would probably work as long as the Time input never skips numbers.

@name weather
@inputs Time
@outputs Reset
@persist Rain Sunny Storm Estorm
interval(1000)

Rain=random(1,100)
Sunny=random(1,10)
Storm=random(1,1000)
Estorm=random(1,10)

if(Rain>=50) {concmd("weather_select rain")}
if(Sunny>=50) {concmd("weather_sunny")}
if(Storm>=50) {concmd("weather_storm")}
if(Estorm>=50) {concmd("weather_endstorm")}

if(Time==240) {concmd("weather_night")}
if(Time==480) {concmd("weather_day")}
if(Time==481) {Reset=1}

Sunny and Estorm probably won’t get to 50 either, since the random is 1, 10 (between 1 and 10)

Why did you post this here? Lua != E2 and E2 != Scripting.

Plus I don’t know E2 either. Never could be bothered with a Lua wrapper myself.