Skript icon indicating copy to clipboard operation
Skript copied to clipboard

timespan comparison

Open Emma9102 opened this issue 1 year ago • 2 comments

Skript/Server Version

Skript version 2.8.7
Customize Minecraft's mechanics with simple scripts written in plain English sentences.
Website: https://skriptlang.org
Authors: Njol, Mirreski, SkriptLang Team and Contributors

Server version 1.19.4

Bug Description

So there was a timespan comparison in my script but it doesn't work as expected. I have a variable that stores dates, and i check it with 'time since' effect and compare it with a timespan as i will upload a screenshot. Event though the time exceed given timespan, it goes for other way.

Expected Behavior

It should be able to compare it correctly.

Steps to Reproduce

This is the code:

/command /time: trigger: if time since ({restourant hirechef date::%player%} ? 6 hours ago) >= 6 hours: send "its exceed 6 hours, %time since {restourant hirechef date::%player%}%" else: send "its not exceed 6 hours. %time since {restourant hirechef _date::%player%}%"

Also tried 'is greater than or equal to' effect and tried without the '? 6 hours ago' part. No change.

image

Errors or Screenshots

This is what is says after using the command i stated above. image

Other

No response

Agreement

  • [X] I have read the guidelines above and affirm I am following them with this report.

Emma9102 avatar Jun 21 '24 11:06 Emma9102

The variable is set to a timespan, not a date. The time since expression works on dates, not timespans.

sovdeeth avatar Jun 21 '24 12:06 sovdeeth

Nevermind i really need to get my eyes checked, I didn't see the time since in the message effect. My apologies.

sovdeeth avatar Jun 21 '24 12:06 sovdeeth

Can confirm this happens on latest dev/patch, although for me the cause is the otherwise.

command /test:
	trigger:
		set {_x} to 2 hours ago
		
		if time since {_x} >= 1 hour:
			send ">= 1 hour ago"
		else:
			send "< 1 hour ago"

returns >= 1 hour ago as it should, but

command /test:
	trigger:
		set {_x} to 2 hours ago
		
		if time since ({_x} ? 2 hours ago) >= 1 hour:
			send ">= 1 hour ago"
		else:
			send "< 1 hour ago"

returns <1 hour ago.

EDIT: seems to be fixed by adding parenthesis around the expression after the ?, so

command /test:
	trigger:
		set {_x} to 2 hours ago
		
		if time since ({_x} ? (2 hours ago)) >= 1 hour:
			send ">= 1 hour ago"
		else:
			send "< 1 hour ago"

works.

Efnilite avatar Jul 13 '24 22:07 Efnilite

dev/patch is not updated. dev/feature is

EquipableMC avatar Jul 13 '24 23:07 EquipableMC

dev/patch is not updated. dev/feature is

they are both updated, one has the latest patches and one has the latest features

Pikachu920 avatar Jul 14 '24 00:07 Pikachu920

Can confirm this happens on latest dev/patch, although for me the cause is the otherwise.

command /test:
	trigger:
		set {_x} to 2 hours ago
		
		if time since {_x} >= 1 hour:
			send ">= 1 hour ago"
		else:
			send "< 1 hour ago"

returns >= 1 hour ago as it should, but

command /test:
	trigger:
		set {_x} to 2 hours ago
		
		if time since ({_x} ? 2 hours ago) >= 1 hour:
			send ">= 1 hour ago"
		else:
			send "< 1 hour ago"

returns <1 hour ago.

EDIT: seems to be fixed by adding parenthesis around the expression after the ?, so

command /test:
	trigger:
		set {_x} to 2 hours ago
		
		if time since ({_x} ? (2 hours ago)) >= 1 hour:
			send ">= 1 hour ago"
		else:
			send "< 1 hour ago"

works.

ahhh it's parsing ({_x} ? 2 hours) ago and getting none because wrong type

sovdeeth avatar Jul 14 '24 00:07 sovdeeth