Resource icon

[Open Assets] WheelieMod v1.02

This content may be freely modified and/or maintained by anyone.

Maril

Fluffy Kitsune Connoisseur
Speccy submitted a new resource:

WheelieMod - Think of wheeling... but it makes you go fast.

Think of wheeling... but it makes you go fast.

WheelieMod is a small script that adds "wheeling" to the game.

You press Custom 1, and you start a wheelie, making you gain speed over time.
It doesn't last long though!.
(GIF reused from Speccy)

kart0002.gif



You can see an example on how to add support to a skin in the PK3!
Everything is reusable!

Read more about this resource...
 
Welcome to releases!
Now that we're here, I'm going to reiterate on my suggestion pre-release so you don't lose it.
Technically the mod works, but the way you have it currently set up is very much prone to cause issues if used by multiple mods. Not really a good thing when this is supposed to be a resource usable by multiple different mods at once.

Now how would you fix this? Well here's my suggestion.

Change this block of code...
Lua:
freeslot("S_WHEELIE", "sfx_wille") -- wille funny

states[S_WHEELIE] = {
    sprite = SPR_PLAY,
    frame = W,
    tics = -1,
    nextstate = mobjinfo[MT_PLAYER].spawnstate
}

rawset(_G, "wheelieMod", {
    skins = {
        ["speccy"] = {
            hasSprite = true, -- Have wheelie sprites? Sure, you can use them!
            wheelieFrame = T, -- What frame do you have them on? We'll use that.
            hasDust = true, -- Should dust display?
            dustRadius = mobjinfo[MT_PLAYER].radius/3, -- If so, what's the radius around the player?
            wheelieSound = true
        }/*,
        ["sonic"] = {
            hasSprite = false, -- Have wheelie sprites? Sure, you can use them!
            wheelieFrame = T, -- What frame do you have them on? We'll use that.
            hasDust = true, -- Should dust display?
            dustRadius = mobjinfo[MT_PLAYER].radius/3, -- If so, what's the radius around the player?
            wheelieSound = true
        }*/
    }
})

local wM = wheelieMod

...into this.
Lua:
--Modify this code here to give your character Wheelie support!
local SKIN = "speccy" -- The skin name of your character.
local SKIN_STATS = {
    hasSprite = true, -- Have wheelie sprites? Sure, you can use them!
    wheelieFrame = T, -- What frame do you have them on? We'll use that.
    hasDust = true, -- Should dust display?
    dustRadius = mobjinfo[MT_PLAYER].radius/3, -- If so, what's the radius around the player?
    wheelieSound = true
}

-- You can ignore the rest of this code if all you're doing is adding compatibility.

-- Add our skin to wheelieMod if the latter already exists.
if wheelieMod then
    wheelieMod.skins[SKIN] = SKIN_STATS
    return
end

-- Create a new wheelieMod!
rawset(_G, "wheelieMod", {
    skins = {
        [SKIN] = SKIN_STATS
    }
})
local wM = wheelieMod

freeslot("S_WHEELIE", "sfx_wille") -- wille funny

states[S_WHEELIE] = {
    sprite = SPR_PLAY,
    frame = W,
    tics = -1,
    nextstate = mobjinfo[MT_PLAYER].spawnstate
}

Basically, my code makes sure that code from other wheelie mods don't get overwritten when a new one is added. This is accomplished by first checking for if wheelieMod already exists. If it does, add the previously defined skin information and don't run the rest of the script by returning. Otherwise, create wheelieMod and add the skin information there, then go on to do the rest of the wheelie script.
 

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

Back
Top