Preprocessor Directives and file paths, for different platforms?

I am a bit unclear as far as preprocessor directives, i.e. if I don’t want to manually change file locations in my scripts for iOS specific builds and or web builds to reference specific files OR web URL’s:
pseudo code:
files:
#if (ios)
var URL=“mywebURL.com/fileName
#if (my_web_regular_apache_Server)
var URL ="(localhost)/fileName"

Thanks!

Steve

Preprocessor directives? Methinks you have a background in C++! :wink: So you have a couple of examples there: detecting if you’re running on iOS and detecting if you’ve running from a certain URL (localhost in the example you give). Let’s take them in turn.

For detecting iOS, check out this StackOverflow thread.

For detecting if you’re running from localhost, check out this StackOverflow thread. So you’d essentially look for localhost in that window.location.href (or do a regex if you’re really thorough!) :smile:

1 Like

Thanks!
Yup Borland C++, I don’t know what else to call them. Awesome!

…script compilation order is a bit grey to me as of this moment because I intentionally avoided web development for the last 10 years - I had dot.com PTSD. :moneybag: :money_with_wings: :cry:

You might want to read this page in the User Manual on script load order:

http://developer.playcanvas.com/en/user-manual/scripting/script-priorities/

This is useful if your project includes third party scripts like JQuery, say, that have to be loaded before anything else.

1 Like

great! Thanks looking at that now…I was using wrong verbage in searching for that, “script priority” instead of “script compilation order”.