Okay, What I'm trying to do is create a run button. The run button would be good for characters like mario or Sonic Lost World Sonic... And the thin is, I can BARELY lua but I do have a code I just made up... I don't think it works but i'm trying to find out what needs to be done.
Code:
addHook("ThinkFrame" do
for player in player.iterate
if player.mo and player.mo.skin = "mario"
if (player.cmd.buttons & BT_CUSTOM1)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
if (player.pflags & PF_RUNNING)
addHook("ThinkFrame" do
for player in player.iterate
if player.mo and player.mo.skin = "mario"
if (player.cmd.buttons & BT_CUSTOM1)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
if (player.pflags & PA_WALK)
and if not (player.cmd.buttons & BT_CUSTOM1)
//this should tell us if the player is walking and is not pressing the run button
if button is pressed (BT_CUSTOM3)
player.defaultspeed = FRACUNIT
player.increasespeed = FRACUNIT/2
//I believe what is supposed to happen here is that the player increases their speed past their running speed
end
end
end
end)
Why on earth are you even trying to use pflags to check for an animation? PA_WALK is not a flag, it's an animation, and must be checked using player.panim instead of player.pflags.
Ok, that's fixed, but I'm having trouble moving on past the action i'm trying to do...
Code:
addHook("ThinkFrame" do
for player in player.iterate
if player.mo and player.mo.skin = "mario"
if (player.cmd.buttons & BT_CUSTOM1)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
if (player.panim & PA_WALK)
and if not (player.cmd.buttons & BT_CUSTOM1)
(action == null?)
//this should tell us if the player is walking and is not pressing the run button
if button is pressed (BT_CUSTOM1)
player.defaultspeed = FRACUNIT
player.increasespeed = FRACUNIT/2
(player.panim & PA_RUN) = True
//I believe what is supposed to happen here is that the player increases their speed past their running speed
end
end
end
end)
I haven't executed this yet, but I still want to know what I did wrong:
Code:
addHook("ThinkFrame" do
for player in player.iterate
if player.mo and player.mo.skin = "mario"
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
if (player.panim & PA_WALK)
and if not (player.cmd.buttons & BT_CUSTOM1)
(player.panim & PA_RUN) == nil
//this should tell us if the player is walking and is not pressing the run button
if button is pressed (BT_CUSTOM1)
player.normalspeed = FRACUNIT
player.normalspeed = FRACUNIT*2
//I believe what is supposed to happen here is that the player increases their speed past their running speed
end
end
end
end)
I haven't executed this yet, but I still want to know what I did wrong:
Code:
if button is pressed (BT_CUSTOM1)
player.normalspeed = FRACUNIT
player.normalspeed = FRACUNIT*2
//I believe what is supposed to happen here is that the player increases their speed past their running speed
end
end
end
end)
player.normalspeed does not need fracunits, just use numbers. Even then, all that will do is increase the player's maximum speed, it will not put them in their running animations, and neither will it put them in motion.
player.normalspeed does not need fracunits, just use numbers. Even then, all that will do is increase the player's maximum speed, it will not put them in their running animations, and neither will it put them in motion.
The running speed of the character is only 5 units from the normal speed, so even by getting speed shoes the character will go in the running animations. And thanks, for the advice.
Fix-up (I guess)
Code:
addHook("ThinkFrame" do
for player in player.iterate
if player.mo and player.mo.skin = "mario"
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
if (player.panim & PA_WALK)
and if not (player.cmd.buttons & BT_CUSTOM1)
(player.panim & PA_RUN) == nil
//this should tell us if the player is walking and is not pressing the run button
if player.cmd.button is pressed (BT_CUSTOM1) is pressed
player.normalspeed = 15
//I believe what is supposed to happen here is that the player increases their speed past their running speed
if (player.cmd.button & BT_CUSTOM1) is not pressed
player.noramlspeed = 10
//I believe what is supposed to happen here is that if the button is not pressed while the running action is going on, it will revert back to the normal speed it has
end
end
end
end)
The running speed of the character is only 5 units from the normal speed, so even by getting speed shoes the character will go in the running animations. And thanks, for the advice.
Fix-up (I guess)
Code:
addHook("ThinkFrame" do
for player in player.iterate
if player.mo and player.mo.skin = "mario"
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
if (player.panim & PA_WALK)
and if not (player.cmd.buttons & BT_CUSTOM1)
(player.panim & PA_RUN) == nil
//this should tell us if the player is walking and is not pressing the run button
if player.cmd.button is pressed (BT_CUSTOM1) is pressed
player.normalspeed = 15
//I believe what is supposed to happen here is that the player increases their speed past their running speed
if (player.cmd.button & BT_CUSTOM1) is not pressed
player.noramlspeed = 10
//I believe what is supposed to happen here is that if the button is not pressed while the running action is going on, it will revert back to the normal speed it has
end
end
end
end)
Sorry, I had a brain fart, you were actually correct, the speed DOES need fracunit. However, the rest of your code is still wrong, in fact, your entire code is wrong, the best "fix" would be to start over, I'll point out some mistakes that I saw.
Code:
for player in player.iterate
if player.mo and player.mo.skin = "mario"
It's playerS.iterate, the skin check needs to be in parentheses, also when checking for things, you use "==" not "="
Code:
(player.panim & PA_RUN) == nil
I can only assume that you were trying to "cancel" running animations with this, however, I doubt that would work, even if it did, you're supposed to use "=" when changing things, not "==" (unless you MEANT to use "==", in which case, I have no idea what you were trying to achieve).
Code:
if player.cmd.button is pressed (BT_CUSTOM1) is pressed
Code:
if (player.cmd.button & BT_CUSTOM1) is not pressed
"Is pressed" and "Is not pressed" doesn't do anything, they aren't a thing, (player.cmd.button & BT_CUSTOM1) checks if you are pressing the button, if you want to execute an action when the button is NOT pressed, all you have to do is make the action that happens when it IS pressed, and then use "else" to say what happens when it is not.
Here's a new and working code. The only problem with it is that it slows down the other characters as well, since I didn't tell it what to do if the character is not Sonic.
Code:
addHook("ThinkFrame", do
for player in players.iterate
if (player.mo and player.mo.skin == "sonic")
and (player.panim & PA_WALK)
and (player.cmd.buttons & BT_CUSTOM1)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 36*FRACUNIT
else
player.normalspeed = 20*FRACUNIT
end
end
end)
addHook("ThinkFrame", do
for player in players.iterate
if (player.mo and player.mo.skin == "mario")
and (player.panim & PA_WALK)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 30*FRACUNIT
else
player.normalspeed = 15*FRACUNIT
end
elseif not (player.mo.skin == "mario")
player.normalspeed = FRACUNIT
end
end
end
end)
Might not be the best solution... but hey, i tried... that character ability tutorial on the wiki wasn't much help...
Well it looks like it works... but an error keeps coming up everytime i fix it...
Code:
addHook("ThinkFrame", do
for player in players.iterate
if (player.mo and player.mo.skin == "mario")
and (player.panim & PA_WALK)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 36*FRACUNIT
else
player.normalspeed = 15*FRACUNIT
end
end
end)
else
return
end
end
end
end
Loading Lua script from mario.wad|LUA_MARI
Pardon me while I initialize the Lua scripting interface...
WARNING: mario.wad|LUA_MARI:99: '<eof>' expected near 'else'
Well it looks like it works... but an error keeps coming up everytime i fix it...
Code:
addHook("ThinkFrame", do
for player in players.iterate
if (player.mo and player.mo.skin == "mario")
and (player.panim & PA_WALK)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 36*FRACUNIT
else
player.normalspeed = 15*FRACUNIT
end
end
end)
else
return
end
end
end
end
I don't know, then. This script looks OK... Maybe you need to move that else up before the ends and move that last bit that comes before the first end to the right a slight bit, then move all the other stuff below it to the right a slight bit and add a new end for them...? I really don't know...
I don't think my script likes the word "else" by itself...
Code:
addHook("ThinkFrame", do
for player in players.iterate
if (player.mo and player.mo.skin == "mario")
and (player.panim & PA_WALK)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 30*FRACUNIT
else
player.normalspeed = 15*FRACUNIT
else
return
end
end
end
end
end
end
end)
WARNING: mario.wad|LUA_MARI:96: 'end' expected (to close 'if' at line 84) near 'else'
---------- Post added at 11:12 PM ---------- Previous post was at 10:31 PM ----------
New fix, similar issue...
Code:
addHook("ThinkFrame", do
for player in players.iterate
if not (player.mo and player.mo.skin == "mario")
continue
end
if (player.panim & PA_WALK)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 30*FRACUNIT
else
player.normalspeed = 15*FRACUNIT
end
end
end
end)
WARNING: mario.wad|LUA_MARI:101: ')' expected (to close '(' at line 82) near 'end'
EDIT: The code is kinda the same... but still the same error...
Code:
addHook("ThinkFrame", do
for player in players.iterate
if not (player.mo and player.mo.skin == "mario")
continue
end
if (player.panim & PA_WALK)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & PF_ROPEHANG)
and not (player.pflags & PF_MACESPIN)
and not (player.pflags & PF_TAGGED)
and not (player.pflags & PF_STASIS)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
player.normalspeed = 30*FRACUNIT
else
player.normalspeed = 15*FRACUNIT
end
end
end
end
end
end)
WARNING: mario.wad|LUA_MARI:101: ')' expected (to close '(' at line 82) near 'end'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.