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

m
Line 31: Line 31:
  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 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 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".
 
===Why make it inline? (WARNING : EXPERT STUFF)===
===Why make it inline? (WARNING : EXPERT STUFF)===
Because in that case, it's as if the content of <tt>func pre</tt> got pasted at the start of <tt>func main</tt> which is perfectly OK for some purposes (like the <tt>dmsg "[r.Thank you for playing ][b.Oni][r.!]"</tt> call in the example above). Three things to consider :
Because in that case, it's as if the content of <tt>func pre</tt> got pasted at the start of <tt>func main</tt> which is perfectly OK for some purposes (like the <tt>dmsg "[r.Thank you for playing ][b.Oni][r.!]"</tt> call in the example above). Three things to consider :