Jump to content

How to edit a state from SGwilson?

Recommended Posts

Hello, I need some help if someone could help me that'd really be great :D!

So, I'm trying to make a action for my character, & the character can move while preforming it. However, the problem is when my character moves while doing it, it makes my character play the run anim, canceling the the action's anim..

Here's the code!


local function powerup(act)
   if act.target.powerup == nil then

	     act.target.powerup = true
	     act.target.components.locomotor:SetExternalSpeedMultiplier(act.target, "powerup", 1.25)

	  act.target:DoTaskInTime(.5, function()
	     ShakeAllCameras(CAMERASHAKE.VERTICAL,.4, .04, .4, act.target, .01)
	     act.target.components.locomotor:RemoveExternalSpeedMultiplier(act.target, "jumping")
	     act.target.powerup = nil


So, is there a way I can make it that no other anim interrupts this anim while this action is being played? Maybe with a certain value or something?

Thanks so much for reading my problem & have a great day/night :D!!

Edited by SuperDavid
Link to comment
Share on other sites

Maybe I can change the run state to not play any anim with certain value, but how would I edit the run state? If I copypaste SGwilson then edit it then any new states or mod states would crash the game :(..

Link to comment
Share on other sites

I am not sure if that helps you but I had a similar problem on my mod where I needed to increase the speed of an action and ended up hijacking the UpdateState-method and just replaced the current state with my own altered state-table.

Maybe you can use that approach for your mod too:


local origin_updateState = player.sg.UpdateState
player.sg.UpdateState = function(...)
	if not player.sg.currentstate then 
		player.sg.currentstate = YOUR_OWN_STATE


You can see the code working in this mod (in scripts/components/DsMMO.lua):



The function for creating my own state ( DsMMO:update_actionSpeed ) is at line 924.

UpdateState is replaced at line 816

Edited by Jodlio
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

  • Create New...