A Development Tutorial: Chapter 11

From FOnline: Reloaded Wiki
Jump to: navigation, search
A Development Tutorial: Chapter 11
Get the developer tools and try building new content for this game!
Season All Seasons
Status Progress Stopped
Completion 75%
Authors Slowhand
This Chapter 11: Setup of Scripting Environment
More Chapters Title Page
Development Kit Setup
Making Maps
The World Map Editor
NPC Dialogues
Create a 2-Map Zone
Monsters, Loot, and Scripts
Tracking Quest Progress
Scenery Scripts
Dialogue-to-Quest Location
Chapter 10
The Scripting Environment
Understanding Quest Scripts
Chapter 13
Dialogue: The "SAY" Menu
Chapter 15
Lockpick Cooldown
Repeatable Locations
Floating FA Text
Roulette Game
Dialogues vs Scripts
Simple Kill Quest
Chapter 21
Mysterious Stranger Perk
Perk Installation
Black Jack Game
Black Jack Installation
Sound Effects
Pro Tips
Notes {{{notes}}}

Setting up the scripting environment.

Scripting from Notepad after second day, is no fun. Before touching more of the scripting topics, our first task is to set up a scripting environment, which helps and speeds up our work. We will configure an IDE (Interactive Development Environment) for this, which will replace the text editor we used to write and read scripts. There are many free IDE's out there. I tried a few, and here are the results:

  • Notepad++:
    • This is not an IDE but an advanced text editor. (not the only or best one, but most popular)
    • Can be set up for highlighting and functions list.
    • I assumed that code completion would not work, so I did not bother with it much, we skip this one.
  • Codelite:
    • This is a lightweight IDE, which would have been perfect for us, because scripting this game does not require complex IDE's.
    • Highlighting worked, fast and easy.
    • Code completion did want to become fully functional. If a header file was named .fos, the code completion did not use it.
  • Codeblocks:
    • This is a more complicated IDE than Codelight, and I only choose it over Codelite because all featured required worked.
    • Except compiling because I did not want to go into that, maybe some other time.
  • Microsoft Visual Studio 2008:
    • The intellisense file as I saw was originally made for this.
    • I did not try to set it up, but some other devs did, so it must work. You can give it a try if you want.

Step by Step - Configuring Code Blocks for scripting FOnline: Reloaded

  • Download Codeblocks
  • Set up Codeblocks:
    • When the program starts at first time, it will ask for a compiler of your choise. Just choose the one that is on top.
    • Set syntax highlighting: Settings->Editor..->Syntax highlighting->File masks - add "*.fos" to the list. (Make sure u add to C++)
    • Set code completion: Settings->Editor..->C/C++ parser (adv) - add "fos" to both header and source files.
  • Create new project:
    • File->New->Project.. - Select Empty Project.
    • Enter title (name of the project) and for location select a temporary location. (not the server\scrips folder)
    • Select a compiler: Scroll to bottom of the list and select: No compiler.
    • Add a new source file:
      • File->New->File..->Empty File->Go Select file name and path, for testing leave it in default folder and name it "test.fos"
      • Add the file to active projects and into one of the build types and press finish.
    • Type into the empty file: "Cri" and press Ctrl+Space. Nothing should happen.
    • Add more files to your project:
      • Click your project, Add files.. and find your intellisense file: "Server\scripts\Solution\intellisense.h"
      • Add another file. This time let it be "Sever\scrips\_vals.fos".
  • Test the setup:
    • In test.fos press Ctrl+Space again while having the cursor at the end of "Cri". This time a helping popup window should appear, giving an option to select "Critter".
    • In test.fos in a new line type: "SPE" and press Ctrl+Space. It should bring up a list of some SPECIAL_XX defines.
    • If this happened so far, we are done, the code-completion works.
    • Also, whenever editing ".fos" files, the code highlighting/coloring should be in effect, you can check this by seeing some of the text in different color.
  • Few more hints:
    • When writing scripts, keep the project files out of "Server\script", but make the new script files in that folder.
    • To build the script file, use the compile.bat as before.
    • Add missing keywords:
      • Settings->Editor->Syntax highlighting->Keywords
      • Add missing keyword at the end of the list, using space for separator. (f.e: " uint")
    • This is how I use it:
      • Create a new project, save the project files anywhere.
      • Add the intellisense file.
      • Add files recursively from the "server\scripts" folder, but not all of them. Use Wildcard select and type "*.fos".
      • All scripts should be loaded and fully functional. Use this to go throw scripts instead of notepad.
      • Compile from command line, with compile.bat.

This is how my IDE looks like when scripting:

(image soon)