• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

[REQUEST] Minecraft-style crafting

kimo

Leechers gonna leech!
Joined
Jul 20, 2007
Messages
68
Reaction score
0
Good day, OtLanders.

We all know how big a success minecraft is, and to some of us (me), it is quite a lot of fun. Crafting impressive items from resources gathered from the world is an appealing idea that I would like to see brought into Tibia. However, I have no experience whatsoever in scripting (ok, maybe an introductory c++ course at uni that will probably do me no good), and thus, I need your help.

The idea itself is not completely materialized yet, so feel free to come up with your completely different idea for it:

-Like minecraft, players collect resources from monsters, quest chests, and resource gathering mods (such as mining, woodcutting, etc .. mods. Example: http://otland.net/f81/farming-mining-woodcutting-updated-fletching-scripts-82419/ --this is just an example)

-Either at a "crafting table" in town, or in a special portable container (the second being preferable, as portability is important), players add the number of different materials required to craft a certain item, and then carrying out the actual crafting. Sadly, since I am not quite literate when it comes to coding, and since I don't know the extent of the ability of scripting, I don't know the possible ways that this can be done. But here is an example:

-The container is a chest of some sort
-Player adds in mats, and pulls a lever
-Script is initialized, *scripting magic*, item!

Sadly, this example won't work if it is to be made portable, due to the need for a lever. Also, it doesn't allow for putting items in different shapes, similar to what minecraft does.
Another example:

-Player opens special window, with a 3*3 grid with slots similar to containers
-Player adds materials in certain configuration and in certain numbers per slot
-Player presses a button and VOILA! Item.

Now, I have ABSOLUTELY no idea whether the concept of a special window is even possible to script.

That being said, I am looking forward to what you guys have in mind.

Kimo
 
Aaah yes, I was kind of expecting, and somewhat dreading, that answer. I take that to mean that a special window in the normal client is not possible (although I kind of guessed as much already, just needed confirmation). How about other ways of doing this? Got any suggestions?

And I assume coding for OTClient requires a more in-depth knowledge of coding, right? I for one definitely don't have that knowledge.

By the way, I JUST noticed your avatar. Hah!
 
I never looked at OTClient properly, so I can't answer how hard it is to make something like that for it.

I guess you could use some sort of chest, the major problem would be the empty slots, lets say you wanted to make an Iron Sword, its:
010
010
020
(0 = nothing, 1 = Iron Ingot, 2 = Stick)
you'd need some sort of placeholder item to fill in the blanks, lets say you'd use a gold coin

after that, you could getContainerItem(uid, slot) to get the items in the order you wanted:

LUA:
function getCraftingTableItems(uid) --uid = container uid
   local craft = { }
   for int i = 0, 8 do
      local item = getContainerItem(uid, i)
      if item.itemid == 2148 then --We don't care about the Gold Coins :p
         item = 0
      end
      craft[i + 1] = item      
   end
   return craft
end

this would return a table with all the items in the correct order for you to do as you please, and any empty slots would be 0

with this, you could make a table of craftableItems and then have a function to compare:
LUA:
   craftableItems = {
   {name = "Iron Sword", itemId = XXXX, recipe = {0, 5880, 0, 0, 5880, 0, 0, 5941, 0}} --Wooden Stake for lack of better item atm for example
   {name = "Iron Pickaxe", itemId = YYYY, recipe = {5880, 5880, 5880, 0, 5941, 0, 0, 5941, 0}} --Wooden Stake for lack of better item atm for example
   {name = "Gold Sword", itemId = ZZZZ, recipe = {0, 2179, 0, 0, 2179, 0, 0, 5941, 0}} --Gold Ring and Wooden Stake for lack of better items atm for example
      --...
   }

   function getCraftResult(craftTable) --craftTable = result from the above function
      for i = 1, #craftableItems do
         local positive = true
         for y = 1, 9 do
            if craftTable[y].itemid != craftableItems[i].recipe[y] then
               positive = false
               break
            end
         end
         if positive then
            return craftTable[i]
         end
      end
      return false
   end

now if it returns something(not false), you can remove the items from the container(you have their uids from the first function) and give the player the result.itemId for the craft item :)



wow, I almost did half the job for you xD

following the thread, if you want, you can add me on Skype, its on my Profile :)
 
Last edited:
Sounds like something I would like on my server. What items have you thought about?


I had a few different "branches" of thought about the items, but no specific items yet:

1) Players can craft a select amount of items already in the game, but mainly equipment. Actually, come to think about it, they can also craft potions (empty flask + ingredients = potion!).

2) Players can craft a series of an item, exclusive to crafting i.e. Let's say a player is a knight and wants to make a sword: he gets the materials for a basic design of sword (not necessarily the item named "sword"), he craft this sword. Now he has a basic sword that was made by crafting. They can then use THAT sword in more crafting to make it a stronger sword, somewhat similar to an idea of augmentation.

3) add both 1 and 2, so players can acquire swords in-game, then use them in crafting to make a higher tier of sword.

As you can see, possibilities are endless. Did you get any ideas you want to share that might help?


I never looked at OTClient properly, so I can't answer how hard it is to make something like that for it.

I guess you could use some sort of chest, the major problem would be the empty slots, lets say you wanted to make an Iron Sword, its:
010
010
020
(0 = nothing, 1 = Iron Ingot, 2 = Stick)
you'd need some sort of placeholder item to fill in the blanks, lets say you'd use a gold coin

after that, you could getContainerItem(uid, slot) to get the items in the order you wanted:

LUA:
function getCraftingTableItems(uid) --uid = container uid
   local craft = { }
   for int i = 0, 8 do
      local item = getContainerItem(uid, i)
      if item.itemid == 2148 then --We don't care about the Gold Coins :p
         item = 0
      end
      craft[i + 1] = item      
   end
   return craft
end

this would return a table with all the items in the correct order for you to do as you please, and any empty slots would be 0

with this, you could make a table of craftableItems and then have a function to compare:
LUA:
   craftableItems = {
   {name = "Iron Sword", itemId = XXXX, recipe = {0, 5880, 0, 0, 5880, 0, 0, 5941, 0}} --Wooden Stake for lack of better item atm for example
   {name = "Iron Pickaxe", itemId = YYYY, recipe = {5880, 5880, 5880, 0, 5941, 0, 0, 5941, 0}} --Wooden Stake for lack of better item atm for example
   {name = "Gold Sword", itemId = ZZZZ, recipe = {0, 2179, 0, 0, 2179, 0, 0, 5941, 0}} --Gold Ring and Wooden Stake for lack of better items atm for example
      --...
   }

   function getCraftResult(craftTable) --craftTable = result from the above function
      for i = 1, #craftableItems do
         local positive = true
         for y = 1, 9 do
            if craftTable[y].itemid != craftableItems[i].recipe[y] then
               positive = false
               break
            end
         end
         if positive then
            return craftTable[i]
         end
      end
      return false
   end

now if it returns something(not false), you can remove the items from the container(you have their uids from the first function) and give the player the result.itemId for the craft item :)



wow, I almost did half the job for you xD

following the thread, if you want, you can add me on Skype, its on my Profile :)

Very elegant solution with the coins. I like it. I will work with that if other, more portable solutions fail. +rep
Also, gold ingots > gold rings :P (maybe you forgot about them?)

I had this idea yesterday while laying in bed just before I sleep (that seems to be the time I get most of my ideas :/). How about using the equipment slots for crafting? but that would mean that we have to allow users to equip items in these slots other than actual equipment, is that possible without source? I hope my idea is clear, I know my English isn't. Can't put it in proper words. The problem with this idea is that it is somewhat of a nuisance to take off your equipment every time you want to craft, even more of a nuisance if you're hunting (although why would you stop to craft if you're hunting, but then again each has his playing style). Portability +1, Accessibility -1.
 
I had a few different "branches" of thought about the items, but no specific items yet:

1) Players can craft a select amount of items already in the game, but mainly equipment. Actually, come to think about it, they can also craft potions (empty flask + ingredients = potion!).

2) Players can craft a series of an item, exclusive to crafting i.e. Let's say a player is a knight and wants to make a sword: he gets the materials for a basic design of sword (not necessarily the item named "sword"), he craft this sword. Now he has a basic sword that was made by crafting. They can then use THAT sword in more crafting to make it a stronger sword, somewhat similar to an idea of augmentation.

3) add both 1 and 2, so players can acquire swords in-game, then use them in crafting to make a higher tier of sword.

As you can see, possibilities are endless. Did you get any ideas you want to share that might help?




Very elegant solution with the coins. I like it. I will work with that if other, more portable solutions fail. +rep
Also, gold ingots > gold rings :P (maybe you forgot about them?)

I had this idea yesterday while laying in bed just before I sleep (that seems to be the time I get most of my ideas :/). How about using the equipment slots for crafting? but that would mean that we have to allow users to equip items in these slots other than actual equipment, is that possible without source? I hope my idea is clear, I know my English isn't. Can't put it in proper words. The problem with this idea is that it is somewhat of a nuisance to take off your equipment every time you want to craft, even more of a nuisance if you're hunting (although why would you stop to craft if you're hunting, but then again each has his playing style). Portability +1, Accessibility -1.
i think its possible, you just have to add the equipSlot to the items.xml on the items you want to give, and each item also can only go in 1 slot, meaning it'll be much less flexible, I think that the way I said is the most flexible way of doing it without any sort of source mods(both server and/or client)
and yeah, i forgot them(gold ingots)

bed and shower, its when the best ideas come xD
 
Last edited:
Back
Top