AkaiNight Posted January 10, 2020 Share Posted January 10, 2020 well im using this code for night vision but i want it just for new moon but it gives night vision every night i don't know what to do local function MoonsCurse(inst) if TheWorld.state.isnight then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) inst.components.talker:Say("The curse has gone We are finally free! Nya~") end if TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("I can feel the curse of moon. The moon binds us! Nya~") end end if TheWorld.state.isdusk then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod (0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.components.talker:Say("I can't feel the moon. Finally i can be free. Nya~") end if TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("Oh! I can feel the moon. This night will be cursed. Nya~") end end if TheWorld.state.isday then inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) end end Link to comment Share on other sites More sharing options...
Ultroman Posted January 10, 2020 Share Posted January 10, 2020 Remove the if-statements which say if TheWorld.state.moonphase == "full" then You don't seem to ever turn it off again. You should do that in the if TheWorld.state.isday then if-statement. Link to comment Share on other sites More sharing options...
AkaiNight Posted January 10, 2020 Author Share Posted January 10, 2020 (edited) 3 hours ago, Ultroman said: Remove the if-statements which say if TheWorld.state.moonphase == "full" then You don't seem to ever turn it off again. You should do that in the if TheWorld.state.isday then if-statement. im not sure what you exactly mean but something like this i suppoise local function MoonsCurse(inst) if TheWorld.state.isnight then TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) inst.components.talker:Say("The curse has gone We are finally free! Nya~") TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("I can feel the curse of moon. The moon binds us! Nya~") end or something like this local function MoonsCurse(inst) if TheWorld.state.isnight then TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) inst.components.talker:Say("The curse has gone We are finally free! Nya~") inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("I can feel the curse of moon. The moon binds us! Nya~") else inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) end Edited January 10, 2020 by AkaiNight Link to comment Share on other sites More sharing options...
Ultroman Posted January 10, 2020 Share Posted January 10, 2020 (edited) No. Not at all. Neither of those compile. Please take the Lua Crash Course linked in the newcomer post. It's very difficult to help modders who don't know what an if-statement is. It'll save you SO MUCH TIME! All the stuff in the newcomer post will. local function MoonsCurse(inst) if TheWorld.state.isnight then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) inst.components.talker:Say("The curse has gone We are finally free! Nya~") end end if TheWorld.state.isday then inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) inst.Light:Enable(false) inst.components.talker:Say("The curse falls upon me!") end end But as you can see, the code still also alters AttackPeriod, walkspeed and runspeed. If you're only after the night vision, then you don't need those lines. Edited January 10, 2020 by Ultroman Link to comment Share on other sites More sharing options...
AkaiNight Posted January 11, 2020 Author Share Posted January 11, 2020 (edited) 23 hours ago, Ultroman said: No. Not at all. Neither of those compile. Please take the Lua Crash Course linked in the newcomer post. It's very difficult to help modders who don't know what an if-statement is. It'll save you SO MUCH TIME! All the stuff in the newcomer post will. local function MoonsCurse(inst) if TheWorld.state.isnight then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) inst.components.talker:Say("The curse has gone We are finally free! Nya~") end end if TheWorld.state.isday then inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) inst.Light:Enable(false) inst.components.talker:Say("The curse falls upon me!") end end But as you can see, the code still also alters AttackPeriod, walkspeed and runspeed. If you're only after the night vision, then you don't need those lines. i do need them i just have problem with night vision. It must be only on new moon. And what about this this should be fine right?? local function MoonsCurse(inst) if TheWorld.state.isnight then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.AddTag("nighty") end if TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("I can feel the curse of moon. The moon binds us! Nya~") end end if TheWorld.state.isdusk then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod (0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.components.talker:Say("I can't feel the moon. Finally i can be free. Nya~") end if TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("Oh! I can feel the moon. This night will be cursed. Nya~") end end if TheWorld.state.moonphase not == "new" then inst.RemoveTag("nighty") end if inst.HasTag("nighty") then inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) end if TheWorld.state.isday then inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) end end Edited January 11, 2020 by AkaiNight Link to comment Share on other sites More sharing options...
Ultroman Posted January 12, 2020 Share Posted January 12, 2020 (edited) No. Don't use tags like that. If you're gonna do that, just use a bool. If you still need all the other code, then this should work: local function MoonsCurse(inst) if TheWorld.state.isnight then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod(0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.Light:Enable(true) inst.Light:SetRadius(18) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.7) inst.Light:SetColour(70/255,230/255,12/170) -- Indicate with a bool on our character that nightvision has been enabled. inst.nightvisionIsEnabled = true inst.components.talker:Say("The curse has gone We are finally free! Nya~") end if TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("I can feel the curse of moon. The moon binds us! Nya~") end else -- If it is not night, disable the nightvision. That way it resets whenever it changes away from night. -- We don't want to call inst.Light:Enable(false) all the time, though, since the player's light source -- is also used for other things, such as, when they get struck by lightning(!) -- So, we limit ourselves to only calling it if our bool indicates that nightvision is enabled. if inst.nightvisionIsEnabled then -- Disable the light. inst.Light:Enable(false) -- Reset our indicator. inst.nightvisionIsEnabled = false end end if TheWorld.state.isdusk then if TheWorld.state.moonphase == "new" then inst.components.combat:SetAttackPeriod (0.4) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 10 inst.components.talker:Say("I can't feel the moon. Finally i can be free. Nya~") end if TheWorld.state.moonphase == "full" then inst.components.combat:SetAttackPeriod (0.8) inst.components.locomotor.walkspeed = 3.2 inst.components.locomotor.runspeed = 4 inst.components.talker:Say("Oh! I can feel the moon. This night will be cursed. Nya~") end end if TheWorld.state.isday then inst.components.locomotor.walkspeed = 4.6 inst.components.locomotor.runspeed = 7 inst.components.combat:SetAttackPeriod (0.6) end end Edited January 12, 2020 by Ultroman Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now