My first attempt at Lua

Status
Not open for further replies.
So my run script is completed and fixed up (Thanks to SpeedWagon)
But now I have a new goal, Mario has a hard time getting under things, and can't even complete MKB2, so I decided to make a shrinking script for mario.
Code:
addHook("ThinkFrame",do
    for player in players.iterate
        if player.mo and player.mo.skin == "mario" then
            if player.health < 10
            and player.mo.health < 10
                player.mo.destscale = FRACUNIT/2
                else
                    player.mo.destscale = FRACUNIT
                end
            end
        end
    end)
The only problem is that it affects other players and reverts back after 9 rings instead of 10...

A feature i'm planning to add is giving mario the same jumpfactor as his normal height, so platforming won't be a slow and impossible pain...
 
The ring error is due to health counting zero rings as well. So, if you want something to happen at ten rings, you'd put player.health < 11, not player.health < 10.
 
WARNING: mario.wad|LUA_MARI:142: unexpected symbol near 'and'
Loading main config from mario.wad
Maybe not... damn pastebin...

EDIT: fixed, you forgot to get rid of "then"

EDIT2: Code Extension to make jump factor related to original height

Code:
addHook("ThinkFrame",do
        for player in players.iterate
                if player.mo and player.mo.skin == "mario"
                and player.health < 11
                and player.mo.health < 11
                    player.mo.destscale = FRACUNIT/2
                else
                    player.mo.destscale = FRACUNIT
                end
            
            if player.mo.destscale = FRACUNIT/2 then
             player.defaultfactor = FRACUNIT*2
         else
             player.defaultfactor = FRACUNIT
        end
    end
end)
EDIT: Turns out the "defaultfactor" didn't count as a thing, so instead i replaced it with jumpfactor... however it broke the multijump script (I guess we ALWAYS can't have nice things *sighs*)


Now that that project is done since someone else is working on something better than what I have >_>
I'm instead working on something I've been longing for, a 4-point health bar! I first want to draw the actual sprites on the hud... and I'm pretty much new to hud drawing... so here's my start...
Code:
local function hud_draw(v, stplyr)

    local p_life1    = v.cachePatch("LIFE1")
        for player in players.iterate
        if player.mo and player.mo.skin == "duon"
        v.draw(64, 70, p_life1, V_SNAPTORIGHT);
...yeah, I had to borrow the lua from Sonic-RPG... since i don't understand how to draw huds in the first place...
 
Last edited:
Status
Not open for further replies.

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

Back
Top