TheBigDeal Posted August 23, 2016 Share Posted August 23, 2016 Hello! I was wondering how I would make a modded character switch between 2 sprites on a press of a button. That's it... Thanks! Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 I did everything you would need to start in the zip folder . PS. Like me or i'll cri evertiem ... STuff.zip Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 Damn, thanks man PS Liked Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 21 minutes ago, SuperDavid said: I did everything you would need to start in the zip folder . PS. Like me or i'll cri evertiem ... STuff.zip So I do I use Key_Z or Key_122, sorta confused on the wording. I used Key_122 and it crashed saying it wasn't declared. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 (edited) Use the stuff like "Z", "LALT", "SLASH", ect. Don't use the numbers. Edited August 23, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 10 minutes ago, SuperDavid said: Use the stuff like "Z", "LALT", "SLASH", ect. Don't use the numbers. Alright, that worked, but problem, my mod, on start, is using the wrong build, any idea why that would happen? If i remove the special build it uses the right one, but as long as the special one is there it will use that. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 In your master postinit put the inst.AnimState:SetBuild("NORMAL BUILD") & not the special one then when the world starts he will be in that texture Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 10 minutes ago, SuperDavid said: In your master postinit put the inst.AnimState:SetBuild("NORMAL BUILD") & not the special one then when the world starts he will be in that texture Didn't seem to change anything, any other ideas :/ Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 (edited) Well since i'm confused I think the simplest thing is just swap the textures from his special build into his normal build (and normal build into special biuild) & keep the names the same, that 100% should work for you & that's what I personally would do. It might confuse you so next to your special build in ur code u can do something like "-- This is really the normal build." stuff like that then u don't get confused Edited August 23, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 11 minutes ago, SuperDavid said: Well since i'm confused I think the simplest thing is just swap the textures from his special build into his normal build & keep the names the same, that 100% should work for you & that's what I personally would do. never mind, it just hit me that i never renamed some things. I thought fixing that would fix this issue, but when I press Z, he just goes invisible and won't revert back. I think it may be this? ACTIONS.TRANSFORM.code Looks a bit sketchy just .code, I don't beleive it said to change anything there, probably wrong though otherwise maybe: SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.TRANSFORM.code, inst, ACTIONS.TRANSFORM.GASTER) or SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.REVERT.code, inst, ACTIONS.REVERT.GASTER) (Gaster is the name of the Character) I'll keep looking in the meantime. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 (edited) 12 minutes ago, TheBigDeal said: SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.TRANSFORM.code, inst, ACTIONS.TRANSFORM.GASTER) or SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.REVERT.code, inst, ACTIONS.REVERT.GASTER) This's your problem. You replaced " mod_name " with " GASTER " you weren't supposed to do that or else I would've said it xD! Change " GASTER " to " mod_name " and you should be good. Edited August 23, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 it's kept mod name? Thats so weird though D: alright checking it. Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 11 minutes ago, SuperDavid said: This's your problem. You replaced " mod_name " with " GASTER " you weren't supposed to do that or else I would've said it xD No change D: Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 Can you tell me exactly what's your problem/crash then I can think how to fix it? Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 8 minutes ago, SuperDavid said: Can you tell me exactly what's your problem/crash then I can think how to fix it? Not crashing, when I press Z (button I bound to transform) the character goes invisible, and upon pressing Z again will not change back to the previous form either. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 The code I gave you can you please post it all here then I can see what you did to it then I can fix it or tell you what's the problem? Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 Definitely! Try not to judge my following instruction skills too harshly. modmain.lua: -- Turns u into ur special form when in normal form local TRANSFORM = GLOBAL.Action() TRANSFORM.str = "Transform" TRANSFORM.id = "TRANSFORM" TRANSFORM.fn = function(act) -- Insert code of what happens when you actiavte this power for example if u want to swap textures act.target.AnimState:SetBuild("gaster_void") end AddAction(TRANSFORM) -- Turns u back from from your special form & into regular form local REVERT = GLOBAL.Action() REVERT.str = "Revert" REVERT.id = "REVERT" REVERT.fn = function(act) -- Insert code of what happens when you actiavte this power if u want to swap textures act.target.AnimState:SetBuild("gaster") end AddAction(REVERT) character.lua: local function OnKeyPressed(inst, data) if data.inst == ThePlayer then if data.key == KEY_Z then if TheWorld.ismastersim then BufferedAction(inst, inst, ACTIONS.TRANSFORM):Do() else SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.TRANSFORM.code, inst, ACTIONS.TRANSFORM.mod_name) end elseif data.key == KEY_Z then if TheWorld.ismastersim then BufferedAction(inst, inst, ACTIONS.REVERT):Do() else SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.REVERT.code, inst, ACTIONS.REVERT.mod_name) end end end end should be everything that was changed unless I forgot something. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 14 minutes ago, TheBigDeal said: when I press Z (button I bound to transform) the character goes invisible, and upon pressing Z again will not change back to the previous form either. Hmm... That seems like there's something wrong with your texture builds...but I want to make sure so replace the bottom code with the one all the way at the bottom -- Turns u into ur special form when in normal form local TRANSFORM = GLOBAL.Action() TRANSFORM.str = "Transform" TRANSFORM.id = "TRANSFORM" TRANSFORM.fn = function(act) -- Insert code of what happens when you actiavte this power for example if u want to swap textures act.target.AnimState:SetBuild("gaster_void") end AddAction(TRANSFORM) -- Turns u back from from your special form & into regular form local REVERT = GLOBAL.Action() REVERT.str = "Revert" REVERT.id = "REVERT" REVERT.fn = function(act) -- Insert code of what happens when you actiavte this power if u want to swap textures act.target.AnimState:SetBuild("gaster") end AddAction(REVERT) this bottom code here -- Turns u into ur special form when in normal form local TRANSFORM = GLOBAL.Action() TRANSFORM.str = "Transform" TRANSFORM.id = "TRANSFORM" TRANSFORM.fn = function(act) -- Insert code of what happens when you actiavte this power for example if u want to swap textures act.target.AnimState:SetBuild("gaster_void") act.target.components.talker:Say("I'm transforming...") end AddAction(TRANSFORM) -- Turns u back from from your special form & into regular form local REVERT = GLOBAL.Action() REVERT.str = "Revert" REVERT.id = "REVERT" REVERT.fn = function(act) -- Insert code of what happens when you actiavte this power if u want to swap textures act.target.AnimState:SetBuild("gaster") act.target.components.talker:Say("I'm reverting...") end AddAction(REVERT) if he says those 2 sayings I added to him when you press the buttons then nothing is wrong with the code, something is wrong with your texture builds Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 20 minutes ago, SuperDavid said: Hmm... That seems like there's something wrong with your texture builds...but I want to make sure so replace the bottom code with the one all the way at the bottom -- Turns u into ur special form when in normal form local TRANSFORM = GLOBAL.Action() TRANSFORM.str = "Transform" TRANSFORM.id = "TRANSFORM" TRANSFORM.fn = function(act) -- Insert code of what happens when you actiavte this power for example if u want to swap textures act.target.AnimState:SetBuild("gaster_void") end AddAction(TRANSFORM) -- Turns u back from from your special form & into regular form local REVERT = GLOBAL.Action() REVERT.str = "Revert" REVERT.id = "REVERT" REVERT.fn = function(act) -- Insert code of what happens when you actiavte this power if u want to swap textures act.target.AnimState:SetBuild("gaster") end AddAction(REVERT) this bottom code here -- Turns u into ur special form when in normal form local TRANSFORM = GLOBAL.Action() TRANSFORM.str = "Transform" TRANSFORM.id = "TRANSFORM" TRANSFORM.fn = function(act) -- Insert code of what happens when you actiavte this power for example if u want to swap textures act.target.AnimState:SetBuild("gaster_void") act.target.components.talker:Say("I'm transforming...") end AddAction(TRANSFORM) -- Turns u back from from your special form & into regular form local REVERT = GLOBAL.Action() REVERT.str = "Revert" REVERT.id = "REVERT" REVERT.fn = function(act) -- Insert code of what happens when you actiavte this power if u want to swap textures act.target.AnimState:SetBuild("gaster") act.target.components.talker:Say("I'm reverting...") end AddAction(REVERT) if he says those 2 sayings I added to him when you press the buttons then nothing is wrong with the code, something is wrong with your texture builds So, he just says "I'm transforming" every time you hit z, never, "I'm reverting" and he is still invisible. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 (edited) Oh my god i'm an idiot ! I just noticed you put both of your powers as the button Z they have to be different ( like put X or something) or only one will work, sorry I didn't notice earilier i'm kinda tired... Edited August 23, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 8 minutes ago, SuperDavid said: Oh my god i'm an idiot ! I just noticed you put both of your powers as the button Z they have to be different ( like put X or something) or only one will work, sorry I didn't notice earilier i'm kinda tired... Haha, same, but is there no way to have it use the same, just like a toggle? I know a couple other mods were able to achieve this, at-least for testing purposes this is fine, but I feel it would get annoying for players. Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 ok ok give me a second I'll think of something Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 (edited) 10 minutes ago, SuperDavid said: ok ok give me a second I'll think of something Alright, awesome, also, just tried it out, he reverts now, completely fine, but on the special form he is still invisible, I just double checked to make sure build names and stuff were the same, and they seemed fine. EDIT: Just had an idea, if this works im a complete idiot. Edited August 23, 2016 by TheBigDeal Link to comment Share on other sites More sharing options...
. . . Posted August 23, 2016 Share Posted August 23, 2016 (edited) Get rid of both of your actions in modmain & just put this -- Turns u into ur special form when in normal form local TRANSFORM = GLOBAL.Action() TRANSFORM.str = "Transform" TRANSFORM.id = "TRANSFORM" TRANSFORM.fn = function(act) if act.target.normal_mode == true then act.target.normal_mode = nil act.target.AnimState:SetBuild("gaster_void") act.target.components.talker:Say("I'm transforming...") elseif act.target.normal_mode == nil then act.target.normal_mode = true act.target.AnimState:SetBuild("gaster") act.target.components.talker:Say("I'm not transforming...") end AddAction(TRANSFORM) also replace local function OnKeyPressed(inst, data) if data.inst == ThePlayer then if data.key == KEY_Z then if TheWorld.ismastersim then BufferedAction(inst, inst, ACTIONS.TRANSFORM):Do() else SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.TRANSFORM.code, inst, ACTIONS.TRANSFORM.mod_name) end elseif data.key == KEY_Z then if TheWorld.ismastersim then BufferedAction(inst, inst, ACTIONS.REVERT):Do() else SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.REVERT.code, inst, ACTIONS.REVERT.mod_name) end end end end with this V local function OnKeyPressed(inst, data) if data.inst == ThePlayer then if data.key == KEY_Z then if TheWorld.ismastersim then BufferedAction(inst, inst, ACTIONS.TRANSFORM):Do() else SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.TRANSFORM.code, inst, ACTIONS.TRANSFORM.mod_name) end end end end WAIT there's more, add the code below in your master_postinit in ur character.lua i'm hoping this works fingers crossed inst.normal_mode = true Edited August 23, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
TheBigDeal Posted August 23, 2016 Author Share Posted August 23, 2016 Ok, so I think I know why he's invisible, I'm not sure how to completely word this so bare with me. I don't think I imported the build correctly in the modmain in PrefabFiles or something, I tried to put gaster_void but it gave me some errors so I assume that isn't it. Currently: PrefabFiles = { "gaster", "gaster_none", "artifact", } I think I have to do something like that but i'm not sure where completely. Hopefully I worded this good enough and such. TL;DR modmain can't find gaster_void or something. 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