Dimpsuu
Dimpsy
So ya know the Growing Monitor from Knuckles Chaotix which increases one's height for a short period of time? Yea I was trying to make that in SRB2 and I'm having a bit of a problem here trying to make the lua script itself work as it should.
Am I doing something wrong?
function A_KCGrow(actor, var1, var2)
local receiver = actor.target
if not receiver.player.kcgrow_power then
receiver.player.powers[pw_speedshoes] = 0
end
S_StartSound(receiver, actor.info.seesound)
end
addHook("ThinkFrame", do
for player in players.iterate
and (kcgrow_power == 1)
and not player.kcgrow_used
if player.mo.flags2 & MF2_OBJECTFLIP
player.mo.flags2 = $1 & ~MF2_OBJECTFLIP
S_StartSound(player.mo, sfx_shield)
else
player.mo.flags2 = $1 | MF2_OBJECTFLIP
S_StartSound(player.mo, sfx_shield)
end
player.kcgrow_used = true
end
if P_IsObjectOnGround(player.mo) then
player.kcgrow_used = false
end
end)
addHook("MobjSpawn", function(mo)
mo.scaleinit = 1
mo.normscale = mo.scale
mo.growscale = mo.scale*2
mo.banim = 0
mo.oldbuttons = 0 // stores what buttons were pressed last tic
end, MT_PLAYER)
// Function for MobjThinker hook to use, required to be in function(mobj) format
// "return false" or "return" on its own allows the normal behaviour to carry on as normal after this
// "return true" would make this stop the normal behaviour from running after this
// in this case at least we don't need to (or want to) overwrite normal player behavior, that would cause some problems!
local function HandleBrakScale(grow)
if player.kcgrow_power then
mo.player.kcgrow_power = false
return
end
if grow.normscale == nil or grow.growscale == nil
grow.normscale = grow.scale
grow.growscale = grow.scale*2
end
if (player.kcgrow_power == 1)
if grow.scaleinit
grow.scale = grow.growscale // set to cbfs scale
grow.scaleinit = 0
end
else //normal skins - switching skins is properly supported now!
if grow.scale == grow.growscale
grow.scale = grow.normscale
end
grow.scaleinit = 1
end
end
addHook("MobjThinker", HandleBrakScale, MT_PLAYER)
Am I doing something wrong?