Jump to content

Recommended Posts

I'm working on a simple chester reskin mod, however i don't know how to change the eyebone icon since it has many different state (shadow/snow, open/closed eye) , i can't just do the usual 

inst.components.inventoryitem.atlasname = "images/inventoryimages/chester_eyebone.xml" --the directory of your atlas
inst.components.inventoryitem.imagename = "chester_eyebone" --the name of your image

anyone has any idea how to do it?

3 hours ago, amazingGob said:

yep!

I think I figured it out!

I took the inventoryimages and inventoryimages1 from the game and turned them into pngs with the tex editor, did a quick edit for the 3 different forms (+opened and closed), turned them back into tex files, created xml files and copy/pasted the xml data for the eyebones into it

And then in the modmain I called the tex and xml file assets

eyebonereskinned.zip

2 hours ago, seraph780 said:

I think I figured it out!

I took the inventoryimages and inventoryimages1 from the game and turned them into pngs with the tex editor, did a quick edit for the 3 different forms (+opened and closed), turned them back into tex files, created xml files and copy/pasted the xml data for the eyebones into it

And then in the modmain I called the tex and xml file assets

eyebonereskinned.zip 3.03 MB · 1 download

ooohhhh interesting. i tested it out and while they eyes works, a lot of other images wouldn't load

here's coal, cactus flesh and blue gem for example

image.png.4bba5671709489b293239c5432d128c3.png

8 hours ago, amazingGob said:

ooohhhh interesting. i tested it out and while they eyes works, a lot of other images wouldn't load

here's coal, cactus flesh and blue gem for example

image.png.4bba5671709489b293239c5432d128c3.png

The image I used might've been outdated then, the inventoryimages has a bunch of other sprites included, so an out of date one probably caused that

I can try to look into it more, though I will admit I'm not very used to changing the game's already existing images, I mostly create my own items

16 minutes ago, seraph780 said:

The image I used might've been outdated then, the inventoryimages has a bunch of other sprites included, so an out of date one probably caused that

I can try to look into it more, though I will admit I'm not very used to changing the game's already existing images, I mostly create my own items

oh wait I realized the actual reason - the xmls files had to include every single item not just the eyebones, so I copied the entire xml files from the games inventoryimages and inventoryimages 1 and now both the eyebone and other items work again

eyebonereskinned2.zip

  • Like 1
1 hour ago, seraph780 said:

The image I used might've been outdated then, the inventoryimages has a bunch of other sprites included, so an out of date one probably caused that

hmmm does this mean ill have to update it everytime theres a new item added to the game?

also what if another mod uses the same method?

1 hour ago, amazingGob said:

hmmm does this mean ill have to update it everytime theres a new item added to the game?

also what if another mod uses the same method?

Unfortunately I don't know what to do about either of those things, sorry :( Only other thing I can come up with right now is creating a new chester using the already existing one's code (and maybe making it so that the old chester eyebone doesn't spawn?) so that those issues don't come up

  • Like 1
4 hours ago, kyupita said:

ofc! i'll try to look into it more later and see if I can find anything

I was able to create a new chester, but I'm stuck figuring out how to get the images to properly show up

If someone smarter than me wants to take a look at what I've got so far:

RSchester.zip

(Might be a little messy, sorry)

Taking a break from it now, but I'll keep trying to see if I can fix it on my own later

Redirect the atlas. But I think I'd better give you an entire mod to learn. But being too lazy...

Basically you can learn from HUD skin mods. There is a lib that allows you to replace any image.

Edited by Rickzzs
  • Like 1
3 hours ago, Rickzzs said:

Redirect the atlas. But I think I'd better give you an entire mod to learn. But being too lazy...

Basically you can learn from HUD skin mods. There is a lib that allows you to replace any image.

Ok I'll look into it, thanks!

1 hour ago, kyupita said:

Ok I'll look into it, thanks!

I looked at a couple HUD mods and Cunning fox's tutorial, and tried to do something similar for chester (Specifically trying to change the inventory images and map icons). None of the images I changed pop up in game though, am I naming something wrong or missing anything?

steve.zip

Changed a little

local env = env
GLOBAL.setfenv(1, GLOBAL)

package.loaded["scripts/img_override_data2"] = nil
local CONVERTION_DATA = require("img_override_data2")
local copy=deepcopy(CONVERTION_DATA)
for k,v in pairs(copy) do
    CONVERTION_DATA[tonumber(hash(k))]=v
    CONVERTION_DATA[k]=v
    for k2,v2 in pairs(v) do
        v[tonumber(hash(k2))]=v2
    end
end
local function ConvertTexture(atlas, tex)
    print(atlas,tex,type(tex))
	if CONVERTION_DATA[atlas] and  CONVERTION_DATA[atlas][tex] then
		return unpack(CONVERTION_DATA[atlas][tex])
	end
	return atlas, tex
end

local Image = require("widgets/image")
local _SetTexture = Image.SetTexture
Image.SetTexture = function(self, atlas, tex, ...)
	atlas, tex = ConvertTexture(atlas, tex)
	return _SetTexture(self, atlas, tex, ...)
end

-- Generate Assets
if not env.Assets then
	env.Assets = {}
end

local Assets = env.Assets
local CachedAssets = {}
for _, v in pairs(CONVERTION_DATA) do
	for _, data in pairs(v) do
		CachedAssets[data[1]] = true
	end
end

for asset, _ in pairs(CachedAssets) do
	table.insert(Assets, Asset("ATLAS", asset))
	local img_name = asset:sub(0, -5)..".tex"
	table.insert(Assets, Asset("IMAGE", img_name))
end

CachedAssets = nil

And please change your name to img_override_data2 so you don't collide with HUD skin mods which usually have that file.

Map icons can't be handled this way.

Just use an AddPrefabPostInit and do a periodic task to change the icon. That's what I can think of.

  • Thanks 1
1 hour ago, Rickzzs said:

Changed a little

local env = env
GLOBAL.setfenv(1, GLOBAL)

package.loaded["scripts/img_override_data2"] = nil
local CONVERTION_DATA = require("img_override_data2")
local copy=deepcopy(CONVERTION_DATA)
for k,v in pairs(copy) do
    CONVERTION_DATA[tonumber(hash(k))]=v
    CONVERTION_DATA[k]=v
    for k2,v2 in pairs(v) do
        v[tonumber(hash(k2))]=v2
    end
end
local function ConvertTexture(atlas, tex)
    print(atlas,tex,type(tex))
	if CONVERTION_DATA[atlas] and  CONVERTION_DATA[atlas][tex] then
		return unpack(CONVERTION_DATA[atlas][tex])
	end
	return atlas, tex
end

local Image = require("widgets/image")
local _SetTexture = Image.SetTexture
Image.SetTexture = function(self, atlas, tex, ...)
	atlas, tex = ConvertTexture(atlas, tex)
	return _SetTexture(self, atlas, tex, ...)
end

-- Generate Assets
if not env.Assets then
	env.Assets = {}
end

local Assets = env.Assets
local CachedAssets = {}
for _, v in pairs(CONVERTION_DATA) do
	for _, data in pairs(v) do
		CachedAssets[data[1]] = true
	end
end

for asset, _ in pairs(CachedAssets) do
	table.insert(Assets, Asset("ATLAS", asset))
	local img_name = asset:sub(0, -5)..".tex"
	table.insert(Assets, Asset("IMAGE", img_name))
end

CachedAssets = nil

And please change your name to img_override_data2 so you don't collide with HUD skin mods which usually have that file.

Map icons can't be handled this way.

Just use an AddPrefabPostInit and do a periodic task to change the icon. That's what I can think of.

Thank you very much! I added the changes, and it worked for the closed version of the image, but the opened eye remains unchanged...

Also I can't seem to get the minimap icons working still, but my main focus right now is the inventory images

steve.zip

16 minutes ago, kyupita said:

Thank you very much! I added the changes, and it worked for the closed version of the image, but the opened eye remains unchanged...

Also I can't seem to get the minimap icons working still, but my main focus right now is the inventory images

steve.zip 40.12 kB · 0 downloads

Just did a quick test and it's specifically the normal chester eyebone (open) and shadow chester eyebone (open) that don't get changed, the 4 other images are fine

I think I made a mistake when copying attributes in a table. So the for iteration cannot iterates every item in a table.

for k,v in pairs(copy) do
    CONVERTION_DATA[tonumber(hash(k))]=v
    CONVERTION_DATA[k]=v
    local vv=deepcopy(v)
    for k2,v2 in pairs(vv) do
        v[tonumber(hash(k2))]=v2
    end
end

This is the correct code.

  • Like 1
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...