Jump to content

Problems with Weapon Coding


Recommended Posts

Hi, All

 

I'm trying to do a charactar for DST, apart from the weapon, is everything going nice.

 

With the weapon i've tried to solve my problem with this topic of danaAddams:

 

http://forums.kleien...eritem-modding/

 

 

But I didn't find what I needed and I think she's inactive for now, So I'm trying to get help from other people :/

 

I'm getting an error while oppening the game, and this is how my files look like:

 

 

modmain

PrefabFiles = {	"cory",	"lightsaber",}Assets = {    Asset( "IMAGE", "images/saveslot_portraits/cory.tex" ),    Asset( "ATLAS", "images/saveslot_portraits/cory.xml" ),    Asset( "IMAGE", "images/selectscreen_portraits/cory.tex" ),    Asset( "ATLAS", "images/selectscreen_portraits/cory.xml" ),	    Asset( "IMAGE", "images/selectscreen_portraits/cory_silho.tex" ),    Asset( "ATLAS", "images/selectscreen_portraits/cory_silho.xml" ),    Asset( "IMAGE", "bigportraits/cory.tex" ),    Asset( "ATLAS", "bigportraits/cory.xml" ),		Asset( "IMAGE", "images/map_icons/cory.tex" ),	Asset( "ATLAS", "images/map_icons/cory.xml" ),		Asset( "IMAGE", "images/avatars/avatar_cory.tex" ),    Asset( "ATLAS", "images/avatars/avatar_cory.xml" ),		Asset( "IMAGE", "images/avatars/avatar_ghost_cory.tex" ),    Asset( "ATLAS", "images/avatars/avatar_ghost_cory.xml" ),}local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGS-- The character select screen linesSTRINGS.CHARACTER_TITLES.cory = "The Desperate Nerd"STRINGS.CHARACTER_NAMES.cory = "Cory"STRINGS.CHARACTER_DESCRIPTIONS.cory = "*Has a mysterious hate of hounds.\n*Loves Technology.\n*Is Friendly."STRINGS.CHARACTER_QUOTES.cory = "\"It's over 9000!\""-- Custom speech stringsSTRINGS.CHARACTERS.CORY = require "speech_cory"-- The character's name as appears in-game STRINGS.NAMES.CORY = "Cory"-- The default responses of examining the characterSTRINGS.CHARACTERS.GENERIC.DESCRIBE.CORY = {	GENERIC = "Look! Is Cory!",	ATTACKER = "Cory looks shifty...",	MURDERER = "Murderer!",	REVIVER = "Cory, Wuuuuuuuuu...",	GHOST = "A heart would be useful for Cory.",}AddPrefabPostInit("researchlab2", function(inst)    if inst.components.sanityaura then        inst.components.sanityaura.aura = TUNING.SANITY_MED * 0.06    else        inst:AddComponent("sanityaura")        inst.components.sanityaura.aura = TUNING.SANITY_MED * 0.06    endend)AddPrefabPostInit("researchlab", function(inst)    if inst.components.sanityaura then        inst.components.sanityaura.aura = TUNING.SANITY_MED * 0.015    else        inst:AddComponent("sanityaura")        inst.components.sanityaura.aura = TUNING.SANITY_MED * 0.015    endend)local function NearbyHounds(inst)    if GLOBAL.GetPlayer().prefab == "cory" then        inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED * 1.3    endend AddPrefabPostInit("hound", NearbyHounds)AddPrefabPostInit("icehound", NearbyHounds)AddPrefabPostInit("firehound", NearbyHounds)GLOBAL.STRINGS.NAMES.lightsaber = "Nerdful Light Saber"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.lightsaber = "The best friend of a nerd."AddMinimapAtlas("images/map_icons/cory.xml")-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.AddModCharacter("cory", "MALE")

lighsaber.lua    (weapon file)

local assets ={	Asset("ANIM", "anim/lightsaber.zip"),	Asset("ANIM", "anim/swap_lightsaber.zip"),	Asset("ATLAS", "images/inventoryimages/lightsaber.xml")}local function onequip(inst, owner)     owner.AnimState:OverrideSymbol("swap_object", "swap_lightsaber", "swap_lightsaber")    owner.AnimState:Show("ARM_carry")     owner.AnimState:Hide("ARM_normal") endlocal function onunequip(inst, owner)     owner.AnimState:Hide("ARM_carry")     owner.AnimState:Show("ARM_normal") endlocal function fn()	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()    inst.entity:AddNetwork()    MakeInventoryPhysics(inst)    if not TheWorld.ismastersim then        return inst    end    inst.AnimState:SetBank("spike")    inst.AnimState:SetBuild("lightsaber")    inst.AnimState:PlayAnimation("idle")    inst:AddTag("sharp")    inst:AddComponent("weapon")    inst.components.weapon:SetDamage(44.5)    -------    inst:AddComponent("inspectable")    inst:AddComponent("inventoryitem")    inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip(onequip)    inst.components.equippable:SetOnUnequip(onunequip)	inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/inventoryimages/lightsaber.xml"			    MakeHauntableLaunch(inst)    return instendreturn Prefab("common/inventory/lightsaber", fn, assets)

cory.lua (character file)

local MakePlayerCharacter = require "prefabs/player_common"local assets = {        Asset( "ANIM", "anim/player_basic.zip" ),        Asset( "ANIM", "anim/player_idles_shiver.zip" ),        Asset( "ANIM", "anim/player_actions.zip" ),        Asset( "ANIM", "anim/player_actions_axe.zip" ),        Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),        Asset( "ANIM", "anim/player_actions_shovel.zip" ),        Asset( "ANIM", "anim/player_actions_blowdart.zip" ),        Asset( "ANIM", "anim/player_actions_eat.zip" ),        Asset( "ANIM", "anim/player_actions_item.zip" ),        Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),        Asset( "ANIM", "anim/player_actions_bugnet.zip" ),        Asset( "ANIM", "anim/player_actions_fishing.zip" ),        Asset( "ANIM", "anim/player_actions_boomerang.zip" ),        Asset( "ANIM", "anim/player_bush_hat.zip" ),        Asset( "ANIM", "anim/player_attacks.zip" ),        Asset( "ANIM", "anim/player_idles.zip" ),        Asset( "ANIM", "anim/player_rebirth.zip" ),        Asset( "ANIM", "anim/player_jump.zip" ),        Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),        Asset( "ANIM", "anim/player_teleport.zip" ),        Asset( "ANIM", "anim/wilson_fx.zip" ),        Asset( "ANIM", "anim/player_one_man_band.zip" ),        Asset( "ANIM", "anim/shadow_hands.zip" ),        Asset( "SOUND", "sound/sfx.fsb" ),        Asset( "SOUND", "sound/wilson.fsb" ),        Asset( "ANIM", "anim/beard.zip" ),        Asset( "ANIM", "anim/cory.zip" ),        Asset( "ANIM", "anim/ghost_cory_build.zip" ),}local prefabs = {}-- Custom starting itemslocal start_inv = {	"goldnugget",	"log",	"log",	"log",	"log",	"rocks",	"rocks",	"rocks",	"rocks",	"lightsaber",}-- When the character is revived from humanlocal function onbecamehuman(inst)	-- Set speed when loading or reviving from ghost (optional)	inst.components.locomotor.walkspeed = 4	inst.components.locomotor.runspeed = 6end-- When loading or spawning the characterlocal function onload(inst)    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)    if not inst:HasTag("playerghost") then        onbecamehuman(inst)    endend-- This initializes for both the server and client. Tags can be added here.local common_postinit = function(inst) 	-- Minimap icon	inst.MiniMapEntity:SetIcon( "cory.tex" )end-- This initializes for the server only. Components are added here.local master_postinit = function(inst)	-- choose which sounds this character will play	inst.soundsname = "woodie"		-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used    --inst.talker_path_override = "dontstarve_DLC001/characters/"		-- Stats		inst.components.health:SetMaxHealth(175)	inst.components.hunger:SetMax(250)	inst.components.sanity:SetMax(200)		-- Damage multiplier (optional)    inst.components.combat.damagemultiplier = 1.15		-- Hunger rate (optional)	inst.components.hunger.hungerrate = 1.25 * TUNING.WILSON_HUNGER_RATE		inst.OnLoad = onload    inst.OnNewSpawn = onloadendlocal fn = function(inst)inst:ListenForEvent("onhitother", function(inst, data)    local old_damage = inst.components.combat.defaultdamage    local weapon = inst.components.combat:GetWeapon()     if data.target:HasTag("hound") then        inst.components.combat.defaultdamage = old_damage * 1.5 --or 1.7        if weapon then            local weapon_old_damage = weapon.components.weapon.damage            weapon.components.weapon.damage = weapon_old_damage * 1.5 --or 1.7        end    else        if weapon then            weapon.components.weapon.damage = weapon_old_damage        end        inst.components.combat.defaultdamage = old_damage    endend)endlocal fn = function(inst)inst:ListenForEvent("onhitother", function(inst, data)    local old_damage = inst.components.combat.defaultdamage    local weapon = inst.components.combat:GetWeapon()     if data.target:HasTag("firehound") then        inst.components.combat.defaultdamage = old_damage * 1.5 --or 1.7        if weapon then            local weapon_old_damage = weapon.components.weapon.damage            weapon.components.weapon.damage = weapon_old_damage * 1.5 --or 1.7        end    else        if weapon then            weapon.components.weapon.damage = weapon_old_damage        end        inst.components.combat.defaultdamage = old_damage    endend)endlocal fn = function(inst)inst:ListenForEvent("onhitother", function(inst, data)    local old_damage = inst.components.combat.defaultdamage    local weapon = inst.components.combat:GetWeapon()     if data.target:HasTag("icehound") then        inst.components.combat.defaultdamage = old_damage * 1.5 --or 1.7        if weapon then            local weapon_old_damage = weapon.components.weapon.damage            weapon.components.weapon.damage = weapon_old_damage * 1.5 --or 1.7        end    else        if weapon then            weapon.components.weapon.damage = weapon_old_damage        end        inst.components.combat.defaultdamage = old_damage    endend)endreturn MakePlayerCharacter("cory", prefabs, assets, common_postinit, master_postinit, start_inv)

And this is the error that appears for me:

 

https://plus.google.com/u/0/103946558561238128109/posts/N9wit3J7VZD?pid=6172591609271452130&oid=103946558561238128109

 

 

Can you help me?

 

 

Thanks in advance.

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