Jump to content
  • 0
Sign in to follow this  
Shadow72

1.6(experimental build) Text scripting bug

Question

It seems you can't instantiate a instance of a custom class outside of the event functions. Doing so results in the error: Undefined variable "{0}". However you can instantiate a new copy of a class such as YVector3 outside of the event functions.

var x = new Test();
var p;
var v = new YVector3(0, 1, 0);

function onSwitchOn(triggerEntity) {
	p = new Test();
	YEntity.spawnEntity(YEntityType.get(35), 1, v, v);
	YDebug.localConsole(p.doSomething());
}

class Test {
	constructor() {}

	doSomething() {
		return "test";
	}
}
  • var x gives the undefined variable error when loading the script
  • var p has no errors and setting the variable in the onSwitchOn function gives no errors
  • var v has no errors
Edited by Shadow72

Share this post


Link to post
Share on other sites

1 reply to this bug / suggestion

Recommended Posts

  • 0
class Test {
	constructor() {}

	doSomething() {
		return "test";
	}
}

 

var x = new Test();
var p;
var v = new YVector3(0, 1, 0);

function onSwitchOn(triggerEntity) {
	p = new Test();
	YEntity.spawnEntity(YEntityType.get(35), 1, v, v);
	YDebug.localConsole(p.doSomething());
}

 

Hi,

you need to first declare your class before you try to use it.

Unfortunately due to a real bug this will not help you at the moment.

Thank you for reporting the bug.

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×