Displaying text from script onto screen
Hey All,
I hope you are doing well, I am currently working on an addition to a lens I am making which focuses on getting the current month and year and projecting it to the screen. I have figured out how to grab the current month and year but however am having trouble on how to project it?
I am currently working on an addition to a lens I am designing which focuses on displaying the current month and year (It will first be translated to a roman numerals) and projecting it to the screen. I have figured out how to grab the current month and year using moment.js which is
var whatisyear = moment().year()
var whatismonth = moment().month() + 1
However I am unsure on how to project this to the screen
If anyone knows it would be greatly appreciated.
Best regards,
Lachlan.
// -----JS CODE-----
//@input Component.Text TextObject
var whatisyear = moment().year()
var whatismonth = moment().month() + 1
var whatisday = moment().date()
function convertToRoman(num) {
var RomanToNum = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
XL: 40,
X: 10,
IX: 9,
V: 5,
IV: 4,
I: 1
};
var roman = "";
for (var key in RomanToNum) {
while (num >= RomanToNum[key]) {
roman += key;
num -= RomanToNum[key];
}
}
print(roman);
}
convertToRoman(whatisyear);
convertToRoman(whatisday);
function set() {
script.TextObject.text = String(roman)
}
This is currently what my script looks like, I am looking to take the output from "print(roman);" and displaying it onto the screen, is anyone sure of why it isn't working?
hi Lachlan
to show a text from script to screen
first add a screen text
then use a simple code to give it a value
// @input Component.Text mytext
script.mytext.text = anyvalue;
Cheers.
Hi,
change "script.TextObject.text = String(roman)"
to
script.TextObject.text = roman;
I use script.textobject.text = roman; and I get an error.
14:39:26.962 [Scenarium] ReferenceError: identifier 'roman' undefined
at [anon] (Script 3.js:44) preventsyield
Any ideas?
Hi,
Can you upload the project file to google drive?
solved :)