Thursday, March 27, 2014

Crafting interface implemented

I added support for crafting. NPCs can now display a crafting window. They can freely define how many slots to display and where to display them. The item script can also define a handler-function which receives the items the player dragged into the window. Each slot can define a "tag" which says which items can go there. Items can now have one or more such tags which define the crafting use they have.

The Java part of the engine does the ground-work of validating that the users input is legal (tags match the slots, user actually has the items).

The scripted function is then responsible for checking if the combination is a valid recipe, remove the items and give the player a new item. This function could also be implemented as a Java class. When I develop a more complex crafting system, I might opt to do so.

No comments:

Post a Comment