Jump to content

[Help] Switching Between 2 "Forms"


Recommended Posts

20 minutes ago, SuperDavid said:

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


inst.normal_mode = true

Alright, worked awesomely, was missing an end, but worked well, invisible issue still stands though

Link to comment
Share on other sites

If you want to add textures correctly first have your exported folder like this 

and add the texture name in your character.lua under the

local assets = {
Asset( "ANIM", "anim/ghaster.zip" ),
Asset( "ANIM", "anim/ghaster_void.zip" ),
}

that should add textures correctly then you compile it.

In your "ghaster" & "ghaster_void" add all your textures you want let it compile with autocompiler which's from Don't Starve Mod Tools which you can download on Steam & your textures should be added in the game, hopefully.

Edited by SuperDavid
Link to comment
Share on other sites

17 minutes ago, SuperDavid said:

If you want to add textures correctly first have your exported folder like this New Compressed (zipped) Folder.zip

and add the texture name in your character.lua under the


local assets = {
Asset( "ANIM", "anim/ghaster.zip" ),
Asset( "ANIM", "anim/ghaster_void.zip" ),
}

that should add textures correctly then you compile it.

Eureka!

Worked great, thank you so much!. Now I set this aside earlier so now is a good time to bring it up.

Final question, you had some code in there for adding abilities when you transform, where exactly would that go now that all the code was changed pretty much?

Also any way to put a delay between transforming?

 

Sorry to be asking all these questions.

Link to comment
Share on other sites

For cooldown replace the thing in ur modmaijn with

local TRANSFORM = GLOBAL.Action()
TRANSFORM.str = "Transform"
TRANSFORM.id = "TRANSFORM"
TRANSFORM.fn = function(act)
if act.target.normal_mode == true and act.target.transform_cooldown == nil then
act.target.normal_mode = nil
act.target.transform_cooldown = true
act.target.AnimState:SetBuild("gaster_void")
act.target.components.talker:Say("I'm transforming into something special!")
act.target:DoTaskInTime(60, function() act.target.transform_cooldown = nil end) -- Cooldown = 1 minute.
elseif act.target.normal_mode == nil and act.target.transform_cooldown == nil then
act.target.normal_mode = true
act.target.AnimState:SetBuild("gaster")
act.target.components.talker:Say("I'm reverting back to normal!")
elseif act.target.transform_cooldown == true then
act.target.components.talker:Say("That's impossible...")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end
end

AddAction(TRANSFORM)

If you wanna add new abilktiues then do like on the bottom

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)

elseif data.key == KEY_X then
      if TheWorld.ismastersim then
      BufferedAction(inst, inst, ACTIONS.SOMETHING):Do()
      else
      SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.SOMETHING.code, inst, ACTIONS.SOMETHING.mod_name)
      end

elseif data.key == KEY_C then
      if TheWorld.ismastersim then
      BufferedAction(inst, inst, ACTIONS.SOMETHING):Do()
      else
      SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.SOMETHING.code, inst, ACTIONS.SOMETHING.mod_name)
      end

        end
      end
   end
end

That's how you add new abilties if your talking about what to do in modmain I'll give a example.

Say I wanted to add a abilty called FACEPALM (this's just a example :lol:) I would do in 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)

elseif data.key == KEY_X then
      if TheWorld.ismastersim then
      BufferedAction(inst, inst, ACTIONS.FACEPALM):Do()
      else
      SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.FACEPALM.code, inst, ACTIONS.FACEPALM.mod_name)
      end

        end
      end
   end
end

And in modmain.lua

local FACEPALM = GLOBAL.Action()
FACEPALM.str = "Facepalm"
FACEPALM.id = "FACEPALM"
FACEPALM.fn = function(act)
act.target.components.talker:Say("*le sigh*")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end

AddAction(FACEPALM)

Taa-daa~! you now know how to add an unlimited amount of keyhandler actions, amazing isn't it :)?

Now as thanks like all my help I gave you or I'll cri so hard everythyme R9mG9xk.gif R9mG9xk.gif R9mG9xk.gif . . .

Of course you don't have to but I would cry tears of joy everythyme I see those likes on my profile R9mG9xk.gif R9mG9xk.gif R9mG9xk.gif . . .

Edited by SuperDavid
Link to comment
Share on other sites

26 minutes ago, SuperDavid said:

For cooldown replace the thing in ur modmaijn with


local TRANSFORM = GLOBAL.Action()
TRANSFORM.str = "Transform"
TRANSFORM.id = "TRANSFORM"
TRANSFORM.fn = function(act)
if act.target.normal_mode == true and act.target.transform_cooldown == nil then
act.target.normal_mode = nil
act.target.transform_cooldown = true
act.target.AnimState:SetBuild("gaster_void")
act.target.components.talker:Say("I'm transforming into something special!")
act.target:DoTaskInTime(60, function() act.target.transform_cooldown = nil end) -- Cooldown = 1 minute.
elseif act.target.normal_mode == nil and act.target.transform_cooldown == nil then
act.target.normal_mode = true
act.target.AnimState:SetBuild("gaster")
act.target.components.talker:Say("I'm reverting back to normal!")
elseif act.target.transform_cooldown == true then
act.target.components.talker:Say("That's impossible...")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end
end

AddAction(TRANSFORM)

If you wanna add new abilktiues then do like 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)

elseif data.key == KEY_X then
      if TheWorld.ismastersim then
      BufferedAction(inst, inst, ACTIONS.SOMETHING):Do()
      else
      SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.SOMETHING.code, inst, ACTIONS.SOMETHING.mod_name)
      end

elseif data.key == KEY_C then
      if TheWorld.ismastersim then
      BufferedAction(inst, inst, ACTIONS.SOMETHING):Do()
      else
      SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.SOMETHING.code, inst, ACTIONS.SOMETHING.mod_name)
      end

        end
      end
   end
end

That's how you add new abilties if your talking about what to do in modmain I'll give a example.

Say I wanted to add a abilty called FACEPALM (this's just a example :lol:) I would do in 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)

elseif data.key == KEY_X then
      if TheWorld.ismastersim then
      BufferedAction(inst, inst, ACTIONS.FACEPALM):Do()
      else
      SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.FACEPALM.code, inst, ACTIONS.FACEPALM.mod_name)
      end

        end
      end
   end
end

And in modmain.lua


local FACEPALM = GLOBAL.Action()
FACEPALM.str = "Facepalm"
FACEPALM.id = "FACEPALM"
FACEPALM.fn = function(act)
act.target.components.talker:Say("*le sigh*")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end

AddAction(FACEPALM)

Taa-daa you now know how to add an unlimited amount of keyhandler actions, amazing isn't it :)?

Now as thanks like all my help I gave you or I'll cri so hard everythyme R9mG9xk.gif R9mG9xk.gif R9mG9xk.gif . . .

Of course you don't have to but I would cry tears of joy everythyme I see those likes on my profile R9mG9xk.gif R9mG9xk.gif R9mG9xk.gif . . .

Wow, lots of info, thanks!

 

I added in the delay, it seems to only work in the special form, and no delay in the other one,.

I'll probably try abilities later tomorrow, it's way too late and I'm already going to end up waking up way past noon lol.

Link to comment
Share on other sites

local TRANSFORM = GLOBAL.Action()
TRANSFORM.str = "Transform"
TRANSFORM.id = "TRANSFORM"
TRANSFORM.fn = function(act)
if act.target.normal_mode == true and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = nil
act.target.transform_cooldown = true
act.target.AnimState:SetBuild("gaster_void")
act.target.components.talker:Say("I'm transforming into something special!")
act.target:DoTaskInTime(60, function() act.target.transform_cooldown = nil end) -- Cooldown = 1 minute.
elseif act.target.normal_mode == nil and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = true
act.target.AnimState:SetBuild("gaster")
act.target.transform_cooldown_void = true
act.target:DoTaskInTime(60, function() act.target.transform_cooldown_void = nil end) -- Cooldown = 1 minute.
act.target.components.talker:Say("I'm reverting back to normal!")
elseif act.target.transform_cooldown == true or act.target.transform_cooldown_void == true then
act.target.components.talker:Say("That's impossible...")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end
end

AddAction(TRANSFORM)

This should put 1 minute cooldown for both replace the old 1 i gave u

Edited by SuperDavid
Link to comment
Share on other sites

13 minutes ago, SuperDavid said:

local TRANSFORM = GLOBAL.Action()
TRANSFORM.str = "Transform"
TRANSFORM.id = "TRANSFORM"
TRANSFORM.fn = function(act)
if act.target.normal_mode == true and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = nil
act.target.transform_cooldown = true
act.target.AnimState:SetBuild("gaster_void")
act.target.components.talker:Say("I'm transforming into something special!")
act.target:DoTaskInTime(60, function() act.target.transform_cooldown = nil end) -- Cooldown = 1 minute.
elseif act.target.normal_mode == nil and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = true
act.target.AnimState:SetBuild("gaster")
act.target.transform_cooldown_void = true
act.target:DoTaskInTime(60, function() act.target.transform_cooldown_void = nil end) -- Cooldown = 1 minute.
act.target.components.talker:Say("I'm reverting back to normal!")
elseif act.target.transform_cooldown == true or act.target.transform_cooldown_void == true then
act.target.components.talker:Say("That's impossible...")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end
end

AddAction(TRANSFORM)

This should put 1 minute cooldown for both replace the old 1 i gave u

Ummm.

I think I just deleted something by accident and I'm not sure what...

local TRANSFORM = GLOBAL.Action()
TRANSFORM.str = "Transform"
TRANSFORM.id = "TRANSFORM"
TRANSFORM.fn = function(act)
if act.target.normal_mode == true and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = nil
act.target.transform_cooldown = true
act.target.AnimState:SetBuild("gaster_void")
act.target.components.talker:Say("Dark Darker Yet Darker...")
act.target:DoTaskInTime(10, function() act.target.transform_cooldown = nil end) -- Cooldown = 1 minute.
elseif act.target.normal_mode == nil and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = true
act.target.AnimState:SetBuild("gaster")
act.target.transform_cooldown_void = true
act.target:DoTaskInTime(10, function() act.target.transform_cooldown_void = nil end) -- Cooldown = 1 minute.
act.target.components.talker:Say("Time to return into existance...")
elseif act.target.transform_cooldown == true or act.target.transform_cooldown_void == true then
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
act.target.components.talker:Say("That's impossible...")
end
end

AddAction(TRANSFORM)


-- The character select screen lines
STRINGS.CHARACTER_TITLES.gaster = "The Royal Scientist"
STRINGS.CHARACTER_NAMES.gaster = "W.D Gaster"
STRINGS.CHARACTER_DESCRIPTIONS.gaster = "*Dark\n*Darker\n*Yet Darker"
STRINGS.CHARACTER_QUOTES.gaster = "\"It's Rude to Talk About Someone When They Are Listening...\""

probably between AddAction and Strings, log gives this:

 

[00:00:56]: [string "../mods/WDGaster/modmain.lua"]:72: attempt to index global 'STRINGS' (a nil value)
LUA ERROR stack traceback:
        ../mods/WDGaster/modmain.lua(72,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(609,1) in function 'RunInEnvironment'
        scripts/mods.lua(470,1) in function 'InitializeModMain'
        scripts/mods.lua(444,1) in function 'LoadMods'
        scripts/main.lua(251,1) in function 'ModSafeStartup'
        scripts/main.lua(306,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(22,1) in function 'SavePersistentString'
        scripts/modindex.lua(76,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(63,1) in function 'BeginStartupSequence'
        scripts/main.lua(305,1) in function 'callback'
        scripts/modindex.lua(516,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(490,1) in function 'Load'
        scripts/main.lua(304,1) in main chunk
[00:00:56]: [string "scripts/mainfunctions.lua"]:972: variable 'global_error_widget' is not declared
LUA ERROR stack traceback:
        =[C] in function 'error'
        scripts/strict.lua(23,1)
        scripts/mainfunctions.lua(972,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(22,1) in function 'SavePersistentString'
        scripts/modindex.lua(76,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(63,1) in function 'BeginStartupSequence'
        scripts/main.lua(305,1) in function 'callback'
        scripts/modindex.lua(516,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(490,1) in function 'Load'
        scripts/main.lua(304,1) in main chunk
[00:00:56]: DoLuaFile Error: (null)
[00:00:56]: LuaError but no error string
[00:00:56]: Error loading main.lua
[00:00:56]: Failed mSimulation->Reset()
[00:00:56]: Error during game restart!
[00:00:58]: SteamWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:58]: Collecting garbage...
[00:00:58]: lua_gc took 0.02 seconds
[00:00:58]: ~ShardLuaProxy()
[00:00:58]: ~ItemServerLuaProxy()
[00:00:58]: ~InventoryLuaProxy()
[00:00:58]: ~NetworkLuaProxy()
[00:00:58]: ~SimLuaProxy()
[00:00:58]: SteamWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:58]: lua_close took 0.01 seconds
[00:00:58]: SteamWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:58]: [Steam] Auth ticket cancelled
[00:00:58]:  Manager - ORPHANED UNKNOWN RESOURCES:
[00:00:58]: shaders/ui_yuv.ksh - 1
[00:00:58]: CurlRequestManager::ClientThread::Main() complete
[00:00:58]: HttpClient2 discarded 0 callbacks.
[00:00:58]: Shutting down

Oops....

Link to comment
Share on other sites

I don't think it was any of your code, I think there was something between that and the STRINGS, because as the log says:

attempt to index global 'STRINGS' (a nil value)

Maybe I didn't delete something? Idk, seems like I might have, but I may have not, overall, the game is crashing lol.

Link to comment
Share on other sites

Uhh, do you have a backup of your mod? I'm not really good at fixing crashes :(... Or do you remember what you did before it started giving this crash? Maybe try putting the the code I gave you under the 

-- The character select screen lines
STRINGS.CHARACTER_TITLES.gaster = "The Royal Scientist" STRINGS.CHARACTER_NAMES.gaster = "W.D Gaster"
STRINGS.CHARACTER_DESCRIPTIONS.gaster = "*Dark\n*Darker\n*Yet Darker"
STRINGS.CHARACTER_QUOTES.gaster = "\"It's Rude to Talk About Someone When They Are Listening...\""

Thank god it worked for you, I was gonna start crying everythyme

Edited by SuperDavid
Link to comment
Share on other sites

8 minutes ago, SuperDavid said:

Uhh, do you have a backup of your mod? I'm not really good at fixing crashes :(... Or do you remember what you did before it started giving this crash?

Found it, accidentally deleted this:

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS

Transformation is perfect now, and game runs fine.

 

I'm gonna head off now, I'll be back to this tomorrow and probably post here if something goes horribly wrong with abilities (hopefully not)

 

Thank you so much, take all my likes!

Link to comment
Share on other sites

21 hours ago, SuperDavid said:

Uhh, do you have a backup of your mod? I'm not really good at fixing crashes :(... Or do you remember what you did before it started giving this crash? Maybe try putting the the code I gave you under the 


-- The character select screen lines
STRINGS.CHARACTER_TITLES.gaster = "The Royal Scientist" STRINGS.CHARACTER_NAMES.gaster = "W.D Gaster"
STRINGS.CHARACTER_DESCRIPTIONS.gaster = "*Dark\n*Darker\n*Yet Darker"
STRINGS.CHARACTER_QUOTES.gaster = "\"It's Rude to Talk About Someone When They Are Listening...\""

Thank god it worked for you, I was gonna start crying everythyme

Alright, back at this again.

So I went to look at the abilities code, and I realized, that the abilities was something completely different from what i imagined, gave me great ideas.

 

What I was talking about before was say in his special form, he gets more movement speed, more health, but less health regeneration. How would I do that?

 

And as for abilities, Maybe one that makes him be invincible until toggled off, but he cannot attack, and it drains his sanity, also increasing movement speed?

(Like if you know Overwatch, sorta like Reapers ult I guess)

Edited by TheBigDeal
Link to comment
Share on other sites

15 hours ago, TheBigDeal said:

What I was talking about before was say in his special form, he gets more movement speed, more health

local TRANSFORM = GLOBAL.Action()
TRANSFORM.str = "Transform"
TRANSFORM.id = "TRANSFORM"
TRANSFORM.fn = function(act)
if act.target.normal_mode == true and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = nil
act.target.transform_cooldown = true
act.target.AnimState:SetBuild("gaster_void")
act.target.components.health:SetMaxHealth(200) -- Let's say his normal hp = 100.
act.target.components.locomotor.runspeed = 100 * TUNING.WILSON_RUN_SPEED -- Put the speed bonus yourself.
act.target.components.talker:Say("I'm transforming into something special!")
act.target:DoTaskInTime(60, function() act.target.transform_cooldown = nil end) -- Cooldown = 1 minute.
elseif act.target.normal_mode == nil and act.target.transform_cooldown == nil and act.target.transform_cooldown_void == nil then
act.target.normal_mode = true
act.target.AnimState:SetBuild("gaster")
act.target.transform_cooldown_void = true
act.target.components.health:SetMaxHealth(100) -- Revert hp back to normal.
act.target.components.locomotor.runspeed = 1 * TUNING.WILSON_RUN_SPEED -- Put the speed bonus yourself.
act.target:DoTaskInTime(60, function() act.target.transform_cooldown_void = nil end) -- Cooldown = 1 minute.
act.target.components.talker:Say("I'm reverting back to normal!")
elseif act.target.transform_cooldown == true or act.target.transform_cooldown_void == true then
act.target.components.talker:Say("That's impossible...")
act.target:PushEvent("emote", { anim = "emoteXL_facepalm", mounted = true })
end
end

AddAction(TRANSFORM)

 

Edited by SuperDavid
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
 Share

×
  • Create New...