Randriko Posted March 23, 2019 Share Posted March 23, 2019 (edited) Hello everyone. I'm making a Incineroar character mod and i'm having trouble with the coding. I was thinking his perks could be He's on fire, so he shines and has a warm aura I managed to add the glow but i can't get the aura to work and I also want to make him weaker during rain. I have been copying other mods and editing their scripts but i can't make it work. This is one of the codes i tried for the wam aura Quote inst:AddComponent("heater") inst.components.heater.heat = MAX_HEAT local MIN_HEAT = 15 local MAX_HEAT = 210 but im not even sure where i had to paste it And i tried this for the rainy thing Quote if TheWorld.state.israining then act.target.components.combat.damagemultiplier = act.target.components.combat.damagemultiplier / 2 end but it crashed This is my first mod. I don't know anything about this I will gladly accept any feedback or suggestions for the mod. In case you don't know the character, it's a fire dark pokemon! (((( If anyone want to see how he looks (outdated, all anim are finished); ))) EDIT: attached .lua incineroar.lua Edited March 23, 2019 by Randriko Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/ Share on other sites More sharing options...
Ultroman Posted March 23, 2019 Share Posted March 23, 2019 This is kind of complicated stuff for someone's first mod. Congratulations on getting this far! I highly recommend looking at my newcomer post. The tips and links in there will save you a lot of time in the long run. Especially the LUA Crash Course and the Debugging section. The heater-thing looks right, except you're declaring the variables after using them. But you can simply do this (in your master_postinit): inst:AddComponent("heater") inst.components.heater.heat = 150 The code you posted doesn't make use of the MIN_HEAT variable, so I'm guessing you're missing some code from wherever you took it, but this snippet will let you set a static heat. The radius is controlled by the "observers" i.e. players by their temperature-component which only reacts to heaters within a certain radius. Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1168833 Share on other sites More sharing options...
ShinyMoogle Posted March 23, 2019 Share Posted March 23, 2019 Heater If you want to use variables, you'll need to declare them in your character prefab before calling them in your master_postinit function (this is also where you add most components to your character prefab). Take a quick look at how it's coded in lavae_pet.lua for a basic implementation. You can also just assign a value manually like is done in lava_pond.lua. If you want something more complex with varying degrees of heat, you'll need to add a function in inst.components.heater.heatfn that will return a value for the emitted temperature - refer to heatrock.lua for an example there. (from lava_pond.lua) inst:AddComponent("heater") inst.components.heater.heat = 500 Rain It's hard to troubleshoot a tiny snippet of code like that by itself, without knowing where it lies in your code or a crash log. I'd hazard a guess that your crash is due to that particular code block not recognizing what you're referring to with "act.target". In general though, functions won't do anything by themselves unless they're called by something else somewhere. You need something to tell the game, "hey, run this piece of code when [x] happens to check if it's raining and do stuff." Fortunately I think there is a pretty easy way to handle this one using WatchWorldState. You can see an example in wx78.lua, where WX-78 is coded to start emitting sparks when it starts raining. You'll want to create a custom function to be called with WatchWorldState that will adjust your damage multiplier depending on whether or not it's raining. (from wx78.lua) local function onisraining(inst, israining) if israining then if inst.spark_task == nil then inst.spark_task = inst:DoPeriodicTask(.1, dorainsparks, nil, .1) end elseif inst.spark_task ~= nil then inst.spark_task:Cancel() inst.spark_task = nil end end local function onbecamerobot(inst) if not inst.watchingrain then inst.watchingrain = true inst:WatchWorldState("israining", onisraining) onisraining(inst, TheWorld.state.israining) end --Override with overcharge light values inst.Light:Enable(false) inst.Light:SetRadius(2) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.9) inst.Light:SetColour(235 / 255, 121 / 255, 12 / 255) end Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1168835 Share on other sites More sharing options...
Randriko Posted March 23, 2019 Author Share Posted March 23, 2019 (edited) 2 hours ago, Ultroman said: This is kind of complicated stuff for someone's first mod. Congratulations on getting this far! I highly recommend looking at my newcomer post. The tips and links in there will save you a lot of time in the long run. Especially the LUA Crash Course and the Debugging section. The heater-thing looks right, except you're declaring the variables after using them. But you can simply do this (in your master_postinit): inst:AddComponent("heater") inst.components.heater.heat = 150 The code you posted doesn't make use of the MIN_HEAT variable, so I'm guessing you're missing some code from wherever you took it, but this snippet will let you set a static heat. The radius is controlled by the "observers" i.e. players by their temperature-component which only reacts to heaters within a certain radius. Would my character feel the heat too? 2 hours ago, ShinyMoogle said: Heater If you want to use variables, you'll need to declare them in your character prefab before calling them in your master_postinit function (this is also where you add most components to your character prefab). Take a quick look at how it's coded in lavae_pet.lua for a basic implementation. You can also just assign a value manually like is done in lava_pond.lua. If you want something more complex with varying degrees of heat, you'll need to add a function in inst.components.heater.heatfn that will return a value for the emitted temperature - refer to heatrock.lua for an example there. (from lava_pond.lua) inst:AddComponent("heater") inst.components.heater.heat = 500 Rain It's hard to troubleshoot a tiny snippet of code like that by itself, without knowing where it lies in your code or a crash log. I'd hazard a guess that your crash is due to that particular code block not recognizing what you're referring to with "act.target". In general though, functions won't do anything by themselves unless they're called by something else somewhere. You need something to tell the game, "hey, run this piece of code when [x] happens to check if it's raining and do stuff." Fortunately I think there is a pretty easy way to handle this one using WatchWorldState. You can see an example in wx78.lua, where WX-78 is coded to start emitting sparks when it starts raining. You'll want to create a custom function to be called with WatchWorldState that will adjust your damage multiplier depending on whether or not it's raining. (from wx78.lua) local function onisraining(inst, israining) if israining then if inst.spark_task == nil then inst.spark_task = inst:DoPeriodicTask(.1, dorainsparks, nil, .1) end elseif inst.spark_task ~= nil then inst.spark_task:Cancel() inst.spark_task = nil end end local function onbecamerobot(inst) if not inst.watchingrain then inst.watchingrain = true inst:WatchWorldState("israining", onisraining) onisraining(inst, TheWorld.state.israining) end --Override with overcharge light values inst.Light:Enable(false) inst.Light:SetRadius(2) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.9) inst.Light:SetColour(235 / 255, 121 / 255, 12 / 255) end A friend already told me to take a look into Wx78 But i have no idea about coding :/ edit: like this? where would i paste this? Quote local function WatchWorldState (inst) if israining then inst.components.combat.damagemultiplier = 0.6 (less than 1 is less dmg i guess right?) end Edited March 23, 2019 by Randriko Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1168859 Share on other sites More sharing options...
ShinyMoogle Posted March 24, 2019 Share Posted March 24, 2019 If you're unfamiliar with coding in general, I'd definitely recommend looking through the link Ultroman posted above! Learning the basics enough to be able to follow existing code (variables, functions, etc.) is a huge help, and generally applicable to anything you might need to look at code for. Even if you don't immediately know all the specific functions and syntax, you can roughly grasp what's happening. WatchWorldState is an existing function - you'll be using it, not declaring a new local one. Try to emulate what's being done in the WX-78 code. I'll try and outline the order things are happening in the wx78.lua file, but definitely take a look at the guides posted if stuff is going over your head. local function onisraining(inst, israining): When called, this will check to see if it's raining or not, and do stuff accordingly. You want to set your lowered damage multiplier here. You also need to make sure to set your damage multiplier back to its original value here! If you don't, then you will do 60% damage forever*, even after it stops raining. *until you restart local function onbecamerobot(inst): A bit of an intermediate step paired with onbecameghost, which only runs the weather check if you're not dead. Optional, but it's more efficient code-wise. This is where you call inst:WatchWorldState("israining", onisraining). It tells the entity to listen for changes in the weather, and then calls onisraining when the rain state changes. local function master_postinit: This is all run when the player character is created for each game session, and where you tell the game to start event listeners for events such as dying and being revived. In wx78.lua, these listeners are responsible for calling onbecamerobot above. It also calls onbecamerobot (which, in turn, calls onisraining) at the very start to do the appropriate action for the current weather state. Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1168886 Share on other sites More sharing options...
Randriko Posted March 24, 2019 Author Share Posted March 24, 2019 (edited) I made it! He's way weaker now during the rain! @ShinyMoogle And hes so hot but only friends can feel it, i would like him to feel a bit but this is ok! @Ultroman Thanks for the help!! Edited March 24, 2019 by Randriko Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1169019 Share on other sites More sharing options...
ShinyMoogle Posted March 24, 2019 Share Posted March 24, 2019 For the temperature thing, it will depend on what you mean when you want Incineroar to feel heat. Do you want him to freeze slower? Overheat faster, or not overheat at all? Slowly gain heat over time (this one will take a bit of extra coding)? Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1169084 Share on other sites More sharing options...
Randriko Posted March 24, 2019 Author Share Posted March 24, 2019 5 hours ago, ShinyMoogle said: For the temperature thing, it will depend on what you mean when you want Incineroar to feel heat. Do you want him to freeze slower? Overheat faster, or not overheat at all? Slowly gain heat over time (this one will take a bit of extra coding)? I guess it would be both Overheat faster and freeze slower Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1169140 Share on other sites More sharing options...
ShinyMoogle Posted March 25, 2019 Share Posted March 25, 2019 All of that is controlled in the character's temperature component in temperature.lua. Take a look through the component - most of that functionality should be a pretty straightforward task of setting the right variables to some custom values. The insulation variables handle your freezing/overheating rates - "inherentinsulation" is your insulation against colder temperatures, while "inherentsummerinsulation" is insulation against hotter temperatures. There are a few other variables you might want to check out in the component as well, such as your overheating threshold. Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1169475 Share on other sites More sharing options...
Randriko Posted March 27, 2019 Author Share Posted March 27, 2019 On 25/3/2019 at 11:36 PM, ShinyMoogle said: All of that is controlled in the character's temperature component in temperature.lua. Take a look through the component - most of that functionality should be a pretty straightforward task of setting the right variables to some custom values. The insulation variables handle your freezing/overheating rates - "inherentinsulation" is your insulation against colder temperatures, while "inherentsummerinsulation" is insulation against hotter temperatures. There are a few other variables you might want to check out in the component as well, such as your overheating threshold. Thanks! I may look into it This is the workshop post for the mod btw in case you want it! https://steamcommunity.com/sharedfiles/filedetails/?id=1692001338 Link to comment https://forums.kleientertainment.com/forums/topic/104131-character-mod-help/#findComment-1169922 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