Some things I've been doing in AGS made possible by the power of the mighty Lua.

Started by Calin Leafshade, Thu 01/05/2014 16:40:38

Previous topic - Next topic

Scavenger

Quote from: abstauber on Thu 18/09/2014 20:43:07
Sorry to bump this...
Calin, is it possible to have 8-bit palette rotation done by the mighty powers of lua? That's really a thing I've been missing for ages. In 8-bit it's half broken (as you can't control the speed) and in 16,32 bit it not possible at all.

I'm not sure what you mean - CyclePalette just rotates the palette around one slot, if you make your own timer you can slow it down or speed it up. It doesn't have to be called every loop, just call it every X loops, where X is how slow you want it.

abstauber

yeah you're right, I've corrected my post.
I'd still love to achive this in 32bit.

Calin Leafshade

If you want to do that then its perfectly possible but you'd need to do some processing and stuff.

You'd have to store your own palette or build one from a sample image and then step through every time you wanted to step it. I reckon that would be easily fast enough in lua.

abstauber

Sorry for being such a noob:
I suppose in addition to the lua plugin and lua itself, I need some sort of graphics lib like 'CD'? And would the game still be portable afterwards?

Calin Leafshade

Nope, no graphics lib required and lua is included with the lua plugin.

The API is basically the same as ags script.

It would look something like this:

Code: lua


function skipPal(numberOfSlotsToSkip, spriteNum)

    local sprite = ags.DynamicSprite.CreateFromExistingSprite(spriteNum)
    local ds = sprite:GetDrawingSurface()

    for x=0, sprite.Width - 1 do
        for y=0, sprite.Height - 1 do
            local color = ds:GetPixel(x,y)
            -- lookup the color from our palette using a lookup table
            local palIndex = pal.lookup[color]
            -- set the drawing color to the palette number plus the slots to skip
            ds.DrawingColor = pal[palIndex + numberOfSlotsToSkip]
            ds:DrawPixel(x,y)
        end
    end

    ds:Release()

    return sprite
end


abstauber

Hey, thanks for the snippet. It really doesn't look all that hard.

Have you managed to compile it for Linux yet?

Crimson Wizard

Quote from: abstauber on Fri 19/09/2014 13:12:02
Have you managed to compile it for Linux yet?
Lua plugin won't be fully compatible with 64-bit Linux until we completely rewrite AGS plugin API.

By "fully compatible" I mean that it may work, but some things may not.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=45810.msg636451744#msg636451744

abstauber

Fair enough :)
I think I will try to get something done in Lua first. Once I make enough progress with my project, I'll decide whether to pre-render the effects or to use this lua magic (which I hope to get done until then )

SMF spam blocked by CleanTalk