It is currently September 20th, 2020, 7:45 pm

Require?

Discuss the use of Lua in Script measures.
User avatar
BinaryInk
Posts: 7
Joined: November 24th, 2009, 12:28 am

Require?

Post by BinaryInk »

Does Require work within Rainmeter? I want to modularize some functions and ideally employ some form of polymorphism, but this task is largely impossible without "Require."

So, for instance I have my main file

main.lua

Code: Select all

function WriteThis()
	return print("WriteThis")
end
and my file that I want to have access to WriteThis() and run it on initialization...

Code: Select all

mainClass = require "mainClass"

function Initialize()
	mainClass.WriteThis()
end
This should in theory work, but it always errors out saying that "require" is a nil value. I've tried "Require" as well to no avail. I have also tried changing the parameter of require to the full path with extension, just in case.

EDIT: Fixed typo in code.
User avatar
jsmorley
Developer
Posts: 21372
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Require?

Post by jsmorley »

No, I"m sorry, but require doesn't work in the Rainmeter implementation of Lua.
User avatar
BinaryInk
Posts: 7
Joined: November 24th, 2009, 12:28 am

Re: Require?

Post by BinaryInk »

I'll assume that meant doesn't. Unfortunate. I think I can work around it a bit with measures, but it's a little messier than I had initially planned.

Either way, thanks!