Jump to content

Need help working out the timer for home tele


Recommended Posts

Posted

When I home tele config 892 changes to what I'm assuming is some sort of game clock and I'm guessing its set up to either set that as what the clock currently is or what it needs to be before you can home tele again.

Does anyone know how to get a reference to what that clock currently would be?

Posted
38 minutes ago, dubai said:

I might be wrong but you could do something like:
If widget exists and contains message(int 1-20 minutes)

But another easy option could be to just store the time in memory from where you teleported and count down 20 mins?

I've never messed with the chat as widgets, I'll look into that. I usually use the onMessage() for anything having to do with chat. 

But I don't want to rely on storing it and having a timer because I'd worry about it not functioning as intended if I need to stop the script and start it back up for whatever reason.

Posted
15 minutes ago, Khaleesi said:

The time the last home teleport is saved in a config 892 if I remember correctly, so you can always check that config :)

Yeah, I got that much sorted out. I'm trying to figure out how to get whatever the current time is to compare it to the time that was set. I thought I found it but I can only figure out how to get my own system's time.

 

Posted

Here, taken from my quester :doge: 

	public int getSecondsLeftTeleportHome() {
		int lastTeleport = getConfigs().get(892);
		long lastTeleportSeconds = (long) lastTeleport * 60;
		Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(Duration.ofMinutes(30));
		Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
		return (int) remainingTime.getSeconds();
	}

 

  • Heart 2
Posted
6 hours ago, Czar said:

Here, taken from my quester :doge: 

	public int getSecondsLeftTeleportHome() {
		int lastTeleport = getConfigs().get(892);
		long lastTeleportSeconds = (long) lastTeleport * 60;
		Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(Duration.ofMinutes(30));
		Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
		return (int) remainingTime.getSeconds();
	}

 

Awesome, that got me squared away. Also taught me about 'Instant' so thanks for that too!

  • Like 1
Posted
13 hours ago, Czar said:

Here, taken from my quester :doge: 

	public int getSecondsLeftTeleportHome() {
		int lastTeleport = getConfigs().get(892);
		long lastTeleportSeconds = (long) lastTeleport * 60;
		Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(Duration.ofMinutes(30));
		Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
		return (int) remainingTime.getSeconds();
	}

 

Nice spoon 😉 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...