Jump to content

[Guide] How to use a secondary ItemInfo file


Neo-Mind

Recommended Posts


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  806
  • Reputation:   220
  • Joined:  03/13/12
  • Last Seen:  

Introduction
Well this idea came up when evilpunker asked about the possibility of having a patch which loads a second file which overrides the iteminfo file. But there is a better way to do that with lua itself.

How to do it?
The key idea is that the item information is added using the main function by the client. so in your custom file you just need to modify the main function to accept your items. Here is how it can be done.



-- Load the original file. As you might have guessed you can also load your translated file here instead 
-- (just make sure the "tbl" array contains your item info)
 
dofile("System/iteminfo.lub") 
 
-- Now as a simple example . I am simply going to change name of Red Potion to Crimson Potion. 
-- But you can add anything in the same way. Format is same as the original one, just
-- the table name is different
 
tbl_custom = {
  [501] = {
    unidentifiedDisplayName = "Crimson Potion",
    unidentifiedResourceName = "»¡°£Æ÷¼Ç",
    unidentifiedDescriptionName = {
      "A potion made from",
      "grinded Red Herbs that",
      "restores ^000088about 45 HP^000000.",
      "^ffffff_^000000",
      "Weight: ^7777777^000000"
    },
    identifiedDisplayName = "Crimson Potion",
    identifiedResourceName = "»¡°£Æ÷¼Ç",
    identifiedDescriptionName = {
      "^000088HP Recovery Item^000000",
      "A potion made from",
      "grinded Red Herbs that",
      "restores ^000088about 45 HP^000000.",
      "^ffffff_^000000",
      "Weight: ^7777777^000000"
    },
    slotCount = 0,
    ClassNum = 0
  },
}
 
-- Now for a helper function because i hate repetitions 
-- It adds items from curTable if it is not present in refTable
 
function itemAdder(curTable, refTable)
  for ItemID,DESC in pairs(curTable) do
    if refTable == nil or refTable[ItemID] == nil then
      result, msg = AddItem(ItemID, DESC.unidentifiedDisplayName, DESC.unidentifiedResourceName, DESC.identifiedDisplayName, DESC.identifiedResourceName, DESC.slotCount, DESC.ClassNum)
      if not result then
        return false, msg
      end
      for k,v in pairs(DESC.unidentifiedDescriptionName) do
        result, msg = AddItemUnidentifiedDesc(ItemID, v)
        if not result then
          return false, msg
        end
      end
      for k,v in pairs(DESC.identifiedDescriptionName) do
        result, msg = AddItemIdentifiedDesc(ItemID, v)
        if not result then
          return false, msg
        end
      end
    end
  end
  return true, "good"
end
 
 
-- And the newly designed main function
function main()
  result, msg = itemAdder(tbl_custom, nil) -- add custom items (including official overrides)
  if result then
    result, msg = itemAdder(tbl, tbl_custom) -- add non-overridden official items
  end
  return result, msg
end

How is it useful?
Think how item_db2.txt is useful for adding custom items in a server. Its the same strategy here.

You can keep your official items in a base file (or you can just use the official iteminfo.lub file if you want the korean names)
and keep your custom items in a different file (make sure the first dofile function calls the base file).

The above code is error free, so feel free to copy and add your items :). Hope the topic was not too confusing :lol:
The lua code can be further expanded for overriding only parts of an official item. But i will leave that update for the future :D

P.S. The client should be patched to accept your custom file not the base file. ^_^

post-3078-0-44385000-1411452271_thumb.jpg

  • Upvote 8
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

yeah, finally. I'm waiting for this. And forgot to ask you somelike "Neo, can u make patch so client can use other lua files to overwrite existing files instead of "read this file instead the original ones" at least for itemInfo.lua"

Link to comment
Share on other sites

  • 3 weeks later...

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

does it capable to support more than 2 itemInfo.lub ??

 

Example:

System/itemInfo_1.lub
System/itemInfo_2.lub
System/itemInfo_3.lub
System/itemInfo_4.lub
dofile("System/itemInfo_1.lub") 
dofile("System/itemInfo_2.lub") 
dofile("System/itemInfo_3.lub") 
dofile("System/itemInfo_4.lub") 

it doesnt seem to work if i add like this. any idea ?

 

if it does support, anything i missed ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  806
  • Reputation:   220
  • Joined:  03/13/12
  • Last Seen:  

You can try it that way but you will need to put the dofile calls inside the main function of the target iteminfo file and also call the main function with no arguments after each dofile call. 

Edited by NeoMind
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

You can try it that way but you will need to put the dofile calls inside the main function of the target iteminfo file and also call the main function with no arguments after each dofile call. 

erm... kinda confuse... not familiar with LUB coding

 

i tried put 4 dofile() inside itemInfo.lub to connect to other itemInfo_XYZ.lub 

but doesnt work for my case ( item appear as apple/unknown )

 

if you dont mind, can provide me some examples ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  806
  • Reputation:   220
  • Joined:  03/13/12
  • Last Seen:  

OK I have come up with a different solution for the cases when you want to load the data from many files (assuming you can edit them).

Put the following in a file and make the client load it. 

-- Define Some arrays and constants 
iiFiles = {"System/itemInfo_1.lub", "System/itemInfo_2.lub", "System/itemInfo_3.lub", "System/itemInfo_4.lub"} -- List of Files to Read which contains the tables
iiTables = {tbl_1, tbl_2, tbl_3, tbl_4} -- List of Table Names read from the files in decreasing order of priority

iiNum = table.getn(iiTables) -- Number of Entries in above array.
initID = 501   -- First Item ID (Don't change this one unless Gravity decided to put lower values for ItemIDs)
lastID = 32767 -- Last  Item ID (Does not matter if some Item IDs in between are not defined, they will be skipped automatically.)

--#############################################################################--
-- Do Not Modify anything beyond this point unless you know what you are doing.--
--#############################################################################--

-- Read the Tables in the Lua files mentioned
for index = 0, iiNum-1, 1 do
  dofile(iiFiles[index])
end

-- Define a new main function that looks through all the tables.
function main()
  for ItemID = initID, lastID, 1 do
    for index = 0, iiNum-1, 1 do -- Iterate through each table
      curTable = iiTables[index]
      if curTable != nil && curTable[ItemID] != nil then -- Check if Table is valid and it has an entry for ItemID.
        ITEMDATA = curTable[ItemID]
        result, msg = AddItem(ItemID, ITEMDATA.unidentifiedDisplayName, ITEMDATA.unidentifiedResourceName, ITEMDATA.identifiedDisplayName, ITEMDATA.identifiedResourceName, ITEMDATA.slotCount, ITEMDATA.ClassNum)
        if not result then
          return false, msg
        end
        for k,v in pairs(ITEMDATA.unidentifiedDescriptionName) do
          result, msg = AddItemUnidentifiedDesc(ItemID, v)
          if not result then
            return false, msg
          end
        end
        for k,v in pairs(ITEMDATA.identifiedDescriptionName) do
          result, msg = AddItemIdentifiedDesc(ItemID, v)
          if not result then
            return false, msg
          end
        end
        index = iiNum -- alternative to continue statement (No More Tables need to be checked)
      end -- if curTable
    end -- for index
  end -- for ItemID
  return true, "good"
end
When you simply dofile the tbl array gets overwritten each time. so you need to rename those to proper names.

Here the assumption is that tbl_1 is defined in ItemInfo_1 file, tbl_2 in ItemInfo_2 file etc. 

 

Hope this was clear.

Edited by NeoMind
  • Love 1
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

I see, perhap it's table name issue previously. 

 

Thx for the help. :)

Link to comment
Share on other sites

  • 2 months later...

  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

hmm, failed. using 2013-08-07

first at

if curTable != nil && curTable[ItemID] != nil then -- Check if Table is valid and it has an entry for ItemID.

changed "!=" to "~=" and "&&" to "and"

 

2nd, show error window "CItemInfoMgr: cannot read stdin: Bad file descriptor"

 

 

EDIT: Read my signature for multiple System/itemInfo.lua

Edited by Cydh
Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.01
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

NICE =d

Edited by AngelZito
Link to comment
Share on other sites

  • 1 year later...

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  171
  • Reputation:   15
  • Joined:  01/26/12
  • Last Seen:  

Sorry for reviving an old Post but does this work with lua files instead of lubs.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  42
  • Topics Per Day:  0.01
  • Content Count:  1096
  • Reputation:   344
  • Joined:  02/26/12
  • Last Seen:  

4 minutes ago, sikiro said:

Sorry for reviving an old Post but does this work with lua files instead of lubs.

yes

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  399
  • Reputation:   69
  • Joined:  12/26/15
  • Last Seen:  

Perhaps this might be the alternative for add custom item.

http://herc.ws/board/topic/11686-guide-adding-new-items-without-iteminfolub/#entry77704

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

On 3/9/2017 at 2:37 AM, hazimjauhari90 said:

Perhaps this might be the alternative for add custom item.

http://herc.ws/board/topic/11686-guide-adding-new-items-without-iteminfolub/#entry77704

that option isn't really an ideal alternative to add custom.

basically it just append another item description to the same items.

just imagine the size of  your item description when  you created an item with super long description ... o-o

not to mention the trouble you have to go through to search for item description to add/edit

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  3
  • Reputation:   0
  • Joined:  01/28/13
  • Last Seen:  

Hello.

How exactly we apply this patch? Could you please give detailed steps on how to do it.

I'm a total newbie to this topic, so please pardon me.

EDIT: Figured it out.

Thank you very much!

 

EDIT2: The custom item's sprite strangely couldn't be loaded. I'm using the default script above.

-- Load the original file. As you might have guessed you can also load your translated file here instead 
-- (just make sure the "tbl" array contains your item info)
 
dofile("System/iteminfo.lub") 
 
-- Now as a simple example . I am simply going to change name of Red Potion to Crimson Potion. 
-- But you can add anything in the same way. Format is same as the original one, just
-- the table name is different
 
tbl_custom = {
  [501] = {
    unidentifiedDisplayName = "Crimson Potion",
    unidentifiedResourceName = "»¡°£Æ÷¼Ç",
    unidentifiedDescriptionName = {
      "A potion made from",
      "grinded Red Herbs that",
      "restores ^000088about 45 HP^000000.",
      "^ffffff_^000000",
      "Weight: ^7777777^000000"
    },
    identifiedDisplayName = "Crimson Potion",
    identifiedResourceName = "»¡°£Æ÷¼Ç",
    identifiedDescriptionName = {
      "^000088HP Recovery Item^000000",
      "A potion made from",
      "grinded Red Herbs that",
      "restores ^000088about 45 HP^000000.",
      "^ffffff_^000000",
      "Weight: ^7777777^000000"
    },
    slotCount = 0,
    ClassNum = 0
  },
}
 
-- Now for a helper function because i hate repetitions 
-- It adds items from curTable if it is not present in refTable
 
function itemAdder(curTable, refTable)
  for ItemID,DESC in pairs(curTable) do
    if refTable == nil or refTable[ItemID] == nil then
      result, msg = AddItem(ItemID, DESC.unidentifiedDisplayName, DESC.unidentifiedResourceName, DESC.identifiedDisplayName, DESC.identifiedResourceName, DESC.slotCount, DESC.ClassNum)
      if not result then
        return false, msg
      end
      for k,v in pairs(DESC.unidentifiedDescriptionName) do
        result, msg = AddItemUnidentifiedDesc(ItemID, v)
        if not result then
          return false, msg
        end
      end
      for k,v in pairs(DESC.identifiedDescriptionName) do
        result, msg = AddItemIdentifiedDesc(ItemID, v)
        if not result then
          return false, msg
        end
      end
    end
  end
  return true, "good"
end
 
 
-- And the newly designed main function
function main()
  result, msg = itemAdder(tbl_custom, nil) -- add custom items (including official overrides)
  if result then
    result, msg = itemAdder(tbl, tbl_custom) -- add non-overridden official items
  end
  return result, msg
end

My client version is 2015-11-04aRagexe.exe

screenrAthena002.jpg

 

EDIT3: Solved. Turns out the script only read the data folder while ignoring GRF files. All of my sprites are in GRF files, that's why the error occured.

Edited by shadowofdoom
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  399
  • Reputation:   69
  • Joined:  12/26/15
  • Last Seen:  

On 3/21/2017 at 11:31 AM, Emistry said:

that option isn't really an ideal alternative to add custom.

basically it just append another item description to the same items.

just imagine the size of  your item description when  you created an item with super long description ... o-o

not to mention the trouble you have to go through to search for item description to add/edit

for me.. it depends on the user itself.. if the user are transitioning from older client which previously used idnum2tables.  perhaps the solution that i've posted above is for them are much easier.. i can on the client side support & request, there are a quite few people are still don't know how to use itemInfo.. so if they would like to continue using old method in adding custom item, this solution might be ideal for them.xD 

Link to comment
Share on other sites

  • 1 year later...

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  57
  • Reputation:   9
  • Joined:  03/05/18
  • Last Seen:  

@shadowofdoom @Anacondaqq

i know this is an old topic but how do I apply this patch? I am still learning about this new thing

 

  • Love 1
Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  67
  • Topics Per Day:  0.02
  • Content Count:  223
  • Reputation:   29
  • Joined:  10/21/12
  • Last Seen:  

On 10/21/2018 at 5:15 AM, Slyx said:

@shadowofdoom @Anacondaqq

i know this is an old topic but how do I apply this patch? I am still learning about this new thing

 

yeah how to apply this patch ?

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  51
  • Reputation:   23
  • Joined:  04/28/12
  • Last Seen:  

What it does

Allows you to have two files in your System folder; One for the standard RO item descriptions, and one for your custom items.
It is useful in the same way that item_db2.txt contains your custom files while the standard RO files are in item_db.txt.

How to implement it

Step 1. Create your secondary file in your System folder. In my example below, it uses iteminfo.au.lub.

image.png.c36130fc1b16156300d10d546cb3600f.png

Step 2. Using an updated NEMO Client patcher, hex your client such that it uses the Load Custom lua file instead of iteminfo.lub patch.

image.thumb.png.dc96875bbd90ab7dbdbb225353e6216b.png

Step 3. On your iteminfo.au.lub, use the following format as a template:

dofile("System/iteminfo.lub") 

tbl_custom = {
	[30001] = {
		unidentifiedDisplayName = "Old Red Box",
		unidentifiedResourceName = "빨간상자",
		unidentifiedDescriptionName = {
		},
		identifiedDisplayName = "Old Red Box",
		identifiedResourceName = "빨간상자",
		identifiedDescriptionName = {
			"A box that glows with a mysterious, red color. If you open it, something good may be inside.",
			"^FFFFFF_^000000",
			"Weight:^009900 20^000000"
		},
		slotCount = 0,
		ClassNum = 0,
		costume = false
	},	

}


-- Now for a helper function because i hate repetitions 
-- It adds items from curTable if it is not present in refTable

function itemAdder(curTable, refTable)
	for ItemID,DESC in pairs(curTable) do
    	if refTable == nil or refTable[ItemID] == nil then
			result, msg = AddItem(ItemID,DESC.unidentifiedDisplayName,DESC.unidentifiedResourceName,DESC.identifiedDisplayName,DESC.identifiedResourceName, DESC.slotCount, DESC.ClassNum)
		
			if not result then
				return false, msg
			end

			for k,v in pairs(DESC.unidentifiedDescriptionName) do
				result, msg = AddItemUnidentifiedDesc(ItemID, v)
				
				if not result then
					return false, msg
				end
			end
		
			for k,v in pairs(DESC.identifiedDescriptionName) do
				result, msg = AddItemIdentifiedDesc(ItemID, v)
				
				if not result then
					return false, msg
				end
			end
		end
	end
	return true, "good"
end

-- And the newly designed main function
function main()
	result, msg = itemAdder(tbl_custom, nil)

	-- add custom items (including official overrides)
  	if result then
  		result, msg = itemAdder(tbl, tbl_custom)
  		-- add non-overridden official items
  		end
  	return result, msg
end

Explanation

1. It first executes the file found in System/iteminfo.lub, which allows you to load the standard RO files.
2. Then, you define tbl_custom, which is your custom items and their definitions.
3. The itemAdder function is used to prioritize information from tbl_custom over the standard tbl of items.
4. The main function is re-designed to do facilitate this behavior.

Reminders

When editing your iteminfo.lub, make sure that you save the file using the EUC-KR encoding and NOT UTF-8, or else your client will not be able to understand the resource names.

Supposedly, if you only use Notepad++ you would not encounter any problems with such. However, I use Visual Studio Code and it annoyingly opens my file using UTF-8 encoding.

image.png.310a0af1586aa337b7d784df6717aa5a.png

 

I hope that was a much more clear explanation of how to do this. If anything is unclear or incorrect, please inform me so I can edit my post.

  • MVP 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...