How to access properties on initialize?

I’m sure this is a basic question for more experienced plugin dev, but I’m a bit stumped.

I have a field called “Time Delay”. I essentially want users to be able to set the time before a popup appears on screen.

The obvious thing I tried was to set a variable in the “initialize” function that accessed the field I created.

But this is not possible. You cannot access properties in the initialize function.

How can you initially set a variable based on a field the user can set a custom value for?

Unfortunately you can’t access properties on initialize.

What I do is – on the update function – I create a do once if to mimic the initialize function.


Thanks @rico.trevisan!

Am I correct in saying that’s what you’re doing in your Code Syntax Highlighter plugin?

1 Like

You can reate it in initialize with display:none and show up in update.

1 Like

thanks @vladimir.pak ! Do you have any open-source plugins where you do this?

I had a look through the code for your Splash Screen plugin but couldn’t quite figure out where you’re applying the principle

Nope, I don’t have one. lf you’d describe in more details what you’re trying to achieve, maybe I could say something more specific for you case.

If it helps, you should be able to set a global variable inside Update, then reference it inside Initialize. = properties.time_delay;

Other than that, try and define all property values inside update, and remember when something changes, then that Update block will rerun.

If you do need to take action on it only once and you decide to put it inside Update, then do as Rico suggested and wrap into something like this…

If (! {
// do what you need here = true;

1 Like

You don’t exactly need a plug-in for this. You can do it with the “do every 5 seconds” set seconds to however many you want. Run only once.

Plug-in would make it a bit easier though.