Jump to content

Oni (folder)/GameDataFolder/IGMD/global: Difference between revisions

m
no edit summary
mNo edit summary
Line 3: Line 3:


But you can create it and use it and it's actually very rewarding. It's a very special folder.
But you can create it and use it and it's actually very rewarding. It's a very special folder.


==What's so special about it?==
==What's so special about it?==
The global folder is visible from every one of Oni's levels. Rather, the scripts (files with extension BSL) in the global folder are always processed at the same time as the level logic of a particular level, when that particular level is loaded.
The global folder is visible from every one of Oni's levels. Rather, the scripts (files with extension BSL) in the global folder are always processed at the same time as the level logic of a particular level, when that particular level is loaded.
==How do I use it?==
==How do I use it?==
Is there really a short way to describe it? Oh well...
Is there really a short way to describe it? Oh well...
Line 19: Line 22:


No. You use the global folder
No. You use the global folder
==<tt>func pre</tt>==
==<tt>func pre</tt>==
Go to the global folder and create a file called <tt>pre.bsl</tt>. Open it and give it the following content :
Go to the global folder and create a file called <tt>pre.bsl</tt>. Open it and give it the following content :
Line 30: Line 35:
  }
  }
This is an inline call to the <tt>pre</tt> function we have just set up in the global folder. The function <tt>pre</tt> is "globally recognized".
This is an inline call to the <tt>pre</tt> function we have just set up in the global folder. The function <tt>pre</tt> is "globally recognized".
===Why call it <tt>pre</tt>?===
===Why call it <tt>pre</tt>?===
Because everything in <tt>func main</tt> is level-specific settings and/or logic, so if you want something to happen exactly the same way every time you load a level, the only place to add that something is at the very start of <tt>func main</tt>, that is, ''before'' all the level-specific content. Which is why it's called "pre".
Because everything in <tt>func main</tt> is level-specific settings and/or logic, so if you want something to happen exactly the same way every time you load a level, the only place to add that something is at the very start of <tt>func main</tt>, that is, ''before'' all the level-specific content. Which is why it's called "pre".