Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RobeNameTable_CLS entries with ID > RobeNameTable size are not processed #98

Open
Singe-Horizontal opened this issue Jan 2, 2025 · 8 comments

Comments

@Singe-Horizontal
Copy link

Singe-Horizontal commented Jan 2, 2025

When merging RobeNameTable with RobeNameTable_CLS in MergeRobes, new entries are inserted at RobeNameTable size + 1 instead of RobeNameTable_CLS's entry id

function MergeRobes(size)
local ct = size
for _, v in pairs(RobeNameTable_CLS) do
ct = ct + 1
if(v ~= nil) then
if( RobeNameTable[ct] == nil) then
RobeNameTable[ct] = v
, which results in an empty string when checking at
function ReqRobSprName(index)
if RobeNameTable_CLS ~= nil and CLSRobes == nil then
CLSRobes = MergeRobes(#RobeNameTable)
end
if RobeNameTable[index] == nil then
return ""
end

How to reproduce:
Add new cls entries with ID gaps and check if they display
Example, if you have SPRITE_ROBE_IDs entries finishing in such way:
ROBE_C_CLB_SS_LT = 221, ROBE_C_Honey_Dipper = 222 }
and a SPRITE_ROBE_IDs_CLS with
SPRITE_ROBE_IDs_CLS = { ROBE_MY_CUSTOM_GARMENT = 300, }
,
SPRITE_ROBE_IDs.ROBE_MY_CUSTOM_GARMENT will be equal to 223 instead of 300 when merging RobeNameTable and RobeNameTable_CLS

@llchrisll
Copy link
Owner

Afaik robe ids can’t be skipped anyway, exactly because it goes by index, that’s just what my minimal lua knowledge tells me xD. Correct me if I’m wrong and provide a better solution as I’m still learning it what it need.

@Singe-Horizontal
Copy link
Author

Singe-Horizontal commented Jan 3, 2025

It's weird I had edited a code suggestion but it disappeared,
This reuses the CLS table IDs :

function MergeRobes()
	for _, v in pairs(RobeNameTable_CLS) do
		if(v ~= nil) then
		   if( RobeNameTable[_] == nil) then
			  RobeNameTable[_] = v
			end
		end
	end
	return 1
end

the original values could also always be overwritten:

function MergeRobes()
	for _, v in pairs(RobeNameTable_CLS) do
		if(v ~= nil) then
		      RobeNameTable[_] = v
		end
	end
	return 1
end

@llchrisll
Copy link
Owner

llchrisll commented Jan 3, 2025

Tbh it’s my first time seeing that _ is used this way, only learned that it’s used to omit the value like if you don’t really need it.

@Singe-Horizontal
Copy link
Author

Yes it could be renamed to k to express the intent of reusing it

@llchrisll
Copy link
Owner

Also the reason I didn’t use the k is based on my understanding that the index would be overwritten since the cls table starts with 1

@Singe-Horizontal
Copy link
Author

Singe-Horizontal commented Jan 3, 2025

Wouldn't it be easier to directly use the final IDs when matching the views with item dbs?
Besides that's the current behavior for accessories.

@llchrisll
Copy link
Owner

I don't match the View IDs on item db but on kRO lub file, I pretty much copy&paste the content each time I update it.
Also remember, I'm a newbie in lua coding, I barely understand what's happening, making such edits was already kinda hard for me until they finally worked somehow.

I only have 1 robe to test with so anything afterwards was just an estimation on my end that it worked just like signboards, because they also go by index and it was only displaying one, someone reported that it did work after I changed it to the current setup.

@Singe-Horizontal
Copy link
Author

Signboard are stored in an array of objects { "map", x, y, Height, Icon ID, "Path", "Content", "Char Color" }, where each object has already a way to identify itself, for example by using the map name. Thus there is no need for custom indexes.
Note that:

SignBoardList = {
       { "map", x, y, Height, Icon ID, "Path", "Content", "Char Color" },
}

this is equivalent to

SignBoardList = {
	[1] = { "map", x, y, Height, Icon ID, "Path", "Content", "Char Color" },
}

Now for robes, it does make sense to allow arbitrary indexes since they are used as ID.

-- spriterobeid.lub
SPRITE_ROBE_IDs_CLS = { 
    ROBE_MY_CUSTOM_GARMENT = 300,
 }
 -- spriterobename.lub
RobeNameTable_CLS = {
	-- Robe File Name
	[SPRITE_ROBE_IDs_CLS.ROBE_MY_CUSTOM_GARMENT ] = "my_custom_garment",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants