Jump to content
Neo

[Guide] How to use a secondary ItemInfo file

Recommended Posts

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.  ^_^ 

 

Screenshot 

post-315-0-72087800-1411419493_thumb.jpg

 

Share this post


Link to post
Share on other sites

nice one.  i made it like this so that i wont need to patch my game exe.

 

iteminfo.lub > my mods

iteminfo_re.lub > renewal items info (untouched)

 

hmm there is only 1 problem i can foresee. When Gravity updates/adds items it modifies iteminfo.lub so your edit might go away.

i would suggest to put it in a different file just to be safe :)

Share this post


Link to post
Share on other sites

hmmm .. .

 

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 differenttbl_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 refTablefunction 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 functionfunction 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, msgend 

 

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.  ^_^ 

 

Screenshot 

attachicon.gifscreenNeoRO000.jpg

sir neo . what did you search on the hex code to change the color of your character name and also the guild?.. sorry if my question is out of the topic.. im just interested about it...

Share this post


Link to post
Share on other sites

where we put this custom iteminfo.lub? in the system folder? please enlighten me. XD

 

You should patch your client with the path of your custom file relative to your RO folder (Typically you place the file in the System folder and patch the client with System/<filename>.lub)

 

Similarly the path of your base file (the one you specify in the dofile function) will also be relative to your RO folder (Like the other one this one is also placed typically in the System folder).

Share this post


Link to post
Share on other sites

sir neo . what did you search on the hex code to change the color of your character name and also the guild?.. sorry if my question is out of the topic.. im just interested about it...

about the color hex code its a patch i found and use but i dont plan to make it public as of now :).

the guild is just from /showname

Share this post


Link to post
Share on other sites

 

where we put this custom iteminfo.lub? in the system folder? please enlighten me. XD

 

You should patch your client with the path of your custom file relative to your RO folder (Typically you place the file in the System folder and patch the client with System/<filename>.lub)

 

Similarly the path of your base file (the one you specify in the dofile function) will also be relative to your RO folder (Like the other one this one is also placed typically in the System folder).

 

could you edit the code so I can have the following:

 

1 - mycustomitems.lua (custom items and official overrides)

2 - ItemInfo.lua ("official" bRO file with portuguese info)

3 - ItemInfo2.lua (translated official file with all items)

 

the problem is: I can have 1 and 2 normally, but since bRO lacks a lot of items because it is still some episodes bellow official I need to code to add to the main tbl only the ItemID that doesn't exists in file 1 and 2, I hope that my explanation is good enough, if no, just ask :)

Share this post


Link to post
Share on other sites

it's a very nice patch sir neo .. but i you don't want to release it. i respect your decision. . . thank you for the response sir neo . . . have a good gay 

Share this post


Link to post
Share on other sites

@@Neo It just came to my mind now, what about making the same with accessoryid/accname files? so we can have both originals and custom files, and what if that file even got the two into one? so we didn't had to change both files, but only one instead, to deal with name and id

Share this post


Link to post
Share on other sites

It is possible, but that would require some hexing in the client for it to read additional lua files. Otherwise i guess the additional lua would have to be in the data folder (not sure about this).

Share this post


Link to post
Share on other sites

It is possible, but that would require some hexing in the client for it to read additional lua files. Otherwise i guess the additional lua would have to be in the data folder (not sure about this).

Additional Lua would be in RO folder... Or data if you include data/

Share this post


Link to post
Share on other sites

It is possible, but that would require some hexing in the client for it to read additional lua files. Otherwise i guess the additional lua would have to be in the data folder (not sure about this).

 

 

just posting the code again in case anyone needs it (okay it is really broken since I do not have the original :P)

 

-- 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, msgend 

Share this post


Link to post
Share on other sites

Formatting issues, indentation, and usability of the guide make it a little difficult to understand.

I wrote a simple-to-understand guide (with pictures!) as a response to the original post in rAthena.

I hope that someone finds it useful.

Edit: 

I called it the original post in rAthena because the formatting of sir @Neo's post in rAthena was much more readable as compared to here.

Edited by fourxhackd
Explained why I called it the original post

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.