Jump to content

[Help] Custom Item not transfering to Shipwrecked


Recommended Posts

Heya everyone,

I could use some help. Trying to make a long story short: I created a character a while ago just for fun for myself and she comes with two custom items (a gun and bullets). Now I've installed Shipwrecked earlier today. The character and the items themselves still seem to work fine. They are in her inventory when she starts as should be and she can use them normally. However I noticed that when in a shipwrecked world the custom items don't show up in any of the crafting tabs. Now that obviously presents a problem because she starts with only 5 bullets (as they are thought as more of a late game item) and will never be able to craft more. I've already gathered that the coding for recipes changed with Shipwreck and tried to fiddle with it myself, but I just can't seem to get it to work. I'd be extremely grateful if someone could help out.

Here's the (relevant) original pre-Shipwrecked coding

PrefabFiles = {
	"bulletgun",
	"canno_projectile",
	"bullet",
}

Assets = {

	Asset( "IMAGE", "images/inventoryimages/bulletgun.tex" ),
	Asset( "ATLAS", "images/inventoryimages/bulletgun.xml" ),
	Asset( "IMAGE", "images/inventoryimages/bullet.tex"),
	Asset( "ATLAS", "images/inventoryimages/bullet.xml" ),

	Asset("ANIM", "anim/bulletgun.zip"),
	Asset("ANIM", "anim/swap_bulletgun.zip"),
	Asset("ANIM", "anim/canno_projectile.zip"),
	Asset("ANIM", "anim/bullet.zip"),
}

GetPlayer = GLOBAL.GetPlayer
GetWorld = GLOBAL.GetWorld
ACTIONS = GLOBAL.ACTIONS

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local SpawnPrefab = GLOBAL.SpawnPrefab

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local STRINGS = GLOBAL.STRINGS
local TECH = GLOBAL.TECH

-- Crafting

local bulletgun = GLOBAL.Ingredient( "bulletgun", 1)
  bulletgun.atlas = "images/inventoryimages/bulletgun.xml"

local bullet = GLOBAL.Ingredient( "bullet", 1)
  bullet.atlas = "images/inventoryimages/bullet.xml"


function modGamePostInit() 

	local bulletgun = GLOBAL.Recipe( "bulletgun", { Ingredient("cutstone", 10), Ingredient("gears", 2), Ingredient("goldnugget", 2) }, RECIPETABS.WAR, TECH.SCIENCE_TWO)
	bulletgun.atlas = "images/inventoryimages/bulletgun.xml"

	local bullet = GLOBAL.Recipe( "bullet", { Ingredient("cutstone", 25), Ingredient("charcoal", 25), Ingredient("flint", 25) }, RECIPETABS.WAR, TECH.SCIENCE_TWO, nil, nil, nil, 50)
	bullet.atlas = "images/inventoryimages/bullet.xml"

end

Yes, the bullets are meant to be expensive on non-renewable resources. ;)

Now what I tried to do for Shipwrecked after "-- Crafting" (since it worked on bringing another icon "over") is this

if GLOBAL.IsDLCEnabled(GLOBAL.CAPY_DLC) then
	local bulletgun = Recipe("bulletgun",{Ingredient("cutstone",10),Ingredient("gears",2),Ingredient
("goldnugget",2)}, RECIPETABS.WAR,TECH.SCIENCE_TWO,RECIPE_GAME_TYPE.COMMON)
	bulletgun.atlas = "images/inventoryimages/bulletgun.xml"
	bulletgun.image = "bulletgun.tex" 

else

	local bulletgun = Recipe("bulletgun",{("cutstone",10),Ingredient("gears",2), Ingredient
("goldnugget",2)},RECIPETABS.WAR,TECH.SCIENCE_TWO)
	bulletgun.atlas = "images/inventoryimages/bulletgun.xml"
	bulletgun.image = "bulletgun.tex" 
end


if GLOBAL.IsDLCEnabled(GLOBAL.CAPY_DLC) then
	local bullet = Recipe("bullet",{Ingredient("cutstone",25),Ingredient("charcoal",25),Ingredient
("flint",25)},RECIPETABS.WAR,TECH.SCIENCE_TWO,RECIPE_GAME_TYPE.COMMON, nil, nil, nil, 50)
	bullet.atlas = "images/inventoryimages/bullet.xml"
	bullet.image = "bullet.tex" 

else

	local bullet = Recipe("bullet",{Ingredient("cutstone",25),Ingredient("charcoal",25),Ingredient
("flint",25)},RECIPETABS.WAR,TECH.SCIENCE_TWO,RECIPE_GAME_TYPE.COMMON, nil, nil, nil, 50)
	bullet.atlas = "images/inventoryimages/bullet.xml"
	bullet.image = "bullet.tex" 
end

Now this only managed to make the mod (and game) crash the second I enable it.

I've also tried to keep the function with it.. but that didn't work out either. I suspect it might be the amount of bullets and the nil values, but unfortunately I'm running empty on ideas on what to change about those.

Any suggestions from the modder community? Pretty please?

Link to comment
Share on other sites

Alright, I hate to have spammed the forum for nothing, but it seems like I found a solution.

The idea about the function wasn't entirely wrong, apparently, but as JustJaspers "Magical Bottle Lanterns" made me aware my ideas on how to implement that were just way off. I will not post the code here since it is copy + pasted from the original author (as my mod is only for my own use after all and will never be uploaded).

I was also on the right track about the nil values (only 1 now, not 3 as before) and RECIPE_GAME_TYPE.COMMON actually needs to be just "common". 

Just thought I'd mention in case it helps anyone else out with a similiar problem.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...