Jump to content

problem with custom speed up code


Recommended Posts

here is the code i use 

local function SpeedUp(inst)
	if inst:HasTag("playerghost") then return
	
end

if TheWorld.state.isday then
	if inst.transformed and inst.components.hunger.current>=5 and inst.components.sanity.current>=5 and inst.level >= 41 then
		inst.components.hunger.current = inst.components.hunger.current - 5
		inst.components.sanity:DoDelta(-5)
		inst.components.locomotor.walkspeed = 6
		inst.components.locomotor.runspeed = 8
		inst.components.sanity.night_drain_mult = 1.5
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 3)
		inst.components.combat:SetAttackPeriod(0.5)
		inst.components.talker:Say("Ikuzoo! Nya~", 1, true)

	elseif inst.transformed and inst.components.hunger.current< 5 then
		inst.components.talker:Say("Well better eat something before run. Nya~", 1, true)
		
	elseif inst.transformed and inst.components.sanity.current< 5 then
		inst.components.talker:Say("Run? Do i know how to run? Nya~", 1, true)
	
	elseif inst.transformed and inst.level < 41 then
		inst.components.talker:Say("I must be lvl 3 for use this. Nya~", 1, true)
	
	end

elseif TheWorld.state.isnight then
	if TheWorld.state.moonphase == "new" then
		
		if inst.transformed and inst.components.hunger.current>=5 and inst.components.sanity.current>=5 and inst.level >= 41 then
		inst.components.hunger.current = inst.components.hunger.current - 5
		inst.components.sanity:DoDelta(-5)
		inst.components.locomotor.walkspeed = 8.5
		inst.components.locomotor.runspeed = 12
		inst.components.sanity.night_drain_mult = 3
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 2)
		inst.components.combat:SetAttackPeriod(0.3)
		inst.components.talker:Say("Ikuzoo! Nya~", 1, true)

	elseif inst.transformed and inst.components.hunger.current< 5 then
		inst.components.talker:Say("Well better eat something before run. Nya~", 1, true)
		
	elseif inst.transformed and inst.components.sanity.current< 5 then
		inst.components.talker:Say("Run? Do i know how to run? Nya~", 1, true)
	
	elseif inst.transformed and inst.level < 41 then
		inst.components.talker:Say("I must be lvl 3 for use this. Nya~", 1, true)
		end
	end


	elseif TheWorld.state.moonphase == "full" then
		if inst.transformed and inst.components.hunger.current>=15 and inst.components.sanity.current>=15 and inst.level >= 41 then
		inst.components.hunger.current = inst.components.hunger.current - 10
		inst.components.sanity:DoDelta(-10)
		inst.components.locomotor.walkspeed = 6.5
		inst.components.locomotor.runspeed = 7.5
		inst.components.sanity.night_drain_mult = 1.7
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 4)
		inst.components.combat:SetAttackPeriod(0.5)
		inst.components.talker:Say("Ikuzoo! Nya~", 1, true)

	elseif inst.transformed and inst.components.hunger.current< 10 then
		inst.components.talker:Say("Well better eat something before run. Nya~", 1, true)
		
	elseif inst.transformed and inst.components.sanity.current< 10 then
		inst.components.talker:Say("Run? Do i know how to run? Nya~", 1, true)
	
	elseif inst.transformed and inst.level < 41 then
		inst.components.talker:Say("I must be lvl 3 for use this. Nya~", 1, true)
		end

elseif TheWorld.state.isdusk then
	if TheWorld.state.moonphase == "new" then
		if inst.transformed and inst.components.hunger.current>=5 and inst.components.sanity.current>=5 and inst.level >= 41 then
		inst.components.hunger.current = inst.components.hunger.current - 5
		inst.components.sanity:DoDelta(-5)
		inst.components.locomotor.walkspeed = 7.5
		inst.components.locomotor.runspeed = 10
		inst.components.sanity.night_drain_mult = 2.5
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 2.5)
		inst.components.combat:SetAttackPeriod(0.35)
		inst.components.talker:Say("Ikuzoo! Nya~", 1, true)

	elseif inst.transformed and inst.components.hunger.current< 5 then
		inst.components.talker:Say("Well better eat something before run. Nya~", 1, true)
		
	elseif inst.transformed and inst.components.sanity.current< 5 then
		inst.components.talker:Say("Run? Do i know how to run? Nya~", 1, true)
	
	elseif inst.transformed and inst.level < 41 then
		inst.components.talker:Say("I must be lvl 3 for use this. Nya~", 1, true)
	end
	
	elseif TheWorld.state.moonphase == "full" then
		if inst.transformed and inst.components.hunger.current>=7 and inst.components.sanity.current>=7 and inst.level >= 41 then
		inst.components.hunger.current = inst.components.hunger.current - 7
		inst.components.sanity:DoDelta(-7)
		inst.components.locomotor.walkspeed = 7
		inst.components.locomotor.runspeed = 8
		inst.components.sanity.night_drain_mult = 2
		inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 3)
		inst.components.combat:SetAttackPeriod(0.4)
		inst.components.talker:Say("Ikuzoo! Nya~", 1, true)

	elseif inst.transformed and inst.components.hunger.current< 7 then
		inst.components.talker:Say("Well better eat something before run. Nya~", 1, true)
		
	elseif inst.transformed and inst.components.sanity.current< 7 then
		inst.components.talker:Say("Run? Do i know how to run? Nya~", 1, true)
	
	elseif inst.transformed and inst.level < 41 then
		inst.components.talker:Say("I must be lvl 3 for use this. Nya~", 1, true)
	end
end
end

	inst.transformed = not inst.transformed

	return true
end

here is the log i cant figure what is wrong (the code is in modmain.lua)

client_log_2019-11-12-06-54-35.txt

client_log.txt

Edited by AkaiNight
Link to comment
Share on other sites

[string "scripts/mainfunctions.lua"]:150: Error loading file prefabs/kitsura
[string "../mods/Kitsura/scripts/prefabs/kitsura.lua"]:47: '=' expected near 'inst'

The million dollar questions are: Which line is line 47? And why does it believe there is a = missing near something with "inst"?

Link to comment
Share on other sites

On 09.12.2019 at 2:07 AM, Ultroman said:

[string "scripts/mainfunctions.lua"]:150: Error loading file prefabs/kitsura
[string "../mods/Kitsura/scripts/prefabs/kitsura.lua"]:47: '=' expected near 'inst'

The million dollar questions are: Which line is line 47? And why does it believe there is a = missing near something with "inst"?

 inst.components.combat:SetAttackPeriod (0.4) this one and im not sure why

Link to comment
Share on other sites

6 hours ago, AkaiNight said:

inst.components.combat:SetAttackPeriod (0.4)

Are you allowed to have a space between the name of the function and the parentheses with parameters? Looking at the code, the function containing it is only used when certain worldstates change, which you have set up in the master_postinit.

inst:WatchWorldState("isday", MoonsCurse)
inst:WatchWorldState("isdusk", MoonsCurse)
inst:WatchWorldState("isnight", MoonsCurse)
inst:WatchWorldState("moonphase", MoonsCurse)

I can't remember if WatchWorldState calls the given function immediately when hooked up or only when it changes, but if it does, then line 47 is the first line of your code to be called which has that space in it. Whatever the case, you have done the same all over your code. If you get a new error when trying to remove the space on line 47, then you know it fixed it, and that you can change the rest. If you get the same error, then that wasn't the problem.

Edited by Ultroman
Link to comment
Share on other sites

43 minutes ago, Ultroman said:

Are you allowed to have a space between the name of the function and the parentheses with parameters? Looking at the code, the function containing it is only used when certain worldstates change, which you have set up in the master_postinit.


inst:WatchWorldState("isday", MoonsCurse)
inst:WatchWorldState("isdusk", MoonsCurse)
inst:WatchWorldState("isnight", MoonsCurse)
inst:WatchWorldState("moonphase", MoonsCurse)

I can't remember if WatchWorldState calls the given function immediately when hooked up or only when it changes, but if it does, then line 47 is the first line of your code to be called which has that space in it. Whatever the case, you have done the same all over your code. If you get a new error when trying to remove the space on line 47, then you know it fixed it, and that you can change the rest. If you get the same error, then that wasn't the problem.

Really??? All those time i waste for fix it and it was just a space.. thanks a lot

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