Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: using interval with onTime no longer work #4841

Closed
4 of 5 tasks
Sajgon opened this issue Nov 18, 2024 · 0 comments · Fixed by #4846
Closed
4 of 5 tasks

[Bug]: using interval with onTime no longer work #4841

Sajgon opened this issue Nov 18, 2024 · 0 comments · Fixed by #4846
Labels
bug An issue describing unexpected behavior of code needs-confirmation not confirmed by a developer yet

Comments

@Sajgon
Copy link

Sajgon commented Nov 18, 2024

By submitting this bug issue, you agree to the following.

  • This is a bug in the software that resides in this repository, and not a support matter (use https://otland.net/forums/support.16/ for support)
  • This issue is reproducible without changes to the C++ code in this repository
  • This bug has not been resolved in master branch
  • There is no existing issue for this bug already

Does this bug crash tfs?

no

Server Version

1.7 (Master)

Operation System

all (listed below)

OS Description

No response

Bug description

using interval with onTime no longer work

Possible Pull Requests which are to blame

Steps to reproduce

Example:

  1. In the script world_light.lua see the value of interval (10000), which equals to 10 seconds
  2. The script should run every 10 seconds, but isn't
  3. The reason is because onTime has a type in compat.lua, the interval isn't set. See the code below, if type is used interval isn't.
} else if ((attr = node.attribute("type"))) {
		const char* value = attr.value();
		if (caseInsensitiveEqual(value, "startup")) {
			eventType = GLOBALEVENT_STARTUP;
		} else if (caseInsensitiveEqual(value, "shutdown")) {
			eventType = GLOBALEVENT_SHUTDOWN;
		} else if (caseInsensitiveEqual(value, "record")) {
			eventType = GLOBALEVENT_RECORD;
		} else if (caseInsensitiveEqual(value, "save")) {
			eventType = GLOBALEVENT_SAVE;
		} else {
			std::cout << "[Error - GlobalEvent::configureEvent] No valid type \"" << attr.as_string()
			          << "\" for globalevent with name " << name << std::endl;
			return false;
		}
	} else if ((attr = node.attribute("interval"))) {
		interval = std::max<int32_t>(SCHEDULER_MINTICKS, pugi::cast<int32_t>(attr.value()));
		nextExecution = OTSYS_TIME() + interval;
	} 

Code to reproduce the issue:

function event.onTime(interval)
	console.log("🚀 ~ WorldLight onTime:", onTime)
	if not defaultWorldLight then
		return true
	end

	local worldLightColor, worldLightLevel = Game.getWorldLight()
	local level = calculateWorldLightLevel()
	Game.setWorldLight(worldLightColor, level)
	return true
end

event:interval(10000) -- 10 seconds
event:register()

Actual Behavior

The script is only ran once on startup.

Expected Behavior

The script should run every 10 seconds.

Backtrace

No response

@Sajgon Sajgon added bug An issue describing unexpected behavior of code needs-confirmation not confirmed by a developer yet labels Nov 18, 2024
@github-project-automation github-project-automation bot moved this to Backlog in TFS 1.8 Nov 18, 2024
@ArturKnopik ArturKnopik mentioned this issue Nov 20, 2024
3 tasks
@ghost ghost linked a pull request Nov 24, 2024 that will close this issue
3 tasks
@ghost ghost closed this as completed in #4846 Nov 24, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in TFS 1.8 Nov 24, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing unexpected behavior of code needs-confirmation not confirmed by a developer yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant