PawnProgrammingNotes

From WowWiki
Jump to navigation Jump to search

This "sub wiki" is being written (initially, at least) by me, ratcliffe. I have been doing software development for 30+ years in VB.NET, C#, C++ and Objective C. This is my first experience with Pawn and of course with programming the WOWCube. Feel free to drop me a DM in the WOWCube Discord if I've gotten anything wrong, or you can suggest a better way to do something, or want me to try to cover a specific topic. I'm going to be making notes here as I build a basic RPG for the WOWCube.

This is just a scaffolding for the moment, I will be fleshing out the listed items over the next few days.

I also need to work to keep some terminology straight so I may change these terms a bit soon

cubelet or module
one of the eight physical small cubes, each with three screens, in the WOWCube
screen
one of the three screens on a cubelet
messaging
the technique supported in the API to send a small packet of information to one or more other cubelets

Here are the current topics in place or coming soon!

  • A few Pawn Language "gotchas"/reminders
    • Statements do NOT have to be terminated with ";" (but I usually do it anyway out of habit)
    • Declare variables with "new" (not "var", etc.)
    • You can use the built in words "true" and "false" to represent a boolean value and test for it with "if (x) { }" which will execute the code in braces if x is true
    • Arrays can be up to three dimensions and indexes start at 0, e.g. new x[8] defines a new array with 8 elements indexed 0..7 inclusive
    • Use "==" (not "=") to check for equivalence in an "if" statement
    • Use "!=" instead of "<>" for "not equal to"
    • You can enter numbers in hex by prefixing with 0x e.g. "0xFFFF0000" is used as an ARGB value for the color red
    • "if" statements with more than one condition require an extra set of () around the whole expression e.g. "if ((x==1)||(x==2)) {}"
    • function definitions are not prefixed with "f" or "func" or "function" e.g. "abs(x) {if (x>=0) {return x} else {return -1*x}}" is a valid function definition
    • you can begin a comment on a line by itself or at the end of a line with "//". Use "/* .... */" for block comments ... block comments CANNOT be nested
  • A few Visual Studio Code "gotchas"/reminders
    • Under circumstances that are not yet entirely clear to me, Visual Studio Code may sometimes open the parent folder of the folder containing the actual project, this may occur mainly or only when using "Create Example Project" from the samples, inside a new folder you have just created. Symptom is errors saying "could not find the task", e.g. when you try to build. The fix is to use the File, Open Folder menu item and then select the folder containing the actual project (that folder will have subfolders named .vscode, assets etc.)
    • So far, it doesn't appear that Visual Studio Code has an automatic feature to fix indenting of all of your code so that it is consistent
  • Remembering that the WOWCube is "eight processors all running the same code"
  • ON_Tick() vs ON_Render()
    • The "lifecycle" of a running Pawn application will repeatedly call ON_Tick() followed by ON_Render(). You should generally put all logic that will set the current/new state of the objects that will appear on the cubelet's screens in ON_Tick(), and then use ON_Render() only to do GFX_xxx calls to display the objects on the screens.
  • You have to render everything on a screen at once!
  • Physical cubelets and "virtual" mapping to them
  • Dealing with differing orientation of the screens
  • Putting text on a screen
  • Basics of developing a simple map with tunnels
  • The magic of TOPOLOGY_getAdjacentFacelet()
  • How to handle moving from one screen to another (on the same or a different cubelet)

  • Tricks when using the Emulator