Jump to content

My custom item skin crashes in dedicated servers


Recommended Posts

Hey all.

I made a custom item skin using @Kzisor's api and it works flawlessly when I use it with my character mod as I just found out that you can make custom skins for custom characters so why not do the same thing for custom items?

When I finished the code though, everytime I try to craft the skin, it crashes the game for some unknown problem that I don't know how to solve.

I tried to compare the code to the code of a certain mod that uses the same code (Mala Mi) and for some reason it doesn't crash for Malani but it crashes for my mod.

This is the error that I've gotten, here is the code I used for the skins and my item's file.

Spoiler

[00:14:48]: [string "scripts/components/playercontroller.lua"]:3608: attempt to index field '?' (a nil value)
LUA ERROR stack traceback:
    scripts/components/playercontroller.lua:3608 in (method) RemoteMakeRecipeFromMenu (Lua) <3606-3620>
    scripts/components/builder_replica.lua:264 in (method) MakeRecipeFromMenu (Lua) <260-266>
    scripts/widgets/widgetutil.lua:63 in (global) DoRecipeClick (Lua) <22-103>
    scripts/widgets/recipepopup.lua:131 in (field) onclick (Lua) <130-136>
    scripts/widgets/imagebutton.lua:206 in (method) OnControl (Lua) <166-213>
    scripts/widgets/widget.lua:113 in (method) OnControl (Lua) <107-121>
    scripts/widgets/widget.lua:113 in (field) OnControl (Lua) <107-121>
    scripts/widgets/recipepopup.lua:569 in (method) OnControl (Lua) <568-576>
    scripts/widgets/widget.lua:113 in (field) OnControl (Lua) <107-121>
    scripts/widgets/craftslot.lua:45 in () ? (Lua) <44-66>
    =(tail call):-1 in ()  (tail) <-1--1>
    scripts/widgets/widget.lua:113 in (method) OnControl (Lua) <107-121>

local RECIPETABS = GLOBAL.RECIPETABS
local Recipe = GLOBAL.Recipe
local Ingredient = GLOBAL.Ingredient
local TECH = GLOBAL.TECH
local PREFAB_SKINS = GLOBAL.PREFAB_SKINS
local PREFAB_SKINS_IDS = GLOBAL.PREFAB_SKINS_IDS

PREFAB_SKINS.jangtonknife = {
	"jangtonknife_bloody",
}

PREFAB_SKINS_IDS = {}
for prefab,skins in pairs(PREFAB_SKINS) do
	PREFAB_SKINS_IDS[prefab] = {}
	for k,v in pairs(skins) do
		PREFAB_SKINS_IDS[prefab][v] = k
	end
end

local jangtonkniferecipe = AddRecipe("jangtonknife", {Ingredient("flint", 6), Ingredient("twigs", 2)}, RECIPETABS.TOOLS, TECH.SCIENCE_ONE, nil, nil, nil, nil, "jangton", "images/inventoryimages/jangtonknife.xml", "jangtonknife.tex")
jangtonkniferecipe.sortkey = -2
jangtonkniferecipe.skinnable = true

 

jangtonknife.lua

I hope someone comes up with a solution and best of luck fellow modders and thanks in advance!

Edited by Stormish
  • Like 1
Link to comment
Share on other sites

17 hours ago, Stormish said:

I hope someone comes up with a solution and best of luck fellow modders and thanks in advance!

Could you try putting this in your modmain, go ingame and reproduce the crash and tell me what recipe.name and skin prints out as? Really sorry for the terrible formatting. I'm writing this out on mobile where I cant format it as code for whatever reason.

 

 

AddComponentPostInit("playercontroller, function(self)
local _RemoteMakeRecipeFromMenu = self.RemoteMakeRecipeFromMenu

function self:RemoteMakeRecipeFromMenu(recipe, skin)
print("Printing recipe name and skin name")
print(recipe.name)
if skin ~= nil then
 print(skin)
end
_RemoteMakeRecipeFromMenu(self, recipe, skin)
end
 end)

  • Like 1
Link to comment
Share on other sites

1 hour ago, Hornete said:

Could you try putting this in your modmain, go ingame and reproduce the crash and tell me what recipe.name and skin prints out as? Really sorry for the terrible formatting. I'm writing this out on mobile where I cant format it as code for whatever reason.

 

 

AddComponentPostInit("playercontroller, function(self)
local _RemoteMakeRecipeFromMenu = self.RemoteMakeRecipeFromMenu

function self:RemoteMakeRecipeFromMenu(recipe, skin)
print("Printing recipe name and skin name")
print(recipe.name)
if skin ~= nil then
 print(skin)
end
_RemoteMakeRecipeFromMenu(self, recipe, skin)
end
 end)

I did that, the recipe name and skin name printed seems fine to me, but it crashes again when I craft it

Here's the full traceback though, it might help you a bit.

Spoiler

[00:23:48]: Printing recipe name and skin name	
[00:23:48]: jangtonknife	
[00:23:48]: jangtonknife_bloody	
[00:23:48]: [string "scripts/components/playercontroller.lua"]:3608: attempt to index field '?' (a nil value)
LUA ERROR stack traceback:
scripts/components/playercontroller.lua:3608 in (upvalue) _RemoteMakeRecipeFromMenu (Lua) <3606-3620>
   self =
      lastzoomtime = 75.366670597345
      isclientcontrollerattached = false
      predictionsent = false
      predictwalking = false
      dragwalking = false
      deploy_mode = true
      controller_targeting_modifier_down = false
      controller_targeting_lock_target = false
      inst = 103249 - jangton (valid:true)
      remote_vector = (-43.64, 3.00, -25.40)
      classified = 104699 - player_classified (valid:true)
      RemoteMakeRecipeFromMenu = function - ../mods/jangton/modmain.lua:657
      lastrottime = 133.4666736275
      map = Map (36436690)
      directwalking = false
      ondetachclassified = function - scripts/components/playercontroller.lua:155
      controller_target_age = 1.#INF
      locomotor = table: 302AF008
      draggingonground = false
      remote_controls = table: 4BA67B40
      ismastersim = false
      handler = table: 24406B30
      HasItemSlots = function - scripts/components/playercontroller.lua:52
      mousetimeout = 10
      is_hopping = false
      controller_targeting_targets = table: 1871C530
      time_direct_walking = 0.93333338201046
   recipe = table: 17E39A20
   skin = jangtonknife_bloody
../mods/jangton/modmain.lua:663 in (method) RemoteMakeRecipeFromMenu (Lua) <657-664>
   self =
      lastzoomtime = 75.366670597345
      isclientcontrollerattached = false
      predictionsent = false
      predictwalking = false
      dragwalking = false
      deploy_mode = true
      controller_targeting_modifier_down = false
      controller_targeting_lock_target = false
      inst = 103249 - jangton (valid:true)
      remote_vector = (-43.64, 3.00, -25.40)
      classified = 104699 - player_classified (valid:true)
      RemoteMakeRecipeFromMenu = function - ../mods/jangton/modmain.lua:657
      lastrottime = 133.4666736275
      map = Map (36436690)
      directwalking = false
      ondetachclassified = function - scripts/components/playercontroller.lua:155
      controller_target_age = 1.#INF
      locomotor = table: 302AF008
      draggingonground = false
      remote_controls = table: 4BA67B40
      ismastersim = false
      handler = table: 24406B30
      HasItemSlots = function - scripts/components/playercontroller.lua:52
      mousetimeout = 10
      is_hopping = false
      controller_targeting_targets = table: 1871C530
      time_direct_walking = 0.93333338201046
   recipe = table: 17E39A20
   skin = jangtonknife_bloody
scripts/components/builder_replica.lua:264 in (method) MakeRecipeFromMenu (Lua) <260-266>
   self =
      classified = 104699 - player_classified (valid:true)
      ondetachclassified = function - scripts/components/builder_replica.lua:32
      inst = 103249 - jangton (valid:true)
   recipe = table: 17E39A20
   skin = jangtonknife_bloody
scripts/widgets/widgetutil.lua:63 in (global) DoRecipeClick (Lua) <22-103>
   owner = 103249 - jangton (valid:true)
   recipe = table: 17E39A20
   skin = jangtonknife_bloody
   knows = true
   can_build = true
   buffered = false
scripts/widgets/recipepopup.lua:131 in (field) onclick (Lua) <130-136>
scripts/widgets/imagebutton.lua:206 in (method) OnControl (Lua) <166-213>
   self =
      image_normal = button_long.tex
      shown = true
      textfocuscolour = table: 4A091FC8
      selected = false
      enabled = true
      help_message = Select
      image_scale = table: 4A092248
      text = Text - Build
      font = spirequal
      name = Build
      textselectedcolour = table: 4A091F00
      focus_flow = table: 4A091F50
      image_focus = button_long_halfshadow.tex
      image_selected = button_long_disabled.tex
      textcolour = table: 4A091D48
      callbacks = table: 4A091B68
      onclick = function - scripts/widgets/recipepopup.lua:130
      inst = 114232 -  (valid:true)
      focus = true
      parent = contents
      normal_scale = table: 4A0929C8
      children = 
[00:23:48]: [string "scripts/components/playercontroller.lua"]:3608: attempt to index field '?' (a nil value)
LUA ERROR stack traceback:
    scripts/components/playercontroller.lua:3608 in (upvalue) _RemoteMakeRecipeFromMenu (Lua) <3606-3620>
    ../mods/jangton/modmain.lua:663 in (method) RemoteMakeRecipeFromMenu (Lua) <657-664>
    scripts/components/builder_replica.lua:264 in (method) MakeRecipeFromMenu (Lua) <260-266>
    scripts/widgets/widgetutil.lua:63 in (global) DoRecipeClick (Lua) <22-103>
    scripts/widgets/recipepopup.lua:131 in (field) onclick (Lua) <130-136>
    scripts/widgets/imagebutton.lua:206 in (method) OnControl (Lua) <166-213>
    scripts/widgets/widget.lua:113 in (method) OnControl (Lua) <107-121>
    scripts/widgets/widget.lua:113 in (field) OnControl (Lua) <107-121>
    scripts/widgets/recipepopup.lua:569 in (method) OnControl (Lua) <568-576>
    scripts/widgets/widget.lua:113 in (field) OnControl (Lua) <107-121>
    scripts/widgets/craftslot.lua:45 in () ? (Lua) <44-66>
    =(tail call):-1 in ()  (tail) <-1--1>
	

 

 

  • Like 1
Link to comment
Share on other sites

Nevermind, I fixed it by removing the local definitions of PREFAB_SKINS and PREFAB_SKINS_IDS and used GLOBAL.PREFAB_SKINS and GLOBAL.PREFAB_SKINS_IDS instead.

Thank you for trying to help though, it's appreciated.

  • Thanks 1
Link to comment
Share on other sites

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
 Share

×
  • Create New...