LaurierCS / PHI-TextBasedGameEngine

A text based game engine for creating games
4 stars 1 forks source link

Scripting Language* #45

Open jbheard opened 3 years ago

jbheard commented 3 years ago

* Or at least something like a scripting language

I doubt this project will ever grow large enough to warrant using an entire language for it (I hope I'm wrong), so we likely don't need anything like Lua, or letting game devs write their own python. But I think it is necessary to have some kind of customizable behavior to make the engine effective.

Some of this is already in the docs for items, but this will also be a necessity for Room objects since something happens when a player makes a choice.

For example, suppose your room has the option Pick up potion. The game dev needs some way to add a potion to the user's inventory, and then remove that option from the room.

Something a bit more complex is using variables. For example, the user wants to keep track of how many times a player has visited a specific room. Variables could be represented as GameObjects, but we need some kind of typing system (unless all variables are integers? strings would get messy, and floats can probably be avoided).

jbheard commented 3 years ago

Some more thoughts on this; the parsing language could have simple rules:

  1. One command per line. Define a variable, instantiate an item/enemy/something, etc.
  2. Commands must map 1-to-1 with existing functions. e.g. GameContext.destroy(obj) is called as destroy obj

With these 2 rules in place the language becomes similar to assembly, and is exceedingly simple to write an interpreter for.