AzurasLight Posted February 17, 2016 Share Posted February 17, 2016 (edited) Hi everyone, I'm pretty new in the modding of character and I need your advices. I'd like to make my character run pretty fast when it's "day" period, a little less faster during "dawn" period, and at the same speed as Wilson at "night". Do you guys know how I could do this ? I guess it's in the "scripts" and "prefabs" folders and into the character's_name.lua file, but I don't know how to do this, but I know that it's possible. Thank you for your attention ! Edited February 17, 2016 by AzurasLight Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/ Share on other sites More sharing options...
Kzisor Posted February 18, 2016 Share Posted February 18, 2016 On 2/17/2016 at 2:57 PM, AzurasLight said: Hi everyone, I'm pretty new in the modding of character and I need your advices. I'd like to make my character run pretty fast when it's "day" period, a little less faster during "dawn" period, and at the same speed as Wilson at "night". Do you guys know how I could do this ? I guess it's in the "scripts" and "prefabs" folders and into the character's_name.lua file, but I don't know how to do this, but I know that it's possible. Thank you for your attention ! prefab file local day_speed = 5 local dusk_speed = 2.5 local night_speed = 1 local function onphase(inst, phase) local speed = 1 if phase == "day" then speed = day_speed elseif phase == "dusk" then speed = dusk_speed else speed = night_speed end inst.components.locomotor:SetExternalSpeedMultiplier( inst, "Acceleration", speed ) end master_postinit inst:WatchWorldState("phase", onphase) Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724412 Share on other sites More sharing options...
SenL Posted February 19, 2016 Share Posted February 19, 2016 Wow cool code. What is "Acceleration"? I see the function takes 3 params: source, key and m. source is inst. speed is m. key is "Acceleration" ... is this just a custom key of locomotor internal array? Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724432 Share on other sites More sharing options...
Kzisor Posted February 19, 2016 Share Posted February 19, 2016 Just now, SenL said: Wow cool code. What is "Acceleration"? I see the function takes 3 params: source, key and m. source is inst. speed is m. key is "Acceleration" ... is this just a custom key of locomotor internal array? This is correct, because we need to have a way of knowing which speed multiplier to change. Technically you can have N speed multipliers on your character, where N is infinite(or as large as lua allows arrays). Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724435 Share on other sites More sharing options...
SenL Posted February 19, 2016 Share Posted February 19, 2016 (edited) So it can be any literal string we want? Also speed =5 at day ... won't that be extremely fast? even 1.4 is very fast already. Edited February 19, 2016 by SenL Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724436 Share on other sites More sharing options...
Kzisor Posted February 19, 2016 Share Posted February 19, 2016 2 minutes ago, SenL said: So it can be any literal string we want? Yes any string which lua allows. Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724438 Share on other sites More sharing options...
SenL Posted February 19, 2016 Share Posted February 19, 2016 (edited) I got a crash on "inst:WatchWorldState("phase", onphase)" saying attempting to index global 'inst' (a nil value). Maybe put in prefab lua? Edit: Omg I misread. Thought you said put in modmain lua. Edited February 19, 2016 by SenL Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724456 Share on other sites More sharing options...
AzurasLight Posted February 19, 2016 Author Share Posted February 19, 2016 Ah, nice it works ! Thanks a lot ! Have a nice day ! Link to comment https://forums.kleientertainment.com/forums/topic/64485-help-how-to-change-a-custom-character-speed/#findComment-724606 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