How check status of doDaylightCycle?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Kickaha

Member
May 28, 2020
2
0
0
Skript Version (do not put latest): Couldn't find any version info in folders/files, and /sk update check just returns "You're currently running the latest stable version of Skript".
Addons: None
Minecraft Version: 1.15.2

Question in the title sums it up. Here's some context in case it's not clear...

I'm trying to find out how to check whether doDaylightCycle is set to true or false. I don't know whether I'm making a simple syntax mistake, approaching the task from the wrong angle, or even attempting something Skript just can't do.

I've spent hours googling, combing documentation, searching forums, and the only related references I find are the same instructions repeated over and over about how to set it, as opposed to check it. (I even went down a workaround rabbit hole doing a check to see whether time had passed between one line of code and another, before it dawned on me that system time would be carrying on regardless. Doh! And MC time doesn't seem to have the necessary precision.)

In desperation, I've tried all kinds of variations, e.g. putting doDaylightCycle in curly brackets as if it were just another variable, omitting the "do" part, substituting "is" with "is set to" and with "=".

This was my first attempt at a skript, and it worked perfectly...until I got ambitious and decided to add the status-check. Any help would be appreciated! Thank you.

Code:
Code:
command /wntimego:
    usage: /wntimego
    aliases: /wntg
    trigger:
        if doDaylightCycle is false:
            make console execute command "/gamerule doDaylightCycle true"
            broadcast "<green>Time has been started by <white>%player%<green>."
        else:
            message "<red>Time was already passing." to player

Error:
Code:
can't understand this condition: 'doDaylightCycle is false' (wntime.sk, line 5: if doDaylight cycle is false:')
 
With MundoSK you should be able to read the value of a gamerule:

Documentation: https://skripthub.net/docs/?id=1738
MundoSK: https://forums.skunity.com/resources/mundosk.69/

or actually much better, you should use skript-mirror:
Code:
import:
    org.bukkit.World

command /test:
    permission: *
    trigger:
        set {_val} to world.getGameRuleValue("doDaylightCycle")
        send "%{_val}%"
with skript-mirror you can also change the gamerule value without using commands (commands looks awful in skript)
Code:
world.setGameRuleValue("doDaylightCycle", "true")

skript-mirror: https://forums.skunity.com/resources/skript-mirror.254/

I found the bukkit gamerule command and used it for the solution:
https://github.com/Bukkit/Bukkit/bl...kit/command/defaults/GameRuleCommand.java#L28
 
Last edited:
I can't do it then - explains why my searching drew a blank, lol.
Thanks for your help.
[doublepost=1590692625,1590691591][/doublepost]Found something ( https://forums.skunity.com/threads/stopwatch-help.11726/ ) that might be a way forward for me. Can I adapt this to use MC time?

Code:
every 0.2 seconds:
   if {isRunning} is true:
      add 0.2 to {time}
 
on event 1:
   set {time} to 0
   set {isRunning} to true
 
on event 2:
   set {isRunning} to false
   message "Ran for %{time}% seconds!"
 
Status
Not open for further replies.