PopScript for NoteTab - V1.00 ------------------------------- CDplayer 8 February 2006 Section 1 - Installation ------------------------ 1. Get and install Notetab NoteTab is a free program available from http://www.notetab.com There are no ads or other malware in the program. It does check for updates once a month but this can be disabled if you wish. Download the EXE package for NoteTab Light 4.95 and follow the instructions to install the program. 2. Configure NoteTab NoteTab works pretty well straight out of the box, but there are a few things we can do to simplify things. Close the three open documents (File/'Close all documents') - after reading them if you like! Go to View/Options Goto Documents and make sure that Wordwrap is unchecked and Auto-indent is checked. Goto Tools and make sure that Indent with tabs is *not* checked Goto Clipbook and check 'Single click to execute' Click on 'Ok' to exit Using Windows Explorer (or My Little Computer), navigate to the folder containing the Notetab libraries (normally C:\Program Files\NoteTab Light\Libraries). Create a new sub-folder called 'Old libraries' and move all the files with the extension '.clb.' into it. (Tip: Click on the 'Type' column header first - then they'll all be in one block.) 3. Instal Popscript libraries Unzip all of the files in the download into the 'libraries' folder. Section 2 - How to use it ------------------------- Ok, so you've got the program installed and configured so let's write some code. Start with Notetab running and a blank document. At the top left of the screen, you should see a box with 'Commands' written in it, and underneath a series of items, starting with 'Main script commands' in red. This is the current 'clip' library. 'Commands' is the title, and each of the items underneath corresponds to a section of code which you can insert into the coding page. The tabs across the bottom of the screen (DO Commands, DO State Cmds etc) correspond to other libraries, each with a subset of the PopScript commands. You can switch between them by clicking on the tabs. Let's start a script from scratch. With the 'Commands' library selected, click on 'Script framework'. This will throw up a dialog box where you can fill in the details of the script you are writing. When you're done, click ok, and the editor will write the outline code and a commented header containing the details you entered - self-documenting code! It will leave the cursor in the section which will be triggered on the first game turn - the initialisation code. You can enter all the commands manually (or by using the other clip libraries) but for now, click on 'insert initialisation template'. Job done! This code section is stored in the file PopInit.dat which you copied into the libraries folder. It's just a text file, so you can edit it to get the setup options the way you want them every time you start a new script. Let's open it and have a look. Click File/Open, navigate to the libraries folder and open PopInit.dat. Notice that your code file is also still open - Notetab can keep dozens of files open at the same time. And best of all, when you close the program it remembers the tabs, so they're all still there next time you fire it up. So you can have PopInit.dat always available in the background, and make changes as and when needed. If this is your first exposure to PopScript, you're likely going to need a little help, so click on the 'help' command in the 'Commands' library. This command does make some assumptions. It assumes that you are using Internet Explorer, that IE is avalable from all folders and that the help file is in the default location. But don't worry if it doesn't work, we can fix it easily enough because the clip libraries are text files, and we're working in a text editor! Try right-clicking on the Help entry. Then, from the menu, select 'Edit clip'. The editor will open a new page with the script commands for that clip displayed. You can substitute 'Iexplore.exe' with the equivalent file name for Firefox, or Opera or Lynx (well, maybe not Lynx ;-) and it should work just as well. If not, try including the full path. Similarly, if your libraries folder is in a different location, you can change that too. Save the page, then try hitting 'Help' again. The help page has a lot of information in it, but it is still a work in progress - there are a lot of gaps, and probably some mistakes, but it will get you started. We'll keep updating it as we discover more. I'm not going to try to give a full PopScript tutorial here, but I will run you through creating an attack, probably one of the most important actions. Go back to the code file we were creating and set the cursor at the end of the line between the two comment lines marking the start and end of the Main Script Code Section. This should be at about line 100 (the line number counter is in the frame at bottom left). We need to insert an EVERY command here. Basically, the entire code is executed on each game turn, and there are around 8-10 game turns per second. We therefore need to put code into sections where it will be executed less often. The EVERY command does this. So: EVERY 256 { //Code here } will execute the code only once every 256 game turns (around 25 seconds). There is also provision for an offset, which shifts the execution earlier (to allow fine control of timing). So: EVERY 256 56 { //Code here } will also execute every 256 turns, but the first period is shortened by 56 turns to 200. Thus the second EVERY statement will always trigger 56 turns earlier than the first. Anyway, we need an EVERY statement. Click the Every entry in the library and it will ask you for a title (for a leading comment), the Interval and the Offset. Enter "Hello World" for the title (it's compulsory for a first program, I'm afraid), 512 for the interval and 0 for the offset. (Intervals have to be a power of two.) Now click ok. The EVERY command will have been inserted, and the cursor left at the end of the line ready for the next command. Inserted code should always indent itself correctly, provided that you start from the correct column position in a blank line. We don't want this attack to happen too early in the game, so lets put in an IF statement. Click the If entry in the library. For value1, enter INT_GAME_TURN, for the condition click on '>' and for value2 enter 5000. This will ensure that the first attack happens after around 10 minutes and about every 50 seconds thereafter. Click ok and again the command is inserted and the cursor left in position ready for the next command. For the attack itself, we'll do a troop attack on the human player's huts (that's Blue). For an attack to take place, we need to set some initial parameters. Click on the 'DO state Cmds' tab at the bottom of the page to load that library and click on 'State auto attack'. Select On and click OK. Press Enter to move to the next line in the coding page. Select the 'Internal Attrs' tab and click on 'Max attacks' then enter 999 and click ok. Press enter to move to the next line. With those done, we can construct the ATTACK statement itself. Move back to the 'DO Commands' library and click on 'Attack'. First select Blue as the target, then 6 as the number of followers and Building type as the objective. Next you can select 'Small hut'. We want to inflict maximum damage (a kamikazi attack) so enter 999 for the damage and then select 'No spell', as this is a troops-only attack. Select 'No spell' on the next two items as well, and accept the defaults on the vehicles page. Finally, accept the defaults of -1 for the Markers page. Et voila! The completed attack command is inserted. And that's really all there is to it. All the commands and variables in PopScript are accessible in the libraries, so there is no need to try and remember syntax or spelling and the only typing needed will be for entering variable names and comments. Once your code has been entered, you need to compile it. This can be done using ALACN's World Editor (Edit/AI script/script from the main menu). (He has promised us a command-line driven version shortly, which will allow us to compile directly from within NoteTab.) The compiled file then needs to be copied to the levels folder of your Populus installation (backup first!). You can then test run it in the game itself. Run Populous and load the level which the script is associated with. (You can find out which level uses which script by again using the World Editor, going to Edit/Header/General.) Once Populous is running, you can switch to NoteTab by pressing alt-tab and you can switch back using 'Switch to Populous' from the Commands library. With a little bit of ingenuity, we should be able to run the entire development environment from within Notetab! That should be enough to get you started. There are extensive help files for NoteTab itself which you may also find useful for other things (it's an excellent HTML editor). I will be issuing updated versions of these files as we discover more and I find better ways of doing things. In the meantime - have fun and let's get coding! CDplayer 8 February 2006