• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
  • entries
    707
  • comments
    1173
  • views
    432772

Scribe scripting library

Sign in to follow this  
Followers 0
Programmer16

592 views

One of the projects I have always wanted to do is create a scripting language, but I have always failed horribly. My most recent attempt was kind of a mix of success and failure. The initial goals were to create a high level syntax (something similar to BASIC) and create a low level language (basically straight op codes; kind of like a simplified assembly.)
I meant to start out implementing the low level version first, but this didn't pan out how I wanted to and I ended up with a more BASIC-esque language. However it is working wonderfully, so I kept it and dubbed it Scribe 1.0. Currently it supports most of your basic features:
- Arithmetic operations
- Conditionals (if, elseif, else)
- Loops (loop, yield)
- Variables (booleans, strings, and numbers)
- Commands
- Labels

I achieved many of the goals that I wanted to, so I'm quite happy: it runs properly on both Windows and Android (and should hopefully , it runs decently (I haven't done any optimizations yet), it doesn't have any built in commands (so no sandboxing needed), and it is easily extendable (I am creating some packages that come with the library that provide some core functionality; they have to explicitly be registered though.)

I'm planning on eventually open-sourcing it, but I want to get it a little more stable and clean it up some first. Anyway, here is Tic Tac Toe written with Scribe and using the Console package:// Initialize the boardclear_board:@board11 = ' '@board12 = ' '@board13 = ' '@board21 = ' '@board22 = ' '@board23 = ' '@board31 = ' '@board32 = ' '@board33 = ' '@playerToken = 'x'@errorMessage = ''game_loop:Console.ClearConsole.SetTextColor RedConsole.WriteLine @errorMessageConsole.SetTextColor WhiteConsole.WriteLine ' 1 2 3'Console.WriteLine ' 1 ' @board11 | @board21 | @board31Console.WriteLine ' -+-+-'Console.WriteLine ' 2 ' @board12 | @board22 | @board32Console.WriteLine ' -+-+-'Console.WriteLine ' 3 ' @board13 | @board23 | @board33Console.WriteLine ''// Check win conditionsif @board11 != ' ' && @board11 == @board21 && @board11 == @board31// Horizontal row 1@winner = @board11goto game_overelseif @board12 != ' ' && @board12 == @board22 && @board12 == @board32// Horizontal row 2@winner = @board12goto game_overelseif @board13 != ' ' && @board13 == @board23 && @board13 == @board33// Horizontal row 3@winner = @board13goto game_overelseif @board11 != ' ' && @board11 == @board12 && @board11 == @board13// Vertical column 1@winner = @board11goto game_overelseif @board21 != ' ' && @board21 == @board22 && @board21 == @board23// Vertical column 2@winner = @board21goto game_overelseif @board31 != ' ' && @board31 == @board32 && @board31 == @board33// Vertical column 3@winner = @board31goto game_overelseif @board11 != ' ' && @board11 == @board22 && @board11 == @board33// Diagonal top left to bottom right@winner = @board11goto game_overelseif @board31 != ' ' && @board31 == @board22 && @board31 == @board13// Diagonal top right to bottom left@winner = @board31goto game_overif @board11 != ' ' && @board12 != ' ' && @board13 != ' ' && @board21 != ' ' && @board22 != ' ' && @board23 != ' ' && @board31 != ' ' && @board32 != ' ' && @board33 != ' '@winner = ''goto game_overConsole.WriteLine 'Current player: ' @playerTokenConsole.Write 'Choose a column [1-3]: '-- Console.ReadLine playerColumnConsole.ReadKeyChar playerColumn falseif @playerColumn != '1' && @playerColumn != '2' && @playerColumn != '3'@errorMessage = 'You must enter a value of 1, 2, or 3.'goto game_loopConsole.WriteLine ''Console.Write 'Choose a row [1-3]: '-- Console.ReadLine playerRowConsole.ReadKeyChar playerRow falseif @playerRow != '1' && @playerRow != '2' && @playerRow != '3'@errorMessage = 'You must enter a value of 1, 2, or 3.'goto game_loop// Set player nodeif @playerColumn == '1' && @playerRow == '1'@board11 = @playerTokenelseif @playerColumn == '2' && @playerRow == '1'@board21 = @playerTokenelseif @playerColumn == '3' && @playerRow == '1'@board31 = @playerTokenelseif @playerColumn == '1' && @playerRow == '2'@board12 = @playerTokenelseif @playerColumn == '2' && @playerRow == '2'@board22 = @playerTokenelseif @playerColumn == '3' && @playerRow == '2'@board32 = @playerTokenelseif @playerColumn == '1' && @playerRow == '3'@board13 = @playerTokenelseif @playerColumn == '2' && @playerRow == '3'@board23 = @playerTokenelseif @playerColumn == '3' && @playerRow == '3'@board33 = @playerToken// Change playerif @playerToken == x@playerToken = oelse@playerToken = x@errorMessage = ''goto game_loopgame_over:if @winner == ''Console.WriteLine 'The game is a tie!'elseConsole.WriteLine @winner ' has won the game!'Console.Write 'Play again? [Y/N]: 'Console.ReadKeyChar playAgainChoice trueConsole.WriteLine ''if @playAgainChoice == 'y' || @playAgainChoice == 'Y'goto clear_board
Now I'm off to implement a few more packages (arrays for one lol) and do a little optimization. I've attached the little bit of documentation I've written up in case anyone is interested.

[edit]
For the curious, here is the C# code to run the above: using Scribe; namespace TicTacToe{ class Program { static void Main(string[] args) { var virtualMachine = new VirtualMachine(); Scribe.Packages.Console.Register(virtualMachine); var thread = virtualMachine.LoadFile(@"C:\Users\Public\tictactoe.scribe"); thread.Start(virtualMachine); while(thread.IsRunning); } }}
I also updated the game's code above so that it allows you to replay without the console closing.

[edit]
Apparently at some point I switched from loop to while. Makes sense seeing as how that is what is used in most languages, but I don't quite remember doing so. I'll have to update the document to reflect this.

[edit]
Here is another example game, Guess the Number. This one includes use of the new Array package: // -------------------------------------------------------------------------// An implementation of Guess the Number written on the Scribe scripting// library.// Written by Donny Beals - February 28th, 2013// Copyright (C) Beals Software 2013// ------------------------------------------------------------------------- initialize:Array.Create numbersGuessed 10 true@choiceMessage = ''Random.NextInRange numberToGuess 1, 10 game_loop:Console.Clear @index = 0Array.Count numberOfGuesses @numbersGuessed Console.Write 'Numbers guessed: 'while @index < @numberOfGuesses Array.GetValue arrayValue @numbersGuessed @index Console.Write @arrayValue ' ' @index += 1Console.WriteLine '' Console.WriteLine @choiceMessageConsole.Write 'Choose a number from 1 to 9: 'Console.ReadKeyChar playerChoice false if @playerChoice != '1' && @playerChoice != '2' && @playerChoice != '3' && @playerChoice != '4' && @playerChoice != '5' && @playerChoice != '6' && @playerChoice != '7' && @playerChoice != '8' && @playerChoice != '9' @choiceMessage = 'You must enter a valid number from 1 to 9.' goto game_loop if @playerChoice < @numberToGuess @choiceMessage = 'Your guess is too low.' Array.AddValue @numbersGuessed @playerChoiceelseif @playerChoice > @numberToGuess @choiceMessage = 'Your guess is too high.' Array.AddValue @numbersGuessed @playerChoiceelse goto game_over goto game_loop game_over:Console.WriteLine ''Console.WriteLine 'You guessed the number (' @numberToGuess ')' Console.Write 'Play again? [Y/N]: 'Console.ReadKeyChar playAgainChoice trueConsole.WriteLine ''if @playAgainChoice == 'y' || @playAgainChoice == 'Y' goto initialize

0
Sign in to follow this  
Followers 0


2 Comments


Awesome great work. I really like the syntax of your scripting language it is very clean. Reminds of the simplicity of assembly without the annoying bits. Thumbs up.
1

Share this comment


Link to comment

Awesome great work. I really like the syntax of your scripting language it is very clean. Reminds of the simplicity of assembly without the annoying bits. Thumbs up.

Thank you! That is pretty much what I was going for, so I'm glad it turned out properly. There are still quite a few major issues with the core mechanics that I need to address before it can really become viable for anything. I'm planning on using it going forward though, so hopefully I'll be able to round it out to something useful lol. The ultimate goal is an easy to use scripting language with simple threading support which compiles down to bare op-codes/expressions ala MonoGame's content system (which also means cross-platform support between Windows, Android, iOS, Mac, and Linux.)

 

Thanks again for the comment, I appreciate it!

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now