Author Topic: [Help Needed] Automatic lights-out script  (Read 213 times)

0 Members and 1 Guest are viewing this topic.

Oakley

  • Jr. Member
  • **
  • Posts: 63
  • Have a great day :)
    • View Profile
    • Ava Gaming
    • Awards
  • Xbox: MisterCreeperX
[Help Needed] Automatic lights-out script
« on: December 07, 2016, 11:20:08 AM »
Hi

Can someone with good scripting knowledge please help me with a script where powered lights turn off when it's daytime, and automatically come on at night, relative to game time? I have no clue how to make such a script but I would like to have automatic lighting on my city map. I tried to get the following script to work, but to no avail:

If
IsDayTime [true]
Then
SetPower [577,201,344] [off]
Commit
Else
IsDayTime [false]
SetPower [577,201,344] [on]
Commit

Is there a better way of doing this? Am I missing something here? Please let me know if there is a better way because this script did not work at all and I definitely have the correct coords. If you know of a better way then please post the exact script that I need below.

Thanks
_
__
___
____
_____
______
_____
____
___
__
_

What could be in here I wonder (͡ ͜ʖ ͡)
Spoiler for Hidden Content:

Spark

  • Sr. Member
  • ****
  • Posts: 368
  • I'm an italian Guy Who likes scripting!
  • Awards 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: ShoppingSpark3
Re: Automatic lights-out script
« Reply #1 on: December 07, 2016, 11:34:37 AM »
Add a loop and remove the isdaytime after else
Like this:

If
IsDayTime [true]
Then
SetPower [577,201,344] [off]
Commit
Else
SetPower [577,201,344] [on]
Commit
Endif
Loop

Run it
It checks every time if it's night time or not

It should work
Amazing Scripter!

Platinum Dryym

  • Supreme Member
  • *****
  • Posts: 4163
  • What's yours is mine. ~TM's Resident Master Thief~
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts 3 years on site+600 posts Site art contributions/TPs in-game/Contest winners 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: dryym
Re: Automatic lights-out script
« Reply #2 on: December 07, 2016, 11:37:22 AM »
Here's a serious question. Why is this necessary? You can't see the light in the daytime, And the lights don't use up power that would be wasted by using them in the day time.

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym

Oakley

  • Jr. Member
  • **
  • Posts: 63
  • Have a great day :)
    • View Profile
    • Ava Gaming
    • Awards
  • Xbox: MisterCreeperX
Re: Automatic lights-out script
« Reply #3 on: December 07, 2016, 12:11:27 PM »
Add a loop and remove the isdaytime after else
Like this:

If
IsDayTime [true]
Then
SetPower [577,201,344] [off]
Commit
Else
SetPower [577,201,344] [on]
Commit
Endif
Loop

Run it
It checks every time if it's night time or not

It should work

Thanks Spark, I missed out the EndIf, I didn't use it because I didn't think that it would be of any importance to the script, but I have it working now, so thanks  :D

Here's a serious question. Why is this necessary? You can't see the light in the daytime, And the lights don't use up power that would be wasted by using them in the day time.



The lights won't be on during the day and they'll turn on automatically at night. I'm trying not to use too many retextured sun boxes, and although most of the automatic lighting will be in shops etc, there will be some in outside areas like gardens, parks and lakes.
_
__
___
____
_____
______
_____
____
___
__
_

What could be in here I wonder (͡ ͜ʖ ͡)
Spoiler for Hidden Content:

Spark

  • Sr. Member
  • ****
  • Posts: 368
  • I'm an italian Guy Who likes scripting!
  • Awards 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: ShoppingSpark3
Re: Automatic lights-out script
« Reply #4 on: December 07, 2016, 01:04:32 PM »
Thanks Spark, I missed out the EndIf, I didn't use it because I didn't think that it would be of any importance to the script, but I have it working now, so thanks 
The endif it's redundant but I put it because I like putting it.

The problem is "isdaytime" after else and you didn't have the loop command on your script

Hope this clarify everything  ^-^
Amazing Scripter!

Platinum Dryym

  • Supreme Member
  • *****
  • Posts: 4163
  • What's yours is mine. ~TM's Resident Master Thief~
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts 3 years on site+600 posts Site art contributions/TPs in-game/Contest winners 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: dryym
Re: Automatic lights-out script
« Reply #5 on: December 07, 2016, 01:11:53 PM »
Thanks Spark, I missed out the EndIf, I didn't use it because I didn't think that it would be of any importance to the script, but I have it working now, so thanks 
The endif it's redundant but I put it because I like putting it.

The problem is "isdaytime" after else and you didn't have the loop command on your script

Hope this clarify everything  ^-^

Incorrect. Without the endif, You would need two loop commands.

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym

Spark

  • Sr. Member
  • ****
  • Posts: 368
  • I'm an italian Guy Who likes scripting!
  • Awards 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: ShoppingSpark3
Re: Automatic lights-out script
« Reply #6 on: December 07, 2016, 01:16:17 PM »
Thanks Spark, I missed out the EndIf, I didn't use it because I didn't think that it would be of any importance to the script, but I have it working now, so thanks 
The endif it's redundant but I put it because I like putting it.

The problem is "isdaytime" after else and you didn't have the loop command on your script

Hope this clarify everything  ^-^

Incorrect. Without the endif, You would need two loop commands.
Now that I think, you're right

Man, I feel bad for not playing for 5 months
Amazing Scripter!