Jump to content

Little problems with custom character (coding)


Recommended Posts

Well I'm trying to make my character only can eat fish, fishsticks, fishtacos and ice. Is it possible? And also i need a code for can't open chester and can't pick up chester bone i was using this but not works.

local function OnPickup(inst)
	if data.prefab == "chester_eyebone" then
		local eyebone = data.prefab
		inst.components.sanity:DoDelta(-30)
		inst.components.inventory:DropItem(eyebone)
		inst.components.talker:Say("It's the cursed bone for us. Nya~")
	end
end

	inst:ListenForEvent("onpickup", OnPickup)

It won't give any errors but just not works

also i need a code for gain sanity when snow raining and lose sanity when raining.

 

Thanks for help.

 

Also there is an error that when i take damage game crashes. But i didin't understand any simple thing here is alisha.lua and client_log also modmain.lua

 

 

 

 

client_log.txt

alishia.lua

modmain.lua

Edited by AkaiNight
Link to comment
Share on other sites

Ive only eyeballed the files alishia and the modmain and the only errors that stand out are the following:

alishia.lua:

local start_inv = {
    "fishingrod", --missing a comma, syntax error fixed
}

local damage = data.damage --line 94, syntax error fixed

Modmain.lua:

PrefabFiles= {

"chester_eyebone", --line 4, missing comma syntax error fixed

    }

other wise the code is a bit lengthy for me to make a sound judgement on what else could be a error or works. Last I can't make out what you mean by "gain sanity on snow raining and lose sanity when raining", usually its either or (its raining or its snowing) code wise. 

Link to comment
Share on other sites

23 hours ago, K1NGT1GER609 said:

Ive only eyeballed the files alishia and the modmain and the only errors that stand out are the following:

alishia.lua:

local start_inv = {
    "fishingrod", --missing a comma, syntax error fixed
}

local damage = data.damage --line 94, syntax error fixed

Modmain.lua:

PrefabFiles= {

"chester_eyebone", --line 4, missing comma syntax error fixed

Well all that i understand from here is that you fixed lots of problem.

 

23 hours ago, K1NGT1GER609 said:

ther wise the code is a bit lengthy for me to make a sound judgement on what else could be a error or works. Last I can't make out what you mean by "gain sanity on snow raining and lose sanity when raining", usually its either or (its raining or its snowing) code wise. 

About this, i mean my character has snowy aura and when snowing she must have sanity gain bonus like 1sanity per  3 seconds also when normal raining she must lose 3 sanity per 3 seconds.

Link to comment
Share on other sites

Here...

local function onisraining(inst, israining)
    if TheWorld.state.israining then
    inst.components.sanity:DoDelta(-3, 3)
    elseif TheWorld.state.issnowing then
    inst.components.sanity:DoDelta(1, 3)
    end
end

local master_postinit = function(inst) --reference on where it goes

inst:DoPeriodicTask(3, onisraining, nil, inst)

Not sure why wx-78's code for raining didn't work for the life of me but this one seems to suit what your looking for.

Link to comment
Share on other sites

1 hour ago, K1NGT1GER609 said:

Here...

local function onisraining(inst, israining)
    if TheWorld.state.israining then
    inst.components.sanity:DoDelta(-3, 3)
    elseif TheWorld.state.issnowing then
    inst.components.sanity:DoDelta(1, 3)
    end
end

local master_postinit = function(inst) --reference on where it goes

inst:DoPeriodicTask(3, onisraining, nil, inst)

Not sure why wx-78's code for raining didn't work for the life of me but this one seems to suit what your looking for.

Thank you

 

Link to comment
Share on other sites

On 27.03.2018 at 7:50 PM, K1NGT1GER609 said:

Here...

local function onisraining(inst, israining)
    if TheWorld.state.israining then
    inst.components.sanity:DoDelta(-3, 3)
    elseif TheWorld.state.issnowing then
    inst.components.sanity:DoDelta(1, 3)
    end
end

local master_postinit = function(inst) --reference on where it goes

inst:DoPeriodicTask(3, onisraining, nil, inst)

Not sure why wx-78's code for raining didn't work for the life of me but this one seems to suit what your looking for.

Hi again there is a little problem here i did it and it worked but i tried to add a speech line there but it says it over and over again when raining. Is there any possible way to make it says just once when rain or snow start? here is code.

local function OnRaining(inst, israining)
	if TheWorld.state.israining then
		inst.components.sanity:DoDelta(-3, 3)
		inst.components.talker:Say("The rain... Must stop now!. Nya~")
	elseif TheWorld.state.issnowing then
		inst.components.sanity:DoDelta(1, 3)
		inst.components.talker:Say("Look at that beauty it relaxes... Nya~")
	end
end

 

Edited by AkaiNight
Link to comment
Share on other sites

Then go with this one for one phrase (the one before for constant sanity drain):

local function onephrase(inst, israining)
   if TheWorld.state.israining then
        inst.components.talker:Say("The rain... Must stop now!. Nya~")
    elseif TheWorld.state.issnowing then
        inst.components.talker:Say("Look at that beauty it relaxes... Nya~")
    end
end

local master_postinit = function(inst) --reference

inst:WatchWorldState("israining", onephrase)
    onephrase(inst, TheWorld.state.israining)

I haven't considered if the ghost version says the phrase so just a heads up.

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