Jump to content

I want give my character own item. (NOT GOOD AT ENG)


Recommended Posts

I'm really not good at english, so I can't describe my detail situation very well... And it's the first time to try making character. I already searched tips in my language, but couldn't find the solution, that's why I ask help here.

 

Test character's name is 'Mueng'.

 

I want to ...

1) give her cold resistance.

2) make own item 'Mueng Ribbon' which has similar effect to Themal Stone

3) give her own recipe of Ribbon, and no recipe in other characters.

 

I tried this and that... and I found too many errors in client log file...

 

I'm sorry that I can't describe well...

I attached the client log file, error image... and if you want, I'll attach the character file.

client_log.txt

3142124122.PNG

Link to comment
Share on other sites

It tells you right here what the problem is.

[string "../mods/mueng_DST/scripts/prefabs/muengribbon.lua"]:207: unfinished string near '"images/inventoryimages/muengribbon1'

You need to fully enclose a string with quotation marks,

This would be a good error to fix, as well. It also tells you exactly what to do.

[00:00:49]: Warning: Mod Character mueng does not currently specify a gender. Please update the call to AddModCharacter to include a gender. "FEMALE", "MALE", "ROBOT", or "NEUTRAL", or "PLURAL" 

Without your code, I can't really tell you where to do these things, but they should be pretty straight forward.

Link to comment
Share on other sites

Here is code of Ribbon. I copied code of Themal Stone and modified slightly... (changed heat rock -> muengribbon)

 

Quote

local assets=
{
    Asset("ANIM", "anim/muengribbon.zip"),    
    Asset("ATLAS", "images/inventoryimages/muengribbon1.xml"),
    Asset("ATLAS", "images/inventoryimages/muengribbon1.tex"),
    Asset("ATLAS", "images/inventoryimages/muengribbon2.xml"),
    Asset("ATLAS", "images/inventoryimages/muengribbon2.tex"),    
    Asset("ATLAS", "images/inventoryimages/muengribbon3.xml"),
    Asset("ATLAS", "images/inventoryimages/muengribbon3.tex"),
    Asset("ATLAS", "images/inventoryimages/muengribbon4.xml"),
    Asset("ATLAS", "images/inventoryimages/muengribbon4.tex"),
    Asset("ATLAS", "images/inventoryimages/muengribbon5.xml"),
    Asset("ATLAS", "images/inventoryimages/muengribbon5.tex"),
}

local function OnSave(inst, data)
    if inst.highTemp ~= nil then
        data.highTemp = math.ceil(inst.highTemp)
    elseif inst.lowTemp ~= nil then
        data.lowTemp = math.floor(inst.lowTemp)
    end
end

local function OnLoad(inst, data)
    if data ~= nil then
        if data.highTemp ~= nil then
            inst.highTemp = data.highTemp
            inst.lowTemp = nil
        elseif data.lowTemp ~= nil then
            inst.lowTemp = data.lowTemp
            inst.highTemp = nil
        end
    end
end

local function OnRemove(inst)
    inst._light:Remove()
end

-- These represent the boundaries between the ranges (relative to ambient, so ambient is always "0")
local relative_temperature_thresholds = { -30, -10, 10, 30 }

local function GetRangeForTemperature(temp, ambient)
    local range = 1
    for i,v in ipairs(relative_temperature_thresholds) do
        if temp > ambient + v then
            range = range + 1
        end
    end
    return range
end

-- Heatrock emits constant temperatures depending on the temperature range it's in
local emitted_temperatures = { -10, 10, 25, 40, 60 }

local function HeatFn(inst, observer)
    local range = GetRangeForTemperature(inst.components.temperature:GetCurrent(), TheWorld.state.temperature)
    if range <= 2 then
        inst.components.heater:SetThermics(false, true)
    elseif range >= 4 then
        inst.components.heater:SetThermics(true, false)
    else
        inst.components.heater:SetThermics(false, false)
    end
    return emitted_temperatures[range]
end

local function GetStatus(inst)
    if inst.currentTempRange == 1 then
        return "FROZEN"
    elseif inst.currentTempRange == 2 then
        return "COLD"
    elseif inst.currentTempRange == 4 then
        return "WARM"
    elseif inst.currentTempRange == 5 then
        return "HOT"
    end
end

local function UpdateImages(inst, range)
    inst.currentTempRange = range

    inst.AnimState:PlayAnimation(tostring(range), true)
    inst.components.inventoryitem:ChangeImageName("muengribbon"..tostring(range))
    if range == 5 then
        inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
        inst._light.Light:Enable(true)
    else
        inst.AnimState:ClearBloomEffectHandle()
        inst._light.Light:Enable(false)
    end
end

local function AdjustLighting(inst, range, ambient)
    if range == 5 then
        local relativetemp = inst.components.temperature:GetCurrent() - ambient
        local baseline = relativetemp - relative_temperature_thresholds[4]
        local brightline = relative_temperature_thresholds[4] + 20
        inst._light.Light:SetIntensity( math.clamp(0.5 * baseline/brightline, 0, 0.5 ) )
    else
        inst._light.Light:SetIntensity(0)
    end
end

local function TemperatureChange(inst, data)
    local ambient_temp = TheWorld.state.temperature
    local cur_temp = inst.components.temperature:GetCurrent()
    local range = GetRangeForTemperature(cur_temp, ambient_temp)

    AdjustLighting(inst, range, ambient_temp)

    if range <= 1 then
        if inst.lowTemp == nil or inst.lowTemp > cur_temp then
            inst.lowTemp = math.floor(cur_temp)
        end
        inst.highTemp = nil
    elseif range >= 5 then
        if inst.highTemp == nil or inst.highTemp < cur_temp then
            inst.highTemp = math.ceil(cur_temp)
        end
        inst.lowTemp = nil
    elseif inst.lowTemp ~= nil then
        if GetRangeForTemperature(inst.lowTemp, ambient_temp) >= 3 then
            inst.lowTemp = nil
        end
    elseif inst.highTemp ~= nil and GetRangeForTemperature(inst.highTemp, ambient_temp) <= 3 then
        inst.highTemp = nil
    end

    if range ~= inst.currentTempRange then
        UpdateImages(inst, range)

        if (inst.lowTemp ~= nil and range >= 3) or
            (inst.highTemp ~= nil and range <= 3) then
            inst.lowTemp = nil
            inst.highTemp = nil
            inst.components.fueled:SetPercent(inst.components.fueled:GetPercent() - 1 / TUNING.HEATROCK_NUMUSES)
        end
    end
end

local function OnOwnerChange(inst)
    local newowners = {}
    local owner = inst
    while owner.components.inventoryitem ~= nil do
        newowners[owner] = true

        if inst._owners[owner] then
            inst._owners[owner] = nil
        else
            inst:ListenForEvent("onputininventory", inst._onownerchange, owner)
            inst:ListenForEvent("ondropped", inst._onownerchange, owner)
        end

        local nextowner = owner.components.inventoryitem.owner
        if nextowner == nil then
            break
        end

        owner = nextowner
    end

    inst._light.entity:SetParent(owner.entity)

    for k, v in pairs(inst._owners) do
        if k:IsValid() then
            inst:RemoveEventCallback("onputininventory", inst._onownerchange, k)
            inst:RemoveEventCallback("ondropped", inst._onownerchange, k)
        end
    end

    inst._owners = newowners
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("heat_rock")
    inst.AnimState:SetBuild("muengribbon")

    inst:AddTag("muengribbon")
    inst:AddTag("icebox_valid")

    inst:AddTag("bait")
    inst:AddTag("molebait")

    --HASHEATER (from heater component) added to pristine state for optimization
    inst:AddTag("HASHEATER")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")
    inst.components.inspectable.getstatus = GetStatus

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "muengribbon"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon1
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon2
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon3
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon4
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon5
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon6
    inst:AddComponent("tradable")
    inst.components.tradable.rocktribute = 6

    inst:AddComponent("temperature")
    inst.components.temperature.current = TheWorld.state.temperature
    inst.components.temperature.inherentinsulation = TUNING.INSULATION_MED
    inst.components.temperature.inherentsummerinsulation = TUNING.INSULATION_MED
    inst.components.temperature:IgnoreTags("muengribbon")

    inst:AddComponent("heater")
    inst.components.heater.heatfn = HeatFn
    inst.components.heater.carriedheatfn = HeatFn
    inst.components.heater.carriedheatmultiplier = TUNING.HEAT_ROCK_CARRIED_BONUS_HEAT_FACTOR
    inst.components.heater:SetThermics(false, false)

    inst:AddComponent("fueled")
    inst.components.fueled.fueltype = FUELTYPE.USAGE
    inst.components.fueled:InitializeFuelLevel(100)
    inst.components.fueled:SetDepletedFn(inst.Remove)

    inst:ListenForEvent("temperaturedelta", TemperatureChange)
    inst.currentTempRange = 0

    --Create light
    inst._light = SpawnPrefab("muengribbonlight")
    inst._owners = {}
    inst._onownerchange = function() OnOwnerChange(inst) end
    --

    UpdateImages(inst, 1)
    OnOwnerChange(inst)

    MakeHauntableLaunchAndSmash(inst)

    inst.OnSave = OnSave
    inst.OnLoad = OnLoad
    inst.OnRemoveEntity = OnRemove

    return inst
end

local function lightfn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddLight()
    inst.entity:AddNetwork()

    inst:AddTag("FX")

    inst.Light:SetRadius(1)
    inst.Light:SetFalloff(0.5)
    inst.Light:SetIntensity(0.9)
    inst.Light:SetColour(235 / 255, 165 / 255, 12 / 255)
    inst.Light:Enable(false)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst.persists = false

    return inst
end

return Prefab("common/inventory/muengribbon", fn, assets),
    Prefab("muengribbonlight", lightfn)
 

 

Link to comment
Share on other sites

Like I said, you need to fully enclose strings with quotation marks. The first line here is right. What are the rest missing at the end?

    inst.components.inventoryitem.imagename = "muengribbon"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon1
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon2
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon3
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon4
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon5
    inst.components.inventoryitem.atlasname = "images/inventoryimages/muengribbon6

 

Link to comment
Share on other sites

I tried many things after I replied, and I think my character has another problem... Because it shut down before character select page. But game doesn't show the WARNING.

 

I checked the client log, and I found....

Quote

Could not load mod_config_data/modconfiguration_mueng_DST

and

Quote

Warning: Mod Character mueng already exists in the CHARACTER_GENDERS table. It was either added previously, or added twice. You only need to call AddModCharacter now.

 

 

When I deleted

Quote

table.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "mueng")

in the modmain.lua, log said to me

Quote

Warning: Mod Character mueng does not currently specify a gender. Please update the call to AddModCharacter to include a gender. "FEMALE", "MALE", "ROBOT", or "NEUTRAL", or "PLURAL

What should I do...

I tried delete all data of Ribbon, and It works...

 

Can you check my files what's wrong? Sorry...(ㅠㅁㅠ)

modmain.lua

muengribbon.lua

mueng.lua

client_log.txt

Edited by MUENG
Link to comment
Share on other sites

Quote

Could not load mod_config_data/modconfiguration_mueng_DST

...is normal, since character mods usually do not have configuration data.

1. What do you mean by

Quote

I tried delete all data of Ribbon, and It works...

???

2. Something went wrong when you posted the mueng.lua. The link doesn't work.

3. Why would you add this

Quote

table.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "mueng")

...when that's not what it asked you to do? It's saying:

Quote

Please update the call to AddModCharacter to include a gender. "FEMALE", "MALE", "ROBOT", or "NEUTRAL", or "PLURAL

 

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