Jump to content

Recommended Posts

Well, I'm going to make Clean Sweeper of my Mod able to return the items with skin to the state without skin, that is, when dsskin_dress.num[target] = 1, but in this way, as long as it is picked up, it will crash and show that the inventory image cannot be found. Is there any method or code to fix this?:(

Here is the example crash:

 

crash111.PNG

reskin_tool Code:

	target = target or staff.components.inventoryitem.owner
	
    if target.components.dsskins ~= nil and target.components.dsskins.skins ~= nil then
		if not staff.components.dsskin_dress.num[target] then
			staff.components.dsskin_dress.num[target] = 2
		else
			staff.components.dsskin_dress.num[target] = staff.components.dsskin_dress.num[target]+1
		end
		if staff.components.dsskin_dress.num[target] > #target.components.dsskins.skins then
			staff.components.dsskin_dress.num[target] = 1
		end
		local num = staff.components.dsskin_dress.num[target]
		target.components.dsskins.skin = target.components.dsskins.skins[num].skin
		if target.components.dsskins.skins[num].fx ~= nil then
			target.components.dsskins.fx = target.components.dsskins.skins[num].fx
		end
		if target.components.dsskins.skins[num].build ~= nil then
			target.components.dsskins.build = target.components.dsskins.skins[num].build
		end			
	    target.components.dsskins:Changeskin()
		
		local fx = SpawnPrefab("reskin_tool_fx")
        local fx_info = reskin_fx_info[target.prefab] or {}

        local scale_override = fx_info.scale or 1
        fx.Transform:SetScale(scale_override, scale_override, scale_override)

        local fx_pos_x, fx_pos_y, fx_pos_z = target.Transform:GetWorldPosition()
        fx_pos_y = fx_pos_y + (fx_info.offset or 0)
        fx.Transform:SetPosition(fx_pos_x, fx_pos_y, fx_pos_z)
		if IsDLCEnabled(PORKLAND_DLC) then            	
            staff.SoundEmitter:PlaySound("dontstarve_DLC003/common/crafted/vortex_armour/equip_on")
            staff.SoundEmitter:PlaySound("dontstarve_DLC003/common/crafted/vortex_armour/equip_off")
		else
            staff.SoundEmitter:PlaySound("dontstarve/wilson/attack_weapon")  
		end	
		return true
    end

dsskins_dress code:

function Dsskin_dress:Dress(target)
    if target.components.dsskins ~= nil and target.components.dsskins.skins ~= nil then
		if not self.num[target]  then
			self.num[target] = 2 
		else
			self.num[target] = self.num[target] +1
		end
		if self.num[target] > #target.components.dsskins.skins then
			self.num[target] = 2
		end
		local num = self.num[target]
			target.components.dsskins.skin = target.components.dsskins.skins[num].skin
			if target.components.dsskins.skins[num].fx ~= nil then
				target.components.dsskins.fx = target.components.dsskins.skins[num].fx
			end
			if target.components.dsskins.skins[num].build ~= nil then
				target.components.dsskins.build = target.components.dsskins.skins[num].build
			end
			target.components.dsskins:Changeskin()
			local pt = Vector3(target.Transform:GetWorldPosition())
			SpawnPrefab("collapse_small").Transform:SetPosition(pt:Get())
        
		
		return true
	elseif TUNING.DSSKINS ~= nil  and TUNING.DSSKINS.base["wendy"] ~= nil then
			local num = math.random(2,#TUNING.DSSKINS.base["wendy"])
			target.AnimState:SetBuild(TUNING.DSSKINS.base["wendy"][num].name)
		return true
    end
	return false
end

 

Well, I would say for you you want the paths that this function is looking for the texture. It should be working...

 

11 hours ago, KXWl1 said:

local pt = Vector3(target.Transform:GetWorldPosition())

GLOBAL.Vector3

11 hours ago, KXWl1 said:

elseif TUNING.DSSKINS ~= nil and TUNING.DSSKINS.base["wendy"] ~= nil then

GLOBAL.TUNING

This probably won't solve the problem, but I think they're missing. If you haven't already defined it before...

 

11 hours ago, KXWl1 said:

SpawnPrefab("collapse_small").Transform:SetPosition(pt:Get())

Maybe here too

Edited by leonidas_iv
  • Like 1
11 hours ago, Leonidas IV said:

Well, I would say for you you want the paths that this function is looking for the texture. It should be working...

 

GLOBAL.Vector3

GLOBAL.TUNING

This probably won't solve the problem, but I think they're missing. If you haven't already defined it before...

 

Maybe here too

Thank you for your reply! But it doesn't seem so simple...... I used your method, either ineffective or causing another form of crash. I don't know why its path was moved to the wrong place (inventroyimages/xxx.xml), it should have been found in the original file.

  • Sad Dupe 1
On 12/25/2021 at 1:12 AM, Leonidas IV said:

Well, I would say for you you want the paths that this function is looking for the texture. It should be working...

 

GLOBAL.Vector3

GLOBAL.TUNING

This probably won't solve the problem, but I think they're missing. If you haven't already defined it before...

 

Maybe here too

Maybe I have to use the most troublesome method to carry all the tex and XML of the items with skin. But the result is that the image is missing, but at least it won't crash.:(

On 12/26/2021 at 2:26 AM, KXWl1 said:

Maybe I have to use the most troublesome method to carry all the tex and XML of the items with skin. But the result is that the image is missing, but at least it won't crash.:(

I don't know how you're doing, but wouldn't it be simpler to change the code of magic box already in the mod?

Edited by Leonidas IV
  • Like 1
13 hours ago, Leonidas IV said:

I don't know how you're doing, but wouldn't it be simpler to change the code of magic box already in the mod?

Personally, I don't like magic boxes very much, First, its image is too blurred (I don't know why, all the skin images are very clear and good, but this...) second, it has no special sound and fx. On the contrary, the image of DST Clean Sweeper is very clear and interesting to use. After all, I'm aesthetic tired. By the way, if I know more about the code in the future, I may carry the Clean Sweeper skin from DST (brush...) into my mod. Anyway, thank you for your reply and keeping this forum alive!

  • Like 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...