Jibble

Author Topic: Some things I've been doing in AGS made possible by the power of the mighty Lua.  (Read 5906 times)

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with scripting
    • Scavenger worked on one or more games that won an AGS Award!
    •  
    • Scavenger worked on one or more games that was nominated for an AGS Award!
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

  • Cavefish
  • Mittens Knight
  • still mowing the lawn
    • abstauber worked on one or more games that won an AGS Award!
    •  
    • abstauber worked on one or more games that was nominated for an AGS Award!
yeah you're right, I've corrected my post.
I'd still love to achive this in 32bit.

Calin Leafshade

  • Long live King Cat!
    • I can help with making music
    • I can help with voice acting
    • Calin Leafshade worked on one or more games that won an AGS Award!
    •  
    • Calin Leafshade worked on one or more games that was nominated for an AGS Award!
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

  • Cavefish
  • Mittens Knight
  • still mowing the lawn
    • abstauber worked on one or more games that won an AGS Award!
    •  
    • abstauber worked on one or more games that was nominated for an AGS Award!
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

  • Long live King Cat!
    • I can help with making music
    • I can help with voice acting
    • Calin Leafshade worked on one or more games that won an AGS Award!
    •  
    • Calin Leafshade worked on one or more games that was nominated for an AGS Award!
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
  1.  
  2. function skipPal(numberOfSlotsToSkip, spriteNum)
  3.  
  4.     local sprite = ags.DynamicSprite.CreateFromExistingSprite(spriteNum)
  5.     local ds = sprite:GetDrawingSurface()
  6.  
  7.     for x=0, sprite.Width - 1 do
  8.         for y=0, sprite.Height - 1 do
  9.             local color = ds:GetPixel(x,y)
  10.             -- lookup the color from our palette using a lookup table
  11.             local palIndex = pal.lookup[color]
  12.             -- set the drawing color to the palette number plus the slots to skip
  13.             ds.DrawingColor = pal[palIndex + numberOfSlotsToSkip]
  14.             ds:DrawPixel(x,y)
  15.         end
  16.     end
  17.  
  18.     ds:Release()
  19.  
  20.     return sprite
  21. end
  22.  
  23.  

abstauber

  • Cavefish
  • Mittens Knight
  • still mowing the lawn
    • abstauber worked on one or more games that won an AGS Award!
    •  
    • abstauber worked on one or more games that was nominated for an AGS Award!
Hey, thanks for the snippet. It really doesn't look all that hard.

Have you managed to compile it for Linux yet?

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
« Last Edit: 19 Sep 2014, 13:35 by Crimson Wizard »

abstauber

  • Cavefish
  • Mittens Knight
  • still mowing the lawn
    • abstauber worked on one or more games that won an AGS Award!
    •  
    • abstauber worked on one or more games that was nominated for an AGS Award!
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 )