Skip to main content
edited body
Source Link
uliwitness
  • 1.2k
  • 1
  • 9
  • 12

Well, you have to essentially make your engine able to load logic from disk somehow. You could actually code that into your program, but more often people devise a data file format for these purposes.

What in end effect it boils down to is creating a very simple (and not necessarily turing-complete, and not necessarily text-form) programming language. That's why so many game developers just use a scripting language like Lua.

But what you really only need is to build the basic operations into your engine (e.g. spawn a monster, despawn a monster, show a dialog tree, move a monster, add a mission objective, resolve mission, whatever your game requires). Then you give each situation an event or trigger (like "monster killed" or "player inside" or "dialog choice selected").

Then build a data structure that can be used to describe each basic operation. In your on-disk representation of a level, save such a data structure for each event of every object. Whenever an event happens, load the data structure (probably an array of 'em) and do the things it describes.

Many games can get away with this. Some also need some sort of counter variables (plus increment/decrement commands), and maybe a conditional (easiest way to implement: Just give it a variable and a value to check it against, then have it trigger another event). If you're going beyond that, you might probably as well use a real scripting language.

As whatWhat you save the data structure as in the end doesn't really matter. You can use XML, stick it line-wise in text files, build a binary data structure, whatever you want.

Your data structure can be as easy as an int to describe the operation (i.e. 1 = spawn monster, 2 is despawn etc.), and two strings naming which objects to operate on.

Well, you have to essentially make your engine able to load logic from disk somehow. You could actually code that into your program, but more often people devise a data file format for these purposes.

What in end effect it boils down to is creating a very simple (and not necessarily turing-complete, and not necessarily text-form) programming language. That's why so many game developers just use a scripting language like Lua.

But what you really only need is to build the basic operations into your engine (e.g. spawn a monster, despawn a monster, show a dialog tree, move a monster, add a mission objective, resolve mission, whatever your game requires). Then you give each situation an event or trigger (like "monster killed" or "player inside" or "dialog choice selected").

Then build a data structure that can be used to describe each basic operation. In your on-disk representation of a level, save such a data structure for each event of every object. Whenever an event happens, load the data structure (probably an array of 'em) and do the things it describes.

Many games can get away with this. Some also need some sort of counter variables (plus increment/decrement commands), and maybe a conditional (easiest way to implement: Just give it a variable and a value to check it against, then have it trigger another event). If you're going beyond that, you might probably as well use a real scripting language.

As what you save the data structure in the end doesn't really matter. You can use XML, stick it line-wise in text files, build a binary data structure, whatever you want.

Your data structure can be as easy as an int to describe the operation (i.e. 1 = spawn monster, 2 is despawn etc.), and two strings naming which objects to operate on.

Well, you have to essentially make your engine able to load logic from disk somehow. You could actually code that into your program, but more often people devise a data file format for these purposes.

What in end effect it boils down to is creating a very simple (and not necessarily turing-complete, and not necessarily text-form) programming language. That's why so many game developers just use a scripting language like Lua.

But what you really only need is to build the basic operations into your engine (e.g. spawn a monster, despawn a monster, show a dialog tree, move a monster, add a mission objective, resolve mission, whatever your game requires). Then you give each situation an event or trigger (like "monster killed" or "player inside" or "dialog choice selected").

Then build a data structure that can be used to describe each basic operation. In your on-disk representation of a level, save such a data structure for each event of every object. Whenever an event happens, load the data structure (probably an array of 'em) and do the things it describes.

Many games can get away with this. Some also need some sort of counter variables (plus increment/decrement commands), and maybe a conditional (easiest way to implement: Just give it a variable and a value to check it against, then have it trigger another event). If you're going beyond that, you might probably as well use a real scripting language.

What you save the data structure as in the end doesn't really matter. You can use XML, stick it line-wise in text files, build a binary data structure, whatever you want.

Your data structure can be as easy as an int to describe the operation (i.e. 1 = spawn monster, 2 is despawn etc.), and two strings naming which objects to operate on.

Source Link
uliwitness
  • 1.2k
  • 1
  • 9
  • 12

Well, you have to essentially make your engine able to load logic from disk somehow. You could actually code that into your program, but more often people devise a data file format for these purposes.

What in end effect it boils down to is creating a very simple (and not necessarily turing-complete, and not necessarily text-form) programming language. That's why so many game developers just use a scripting language like Lua.

But what you really only need is to build the basic operations into your engine (e.g. spawn a monster, despawn a monster, show a dialog tree, move a monster, add a mission objective, resolve mission, whatever your game requires). Then you give each situation an event or trigger (like "monster killed" or "player inside" or "dialog choice selected").

Then build a data structure that can be used to describe each basic operation. In your on-disk representation of a level, save such a data structure for each event of every object. Whenever an event happens, load the data structure (probably an array of 'em) and do the things it describes.

Many games can get away with this. Some also need some sort of counter variables (plus increment/decrement commands), and maybe a conditional (easiest way to implement: Just give it a variable and a value to check it against, then have it trigger another event). If you're going beyond that, you might probably as well use a real scripting language.

As what you save the data structure in the end doesn't really matter. You can use XML, stick it line-wise in text files, build a binary data structure, whatever you want.

Your data structure can be as easy as an int to describe the operation (i.e. 1 = spawn monster, 2 is despawn etc.), and two strings naming which objects to operate on.