Lawrence Posted April 14, 2014 Share Posted April 14, 2014 (edited) Hi guys,I can't understand how to add custom Stategraph to mobs, I looked to "API examples" but it doesn't work... For example I wrote this on modmain: local stunned = State({ name = "stun", tags = {"idle", "canrotate"}, onenter = function(inst) inst.Transform:SetRotation(0) inst.AnimState:PushAnimation("idle_loop", true) end, timeline = { TimeEvent(20*FRAMES, function(inst) inst.Transform:SetRotation(90) end), TimeEvent(40*FRAMES, function(inst) inst.Transform:SetRotation(180) end), TimeEvent(60*FRAMES, function(inst) inst.Transform:SetRotation(270) end), TimeEvent(80*FRAMES, function(inst) inst.Transform:SetRotation(0) end), TimeEvent(100*FRAMES, function(inst) inst.sg:GoToState("idle") end), }, events = { EventHandler("animover", function(inst) inst.sg:GoToState("idle") end ), },}) then I triedAddStategraphState("pigman", stunned), but results in "TRIED TO GO TO INVALID STATE";so I wrote AddStategraphState("pig", stunned), no errors showing in this way, but the pigs doesn't do anything. What am I doing wrong? Can you help me? Thanks. Edited April 14, 2014 by Lawrence Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/ Share on other sites More sharing options...
simplex Posted April 14, 2014 Share Posted April 14, 2014 (edited) Hi guys,I can't understand how to add custom Stategraph to mods, I looked to "API examples" but it doesn't work... For example I wrote this on modmain: (stuff) then I triedAddStategraphState("pigman", stunned), but results in "TRIED TO GO TO INVALID STATE";so I wrote AddStategraphState("pig", stunned), no errors showing in this way, but the pigs doesn't do anything. What am I doing wrong? Can you help me? Thanks.The correct would indeed be AddStategraphState("pig", stunned)since the name of the stategraph is SGpig.lua.Your state looks right to me. My guess is there's just nothing triggering it (such as event or action handlers). If you spawn a pigman and then do inst.sg:GoToState("stun"), does it work?(by the way, if you want the state to be somewhat "permanent" until it ends, you may want to replace the "idle" tag with "busy") Edited April 14, 2014 by simplex Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453316 Share on other sites More sharing options...
Lawrence Posted April 14, 2014 Author Share Posted April 14, 2014 (edited) The correct would indeed be AddStategraphState("pig", stunned)since the name of the stategraph is SGpig.lua.Your state looks right to me. My guess is there's just nothing triggering it (such as event or action handlers). If you spawn a pigman and then do inst.sg:GoToState("stun"), does it work?(by the way, if you want the state to be somewhat "permanent" until it ends, you may want to replace the "idle" tag with "busy") I made a sort of staff that should stun mobs and yeah, I used inst.sg:GoToState("stun") but doesn't do anythingNow I'm trying to replace idle with busy Edited April 14, 2014 by Lawrence Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453323 Share on other sites More sharing options...
Lawrence Posted April 14, 2014 Author Share Posted April 14, 2014 (edited) The correct would indeed be AddStategraphState("pig", stunned)since the name of the stategraph is SGpig.lua.Your state looks right to me. My guess is there's just nothing triggering it (such as event or action handlers). If you spawn a pigman and then do inst.sg:GoToState("stun"), does it work?(by the way, if you want the state to be somewhat "permanent" until it ends, you may want to replace the "idle" tag with "busy") Ok, with "busy" at least the pig rotates to 0 (from inst.Transform:SetRotation(0) ), but does not spin :/ should I add an action? Edited April 14, 2014 by Lawrence Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453327 Share on other sites More sharing options...
simplex Posted April 14, 2014 Share Posted April 14, 2014 Ok, with "busy" at least the pig rotates to 0 (from inst.Transform:SetRotation(0) ), but does not spin :/ should I add an action? Try commenting out your animover event handler. Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453341 Share on other sites More sharing options...
Lawrence Posted April 14, 2014 Author Share Posted April 14, 2014 Try commenting out your animover event handler. Mmh... Now it goes on idle for ever, but no spins yet Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453349 Share on other sites More sharing options...
simplex Posted April 14, 2014 Share Posted April 14, 2014 Mmh... Now it goes on idle for ever, but no spins yet I don't know what to tell you. I just took the code snippet you posted, changed the "idle" tag to "busy", commented out the "animover" event handler, spawned a pig and put it in the stun state with inst.sg:GoToState("stun"). It worked, with each step of the 90 degree rotation happening properly. Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453365 Share on other sites More sharing options...
Lawrence Posted April 14, 2014 Author Share Posted April 14, 2014 I don't know what to tell you. I just took the code snippet you posted, changed the "idle" tag to "busy", commented out the "animover" event handler, spawned a pig and put it in the stun state with inst.sg:GoToState("stun"). It worked, with each step of the 90 degree rotation happening properly. It seems that it skips everything inside " timeline = { ... } "what the ...? o_o Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453368 Share on other sites More sharing options...
simplex Posted April 14, 2014 Share Posted April 14, 2014 It seems that it skips everything inside " timeline = { ... } " what the ...? o_o It seems something else in your code is causing a change of state right after it enters the stun state. Probably the onattacked event handler. Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453371 Share on other sites More sharing options...
Lawrence Posted April 14, 2014 Author Share Posted April 14, 2014 (edited) No, sorry I was wrong it works xDsorry I'm stupid somethimes(and with sometimes I mean always) Edited April 14, 2014 by Lawrence Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453372 Share on other sites More sharing options...
Lawrence Posted April 14, 2014 Author Share Posted April 14, 2014 No, sorry I was wrong it works xDsorry I'm stupid somethimes(and with sometimes I mean always) It seems something else in your code is causing a change of state right after it enters the stun state. Probably the onattacked event handler. Thanks a lot for the help ^_^ Link to comment https://forums.kleientertainment.com/forums/topic/34871-help-trying-to-add-a-stategraph-to-mobs/#findComment-453384 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