Better encoding for game mechanics?

pabs
New member
 
Posts: 4
Joined: Tue Nov 15, 2011 04:17

Better encoding for game mechanics?

by pabs » Tue Nov 15, 2011 04:21

Currently in minetest all the game mechanics are hard-coded in C++. How about converting that to a custom plain text format?

There are a number of advantages to this:

  • you could get rid of large parts of the wiki and instead build documentation automatically from the source code.
  • the game could have a built-in documentation browser that use the same data as the game, making it always up-to-date.
  • users could much more easily mod the game, since they could probably understand this stuff better than C++

You could either generate C++ code from the plain text format, or parse it at runtime. The latter would allow more flexibility and would be what I would suggest.

An example of what I mean:

data/items/apple_iron.txt:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
id: iron_apple
type: item
texture: apple_iron.png
name: _("Iron apple")
stackable: yes
eatable: yes
heart: 4
description: _("Iron apples heal 4 hearts when eaten and are much more
rare than regular apples. To eat one, place one or more on the ground
and right click it. You can obtain them by picking them off of apple
trees. Before apples are removed from the tree, they won't fall to the
ground and blocks can be built upon them.")


The _("") here are to allow for the possibility of translations once Irrlicht can use TrueType fonts.

data/crafting/apple_iron.txt:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
in_1: steel_ingot
in_3: steel_ingot
in_4: apple
in_5: steel_ingot
in_7: steel_ingot
out: iron_apple


data/cooking/cooked_rat.txt

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
out: cooked_rat
in: rat
Last edited by pabs on Tue Nov 15, 2011 04:23, edited 1 time in total.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

by kahrl » Tue Nov 15, 2011 06:45

Good idea!

Another idea about the crafting description. The way you proposed ties the crafting recipes to the 3x3 crafting square. In case this would be extended or reduced (e.g. if a workbench is ever added) something more generic would be better. Maybe:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
in 1: apple
in right of 1: steel_ingot
in left of 1: steel_ingot
in below of 1: steel_ingot
in above of 1: steel_ingot
out: iron_apple


Here's a context free grammar for this language to make it more (or less? ;)) clear
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
crafting_recipe -> "recipe" "\n" ((in_rule | out_rule)? "\n")*
in_rule         -> "in" id? constraint* ":" item
out_rule        -> "out" ":" item count?
constraint      -> ("left" | "right" | "above" | "below")+ "of" id | "offset" id "," x "," y
id              -> natural
count           -> natural
x               -> integer
y               -> integer
natural         -> [0-9]+
integer         -> "-"? [0-9]+


The crafting evaluator will go through all available recipes and return the first one that in any possible way matches the crafting input. I'll try to write a sample implementation later.

One nice thing about this alternative is that such recipes don't *have* to require a certain arrangement of the inputs, e.g. in minecraft, if you want to color wool, you have to put one wool and one dye into the crafting slots, but their arrangement is irrelevant.

EDIT: Adjusted grammar to allow constraints like "below left of 1", and allow negative offsets.

EDIT: Here's an example, using a slightly different grammar than the one above: http://paste.pocoo.org/show/508223/
Last edited by kahrl on Tue Nov 15, 2011 16:03, edited 1 time in total.
 

User avatar
Hackeridze
Member
 
Posts: 310
Joined: Thu Nov 03, 2011 13:35

by Hackeridze » Wed Nov 16, 2011 09:28

JUST MAKE IT, and I think that Celeron will add it to main stream. Some topics ago we talked about this, and he say, that its hard to write this thing and he will not do this job! If you can write this, we all be happy :)
My game: RTMG
GENTOO USER
 

pabs
New member
 
Posts: 4
Joined: Tue Nov 15, 2011 04:17

by pabs » Wed Nov 16, 2011 12:13

I'm sorry but I don't have the time or the skills to do that, so I will leave it up to the coders to work on it.
 

User avatar
Staffs
Member
 
Posts: 329
Joined: Thu Aug 04, 2011 13:16

by Staffs » Wed Nov 16, 2011 13:58

Well there is kind of no point for this topic its like saying hey guys im too lazy and not so smart so you guys make that scripting thing while i chill and do nothing ..
I love mods :D
 

pabs
New member
 
Posts: 4
Joined: Tue Nov 15, 2011 04:17

by pabs » Wed Nov 16, 2011 23:23

This is the feature discussion forum in case you hadn't noticed.

No need to be nasty to someone offering ideas :(
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 3 guests