From a8e54a038cf9576473cbe8b1f62f3012bd47a0c3 Mon Sep 17 00:00:00 2001 From: mjcox244 <66311016+mjcox244@users.noreply.github.com> Date: Sat, 19 Mar 2022 04:30:53 +0000 Subject: [PATCH] Add more Example Lua mods (#35) --- docs/lua/examples/Instant_Clip.lua | 12 ++++++++++++ docs/lua/examples/Moonjump.lua | 10 ++++++++++ docs/lua/lua.md | 3 +++ mods/Mario-Run.lua | 24 ++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 docs/lua/examples/Instant_Clip.lua create mode 100644 docs/lua/examples/Moonjump.lua create mode 100644 mods/Mario-Run.lua diff --git a/docs/lua/examples/Instant_Clip.lua b/docs/lua/examples/Instant_Clip.lua new file mode 100644 index 00000000..1a735362 --- /dev/null +++ b/docs/lua/examples/Instant_Clip.lua @@ -0,0 +1,12 @@ +-- name: Instant Clip +-- description: Press L trigger, profit! + +function mario_update(m) + if (m.controller.buttonDown & L_TRIG) ~= 0 then -- If L pressed + set_mario_action(m, ACT_WALKING, 0) --set mario to walking so his vel is used + m.forwardVel = 400 --set Velocity to clip speed + end +end + +-- hooks -- +hook_event(HOOK_MARIO_UPDATE, mario_update) \ No newline at end of file diff --git a/docs/lua/examples/Moonjump.lua b/docs/lua/examples/Moonjump.lua new file mode 100644 index 00000000..5927d7b1 --- /dev/null +++ b/docs/lua/examples/Moonjump.lua @@ -0,0 +1,10 @@ +-- name: MoonJump +-- description: Hold the A button to Moonjump +function mario_update(m) + if (m.controller.buttonDown & A_BUTTON) ~= 0 then --If the A button is pressed + m.vel.y = 25 --Set Y velocity to 25 + end +end + +-- hooks -- +hook_event(HOOK_MARIO_UPDATE, mario_update) \ No newline at end of file diff --git a/docs/lua/lua.md b/docs/lua/lua.md index de8b8bf7..fdb5e27e 100644 --- a/docs/lua/lua.md +++ b/docs/lua/lua.md @@ -48,6 +48,7 @@ All of this is a holdover from when there were only two players. It was a reason - [Faster Swimming](../../mods/faster-swimming.lua) - [Hide and Seek Gamemode](../../mods/hide-and-seek.lua) - [Football (soccer) Gamemode](../../mods/football.lua) +- [Mario Run](../../mods/Mario-Run.lua) - [HUD Rendering](examples/hud.lua) - [Object Spawning](examples/spawn-stuff.lua) - [Custom Ball Behavior](examples/behavior-ball.lua) @@ -55,3 +56,5 @@ All of this is a holdover from when there were only two players. It was a reason - [Add to Goomba Behavior](examples/behavior-add-to-goomba.lua) - [Behavior with Surface Collisions](examples/behavior-surface-collisions.lua) - [Custom Box Model](examples/custom-box-model) +- [Moonjump](examples/Moonjump.lua) +- [Instant Clip](examples/Instant_Clip.lua) diff --git a/mods/Mario-Run.lua b/mods/Mario-Run.lua new file mode 100644 index 00000000..b9ea3bbe --- /dev/null +++ b/mods/Mario-Run.lua @@ -0,0 +1,24 @@ +-- name: Mario RUN! +-- description: Mario Is contantly runing + +Threshold = 50 --set Threshold to 50 + +function mario_update(m) + --Prevent mario from ideling + if m.action == ACT_IDLE then --If idle + set_mario_action(m, ACT_WALKING, 0) --Make Mario walk + end + + --Crouching doesnt apply vel so prevent that + if m.action == ACT_CROUCHING then --If crouching + set_mario_action(m, ACT_WALKING, 0) --Make Mario walk + end + + --Speed floor + if (m.forwardVel > 0-Threshold) and (m.forwardVel < Threshold) then --If Mario isn't moveing fast enough + m.forwardVel = Threshold --set forwards velocity to whatevet the threashold is set to + end +end + +-- hooks -- +hook_event(HOOK_MARIO_UPDATE, mario_update)