hey, I'm trying to make a lua character because my incredibly lazy "mossysauce" beta character got rejected (deservedly so.) my script ain't working!

kittkat

kittkat
my script here isn't working. the idea is that when you press "spin" then the character's sprite shrinks vertically and vertically only. I'm still learning lua, but why ain't this working?
squash:
if input.gameControlDown GC_SPIN then
p.mo.spriteyscale = FRACUNIT/2 until
not input.gameControlDown GC_SPIN
end
 
my script here isn't working. the idea is that when you press "spin" then the character's sprite shrinks vertically and vertically only. I'm still learning lua, but why ain't this working?
squash:
if input.gameControlDown GC_SPIN then
p.mo.spriteyscale = FRACUNIT/2 until
not input.gameControlDown GC_SPIN
end
Is this all the code? If that's the case, you need a hook to properly execute it.
 
Is this all the code? If that's the case, you need a hook to properly execute it.
yes, this is all the code. I'm looking up what a hook is right now to try to implement it! thanks for the help/
Post automatically merged:

yes, this is all the code. I'm looking up what a hook is right now to try to implement it! thanks for the help/
nevermind, I have absolutely zero idea what hook to use.
 
shrink:
local function ShrinkLogic(p)
    if (p.mo.skin ~= "sonic") then return end --replace with your skin of choice
    if (p.cmd.buttons & BT_SPIN) then
        p.shrinkheld = true
        p.mo.spriteyscale = FRACUNIT/2
    else
        if (p.shrinkheld) then
            p.shrinkheld = false
            p.mo.spriteyscale = FRACUNIT
        end
    end
end

addHook("PlayerThink", ShrinkLogic)

Try this. If you want a player to do something every frame, you want the PlayerThink hook. Usually the hooks are pretty self explanatory on where they are used, but I can understand the confusion for a beginner.

As for the code, I replaced the input with a cmd button check. The input library is (presumably) more useful for scenarios where there are no players, like the menu. You can check for an existing player's button inputs with p.cmd.

I also added a "shrinkheld" variable. This is mainly so that if *something else* shrinks your y scale, the code doesn't automatically interrupt it unless you press Spin yourself.
 
shrink:
local function ShrinkLogic(p)
    if (p.mo.skin ~= "sonic") then return end --replace with your skin of choice
    if (p.cmd.buttons & BT_SPIN) then
        p.shrinkheld = true
        p.mo.spriteyscale = FRACUNIT/2
    else
        if (p.shrinkheld) then
            p.shrinkheld = false
            p.mo.spriteyscale = FRACUNIT
        end
    end
end

addHook("PlayerThink", ShrinkLogic)

Try this. If you want a player to do something every frame, you want the PlayerThink hook. Usually the hooks are pretty self explanatory on where they are used, but I can understand the confusion for a beginner.

As for the code, I replaced the input with a cmd button check. The input library is (presumably) more useful for scenarios where there are no players, like the menu. You can check for an existing player's button inputs with p.cmd.

I also added a "shrinkheld" variable. This is mainly so that if *something else* shrinks your y scale, the code doesn't automatically interrupt it unless you press Spin yourself.
thanks! this really helps.
Post automatically merged:

thanks! this really helps.
nevermind, this doesn't work. i changed the name "sonic" to the skin name of my character, (luachar) and it still doesn't. what's the problem?
srb20015.gif
 
Last edited:
Did it work when the skin name was still Sonic? If it didn't:

-if you're using a PK3, make sure make a folder called Lua in the root of the PK3, then put the script inside that.
-If you're using a WAD, make sure the file is named LUA_XXXX where the X can be anything you want..

If it did work as Sonic, just uhh..... make sure your skin's name (the real name, not the one on the bottom left) matches?
 
Did it work when the skin name was still Sonic? If it didn't:

-if you're using a PK3, make sure make a folder called Lua in the root of the PK3, then put the script inside that.
-If you're using a WAD, make sure the file is named LUA_XXXX where the X can be anything you want..

If it did work as Sonic, just uhh..... make sure your skin's name (the real name, not the one on the bottom left) matches?
here's what it looks like. my skin name and realname are both luachar, so i just don't know what's happening.
1717371310904.png
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top