Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Scavenger

#361
Working on DWEF again exclusively now! After learning how to speed up some of my graphics programming, the game should run even smoother with fancier effects. I should be able to release a working demo in a couple of months!

Have a screenshot of one of the cutscenes in the meantime, just to get some interest flowing:

I'd show more, but I wouldn't want to spoil anything!

And if you cannot wait for this game, please play it's gaiden game, Heatwave. I promise you: you will not be disappointed.
#362
Quote from: selmiak on Fri 06/12/2013 12:16:56
hmm, maybe AGS should then provide a 200%, 75%, 50%, 25% scaling view option for more control over enginenative scaling that might work different from what the autor/artist wants to happen.

Couldn't you script that really easily in AGS anyway? Set a few properties, and have in your rep_exec_always:

Code: AGS

function game_start ()
{
    player.ManualScaling = true;
}

function repeatedly_execute_always ()
{
    if (GetScalingAt (player.x,player.y) > 100) 
    {
        player.ChangeView (player.GetProperty ("BIG CHARACTER!!!"));
        player.SpeechView = player.GetProperty ("BIG CHARACTER TALKIN!!!");
        player.SetIdleView (player.GetProperty ("BIG CHARACTER IDLING!!!"),whatevervariableyousettheidletimerto);
        player.Scaling = GetScalingAt (player.x,player.y) / 2; 
    }
    else if (GetScalingAt (player.x,player.y) =< 50)
    {
        player.ChangeView (player.GetProperty ("tiny character"));
        player.SpeechView = player.GetProperty ("tiny character talkin");
        player.SetIdleView (player.GetProperty ("tiny character idlin"),whatevervariableyousettheidletimerto);
        player.Scaling = GetScalingAt (player.x,player.y) * 2; 
    }
else
{
        player.ChangeView (player.GetProperty ("Normal Character"));
        player.SpeechView = player.GetProperty ("Normal Character Talking");
        player.SetIdleView (player.GetProperty ("Normal Character Idling"),whatevervariableyousettheidletimerto);
        player.Scaling = GetScalingAt (player.x,player.y); 
}

}


And you could just use the Properties to set the initial values and just have an array you change at runtime, to have like, different outfits and junk. No need to implement it as an engine function.
#363
Yeah, that works! Weird that Lua is doing that with DrawingColor=0. I'm guessing it doesn't show up on the Translucency because Lua doesn't actually write pixels of the 0 colour.

This is a weird bug - does it do the same thing in 16 bit and 32bit with magic pink?
#364
Thanks for the feedback, everyone. I'm glad you all enjoyed it! There'll be plenty more cyberpunk adventure coming soon, with much better animations, and much more length and depth! I'd love to hear more people's thoughts on the game, too!

Also, Heatwave got it's first review today!

#365
Critics' Lounge / Re: Props, as in planes
Wed 04/12/2013 01:57:56
Quote from: jwalt on Wed 04/12/2013 01:17:43
Question the second: I've figured out how to get an image out of Gimp with an alpha channel (transpartent background), but generating the gif with an alpha channel is proving harder. The output I get looks like ghosting, and is sequentially displaying all the images without deleting them. I'd guess I'm missing something in the process. Suggestions?

GIF only supports 1-bit transparency, not full alpha transparency. You can make an animated PNG file, but I'm not sure how.

As for the bird, you may want to have a look at the line on the side of his beak, it looks like a rendering error - smooth that out before going too much further, or it'll look real ugly later on.

If I were doing it, I'd make a blendshape of what his mouth would look like fully open, then as you rotate the bone that opens his jaw, increase the influence of that blendshape. It'll help maintain the volume of the pouch he's got there and make it look a little more convincing.

Also, would you mind posting the low-poly wireframes, like before you subdivide, and the bones you're putting down? It might help us give you some tips on how to make more animatable models.
#366
Generally I like to see remakes of games that could have used better technology, and demakes of games that used too much technology and sucked because of it.

So, Simon the Sorcerer 3D? Is in dire need of a demake.

But don't remake just any old game. Remake the ones that have dated poorly, and need some tightening up. Demake the ones that dated poorly, and could have been done better with older tech (So any of the early 3D games that were made just because 3D was popular.)
#367
Alright! With Calin and Denzil's amendments to the code, it no longer crashes, and it shows the effect! I fixed the palette[palindex[ i ]].r bit and the colours got more accurate, but they still aren't correct compared to the AGSScript version.

Code: AGS
int paltemp [];
  paltemp = new int [palsiz];
  char i = 0;
  int i2 = 1;
  int upperboundary;
  while (i < palsiz)
  {
    paltemp [i] = (palette[palindex[i]].r +  // This algorithm produces an accurate, fast approximation of
                   palette[palindex[i]].r +  // The luminescence value of each of our palette slots.
                   palette[palindex[i]].r +  //
                   palette[palindex[i]].b +  // This ensures that when we colourise the final product, there 
                   palette[palindex[i]].g +  // will be little to no weird artifacts or lightness shifts.
                   palette[palindex[i]].g +  //
                   palette[palindex[i]].g +  // By using addition and bit shifts instead of multiplication, 
                   palette[palindex[i]].g    // the code will run a lot faster and more efficiently.
                   )>>3;
    i++;
  }
  i = 0;
  while (i < palsiz)
  {
      //Display ("%d , %d", i,  i+1);
      if (i > palsiz -2) upperboundary = 255;
      else upperboundary = (paltemp [i] + paltemp [i + 1])/2;
      //Display ("%d",upperboundary);

      while (i2 < upperboundary)
      {
        _C8palgorithm [i2] = palindex[i];
        i2++;
      }
    i++;
    }
    
    i= 0;
    paltemp = new int [256];
    while (i < 255)
      {
       paltemp [i] = (palette[i].r +  // This algorithm produces an accurate, fast approximation of
                      palette[i].r +  // The luminescence value of each of our palette slots.
                      palette[i].r +  //
                      palette[i].b +  // This ensures that when we colourise the final product, there 
                      palette[i].g +  // will be little to no weird artifacts or lightness shifts.
                      palette[i].g +  //
                      palette[i].g +  // By using addition and bit shifts instead of multiplication, 
                      palette[i].g    // the code will run a lot faster and more efficiently.
                      )>>3;
                      i++;
      }
    i = 0;
    while (i < 255)
      {
       _C8PaletteMap [i] = _C8palgorithm [paltemp[i]];
       i++;
      }


Code: Lua
function ProcessPalette (...)
  local palindex = {}
  local paltemp = {}
  local palsiz = select('#', ...) -- get number of arguments
  for n = 1, palsiz do
     palindex[n - 1] = select(n, ...) -- get nth argument
     paltemp[n - 1] = select(n, ...)
  end
  local i = 0
  local i2 = 1
  local upperboundary = 0
  C8palgorithm = {}
  C8PaletteMap = {}
  C8PaletteMap [0] = C8PaletteMap [0] or {}
  C8palgorithm [0] = C8palgorithm [0] or {}
  while (i < palsiz)
  do
    --paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
    paltemp [i] = palette_r [palindex[i]] + palette_r [palindex[i]] + palette_r [palindex[i]] + palette_b [palindex[i]] +  palette_g [palindex[i]] + palette_g [palindex[i]] + palette_g [palindex[i]] + palette_g [palindex[i]]
    paltemp [i] = bit.rshift(paltemp [i],3) 
    i = i + 1
  end
  i = 0
  C8palgorithm = {}
  while (i < palsiz)
  do
      if (i > palsiz - 2) then upperboundary = 255
      else 
        upperboundary = paltemp [i] + paltemp [i + 1]
        upperboundary = upperboundary /2
        end
      
      while (i2 < upperboundary)
      do
        C8palgorithm [i2] = palindex[i]
        i2 = i2 + 1
      end
    i = i + 1
  end
   i= 0
   paltemp = {}
   while (i < 255)
      do
       --paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
       paltemp [i] = palette_r [i] + palette_r [i] + palette_r [i] + palette_b [i] +  palette_g [i] + palette_g [i] + palette_g [i] + palette_g [i]
       paltemp [i] = bit.rshift(paltemp [i],3)
       i = i+ 1
      end
    i = 0
    while (i < 255)
      do
       C8PaletteMap [i] = C8palgorithm [paltemp[i]]
       i = i + 1
      end
  
end


Is the problem that Lua is counting from 1 again in the latter part of it?

The effect now looks like this:


The code looks identical, but the effect is very off. I'm not even sure how it's getting those non-blue colours.

ALSO, I'm trying to fix the translucency things, and I've noticed something very odd about the FakeScreen code I'm using:

Code: AGS
while ((i < Game.CharacterCount) || (i < Room.ObjectCount)) {
    if ((i < Game.CharacterCount) && (character[i].Room == player.Room)) surface.DrawCharacter(character[i]);
    if (i < Room.ObjectCount) {
      if (object[i].Visible) surface.DrawObject(object[i]);
      if (object[i].Graphic && object[i].Visible) {
        int scale = GetScalingAt(object[i].X, object[i].Y);
        int ow = (Game.SpriteWidth[object[i].Graphic] * scale) / 100;
        int oh = (Game.SpriteHeight[object[i].Graphic] * scale) / 100;
        if (object[i].IgnoreScaling) {
          ow = Game.SpriteWidth[object[i].Graphic];
          oh = Game.SpriteHeight[object[i].Graphic];
        }
        int ox1 = object[i].X;
        int ox2 = ox1 + ow;
        int j = 0;
        while (j < Game.CharacterCount) {
          if (character[j].Room == player.Room) {
            ViewFrame *frame = Game.GetViewFrame(character[j].View, character[j].Loop, character[j].Frame);
            int cw = (Game.SpriteWidth[frame.Graphic] * character[j].Scaling) / 100;
            int cx1 = character[j].x - (cw / 2);
            if ((((cx1 + cw) >= ox1) && (cx1 <= ox2)) && (character[j].y > object[i].Baseline) && ((character[j].y - character[j].z) >= (object[i].Y - oh))) surface.DrawCharacter(character[j]);
          }
          j++;
        }
      }
    }
    i++;
  }


It doesn't take into account the baseline of the objects, and it only seems to ever draw one object on it's surface. How do I sort objects by their baseline and draw them top-to-bottom, instead of by their object IDs? Otherwise I get stuff like this:



Which makes the effect kind of pointless. (The other object is invisible even when it's Y coordinate is above the translucent sprite. I have no idea what's going on!)

I'm really sorry for being so useless at solving these problems. This must be getting really irritating. x3
#368
It's cool, Denzil, I'm really liking this plugin and it can do some amazing things compared to plain AGSScript. It's mostly my newness to Lua that is holding me back.

I corrected those errors, but I'm still getting the same problem:

Code: Lua
function Colourise (ds)
  local surface = ds:GetDrawingSurface ()
  local i = 0;
  local j= 0;
  local h = ds.Height
  local w = ds.Width
  local cpixel;
  while (j < h)
  do
    while (i < w)
    do
      cpixel = surface:GetPixel (i, j)
      if (cpixel == -1)
        then
          surface.DrawingColor = 0
      else 
          surface.DrawingColor = C8PaletteMap [cpixel]
        end
      surface:DrawPixel (i, j)
      i = i + 1
    end
    i = 0
    j = j + 1
  end
  surface:Release ()
end
#369
Okay, copied the lua file into Notepad++ to count the lines there, solved that issue.

But there are so many other issues cropping up I am beginning to lose hope that I'll ever get this done. I don't think I'm quite qualified to even do this.

1) The colourisation function crashes AGS with the same
Quote
Error: [Lua] [string "local select = select;local error = error;l..."]:1: bad argument #2 to 'setter' (number expected, got nil)
Error. I have no idea what is going wrong there. I added a UsingLua bool you can switch on and off to see the intended effect there.

2) Only Object 0 is affected by translucency. Even though in repeatedly_execute_always it iterates through all of the objects on screen, only Object 0 will be translucent.

3) Other objects are invisible behind a translucent object. I think this is related to 2, as somewhere along the line the function is just choking. Characters render fine. This is odd, as I knew I tested this in the AGSScript version. It just... stopped working.

I'll put the project here:
https://dl.dropboxusercontent.com/u/50882197/Game/paltest321_errors.zip
If anyone wants to take a look. It uses the FakeScreen functions (DrawObject, DrawCharacter) to build the background and the characters on it so that the translucency drawing functions know what is behind the object at the time. The workflow goes:

repeatedly execute always: Is there translucency to be rendered? If so, create a surface and start building on it until a translucent object needs to be rendered. Then, render the translucent object (DrawObject) and set that to be the object's graphic.
#370
Okay, I managed to make ProcessPalette start working! It's pretty smooth up until Next error is this particularily nebulous one:

QuoteAttempt to compare nil with number

Code: Lua
function ProcessPalette (...)
  local palindex = {...}
  local paltemp = {...}
  local i = 0
  local i2 = 1
  local upperboundary = 0
  C8Palgorithm = {}
  C8PaletteMap = {}
  while (i < table.getn(palindex))
  do
    --paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
    paltemp [i] = palette_r [i] + palette_r [i] + palette_r [i] + palette_b [i] +  palette_g [i] + palette_g [i] + palette_g [i] + palette_g [i]
    paltemp [i] = bit.rshift(paltemp [i],3) 
    i = i + 1
  end
  i = 0
  C8palgorithm = {}
  while (i < table.getn(palindex))
  do
      if (i > table.getn(palindex)-2) then upperboundary = 255
      else upperboundary = (paltemp [i] + paltemp [i + 1])/2  --THIS IS THE LINE IT CHOKES AT
      end
      
      while (i2 < upperboundary)
      do
        C8palgorithm [i2] = palindex[i]
        i2 = i2 + 1
      end
    i = i + 1
  end
    
   i= 0
   paltemp = {}
   while (i < 255)
      do
       --paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
       paltemp [i] = palette_r [i] + palette_r [i] + palette_r [i] + palette_b [i] +  palette_g [i] + palette_g [i] + palette_g [i] + palette_g [i]
       paltemp [i] = bit.rshift(paltemp [i],3)
       i = i+ 1
      end
    i = 0
    while (i < 255)
      do
       C8PaletteMap [i] = C8palgorithm [paltemp[i]]
       i = i + 1
      end
  
end


Splitting the line into two:

Code: Lua
        upperboundary = paltemp [i] + paltemp [i + 1]
        upperboundary = upperboundary /2 --It chokes here now.


I'm sure I'll be able to figure out errors like these when I get more used to Lua, but... choking on a simple division?
#371
Got this:

QuoteScript link failed: Runtime Error: Unresolved import 'Lua::Evaluate^2'

I am really sorry I am having so much trouble with this. x3
#372
Funny, I do have that version (LuaForAGS_v6_b), but it's not got ToArray in it. I'm not sure what's going on there. Perhaps it wasn't implemented yet?
#373
I get:

Quotepal2.asc(569): Error (line 569): '.ToArray' is not a public member of 'LuaValueList'. Are you sure you spelt it correctly (remember, capital letters are important)?

Maybe it's in a newer version than what I've got? Where's the latest version of the plugin?
#374
Yeah, there's probably not enough purples and purple-like colours in the palette for it to work properly. It DOES, however, work really nicely for a wide variety of effects - I'm not quite sure how to make characters translucent yet as that requires fiddling around with the ViewFrame functions and that is some deep stuff I don't want to mess around with.

I'm trying to code a workaround for passing the palette to Lua, but I don't think Lua likes having 256 parameters in it's functions.

Code: AGS
function GiveLuaPalette ()
{
  LuaValueList *r = Lua.NewValueList();
    int i = 0;
    while (i < 255)
    {
        r.Add(Lua.IntValue(palette[i].r));
        i ++;
    }
    Lua.Call("CatchPalette_R", r, eLuaUnprotectedMode);
    
    LuaValueList *b = Lua.NewValueList();
    i = 0;
    while (i < 255)
    {
        b.Add(Lua.IntValue(palette[i].b));
        i ++;
    }
    Lua.Call("CatchPalette_B", b, eLuaUnprotectedMode);
    
      LuaValueList *g = Lua.NewValueList();
    i = 0;
    while (i < 255)
    {
        g.Add(Lua.IntValue(palette[i].g));
        i ++;
    }
    Lua.Call("CatchPalette_G", g, eLuaUnprotectedMode);
}


function ProcessPaletteLua (int palsiz, int palindex [])
{
  GiveLuaPalette ();
  LuaValueList *list = Lua.NewValueList();
    int i = 0;
    while (i < palsiz)
    {
        list.Add(Lua.IntValue(palindex[i]));
        i ++;
    }
    Lua.Call("ProcessPalette", list, eLuaUnprotectedMode);
}

static function PALgorithms::ProcessPalette (int palsiz, int palindex[])
{
  /*
  int paltemp [];
  paltemp = new int [palsiz];
  char i = 0;
  int i2 = 1;
  int upperboundary;
  while (i < palsiz)
  {
    paltemp [i] = (palette[palindex[i]].r +  // This algorithm produces an accurate, fast approximation of
                   palette[palindex[i]].r +  // The luminescence value of each of our palette slots.
                   palette[palindex[i]].r +  //
                   palette[palindex[i]].b +  // This ensures that when we colourise the final product, there 
                   palette[palindex[i]].g +  // will be little to no weird artifacts or lightness shifts.
                   palette[palindex[i]].g +  //
                   palette[palindex[i]].g +  // By using addition and bit shifts instead of multiplication, 
                   palette[palindex[i]].g    // the code will run a lot faster and more efficiently.
                   )>>3;
    i++;
  }
  i = 0;
  while (i < palsiz)
  {
      //Display ("%d , %d", i,  i+1);
      if (i > palsiz -2) upperboundary = 255;
      else upperboundary = (paltemp [i] + paltemp [i + 1])/2;
      //Display ("%d",upperboundary);

      while (i2 < upperboundary)
      {
        String output;
        _C8palgorithm [i2] = palindex[i];
        i2++;
      }
    i++;
    }
    
    i= 0;
    paltemp = new int [256];
    while (i < 255)
      {
       paltemp [i] = (palette[i].r +  // This algorithm produces an accurate, fast approximation of
                      palette[i].r +  // The luminescence value of each of our palette slots.
                      palette[i].r +  //
                      palette[i].b +  // This ensures that when we colourise the final product, there 
                      palette[i].g +  // will be little to no weird artifacts or lightness shifts.
                      palette[i].g +  //
                      palette[i].g +  // By using addition and bit shifts instead of multiplication, 
                      palette[i].g    // the code will run a lot faster and more efficiently.
                      )>>3;
                      i++;
      }
    i = 0;
    while (i < 255)
      {
       _C8PaletteMap [i] = _C8palgorithm [paltemp[i]];
       i++;
      }
      */
      ProcessPaletteLua (palsiz, palindex);
  } 
  
function Colourise (DynamicSprite* sprite)
{
  LuaValueList *list = Lua.NewValueList();
  list.Add(sprite.AsLuaValue());
  Lua.Call("Colourise", list, eLuaUnprotectedMode);
}

function ColouriseArea (this DynamicSprite*, int x1,  int y1,  int w,  int h)
{
  DrawingSurface *Surface;
  DynamicSprite *Area;
  //Display ("Init C8");
  mouse.Visible = false;
  Wait (1);
  Area = DynamicSprite.CreateFromScreenShot (320, 200);
  //Display ("Screenshot created.");
  mouse.Visible = true;
  if (Area.ColorDepth != 8) AbortGame ("Error in COLOR8: Isn't an indexed image!");
  int realwidth = w;
  int realheight = h;
  if (x1 + w > 320) realwidth = 320 - x1;
  if (y1 + h > 200) realheight = 200 - y1;
  int realx = x1;
  int realy = y1;
  if (x1 == 320) 
  {
    realx = 319;
    realwidth = 1;
  }
  if (y1 == 200)
  {
    realy = 199;
    realheight = 1;
  }
  Area.Crop (realx, realy, realwidth, realheight);
  Colourise (Area);
  /*Surface = Area.GetDrawingSurface ();
  int i;
  int j;
  int cpixel;
  while (j < h)
  {
    while (i < w)
    {
      cpixel = Surface.GetPixel (i, j);
      //Display ("Coordinates: %d, %d. Colour: %d",i, j,  Surface.GetPixel (i, j));
      if (cpixel == COLOR_TRANSPARENT) Surface.DrawingColor = COLOR_TRANSPARENT;
      else Surface.DrawingColor = _C8PaletteMap [cpixel];
      Surface.DrawPixel (i, j);
      i++;
    }
    i = 0;
    j++;
  } 
  this.Crop (x1, y1, w, h);
  Surface.Release ();
  */
  this.Crop (realx, realy, realwidth, realheight);
  Surface = this.GetDrawingSurface ();
  Surface.DrawImage (0, 0, Area.Graphic);
  Surface.Release ();
  Area.Delete ();
  return this.Graphic;
}


Code: Lua

function CatchPalette_R (...)
  local i = 0
  local r = {...}
  palette_r = {}
  while (i < 255)
  do
      palette_r [i] = r[i]
      i = i + 1
  end
end

function CatchPalette_B (...)
  local i = 0
  local b = {...}
  palette_b = {}
  while (i < 255)
  do
      palette_b [i] = b[i]
      i = i + 1
  end
end

function CatchPalette_G (...)
  local i = 0
  local g = {...}
  palette_g = {}
  while (i < 255)
  do
      palette_g [i] = g[i]
      i = i + 1
  end
end


function ProcessPalette (...)
  local palindex = {...}
  local paltemp = {...}
  local i = 0
  local i2 = 1
  local upperboundary
  C8Palgorithm = {}
  C8PaletteMap = {}
  while (i < table.getn(palindex))
  do
    --paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
    paltemp [i] = palette_r [i] + palette_r [i] + palette_r [i] + palette_b [i] +  palette_g [i] + palette_g [i] + palette_g [i] + palette_g [i]
    paltemp [i] = bit.rshift(paltemp [i],3) 
    i = i + 1
  end
  i = 0
  C8palgorithm = {}
  while (i < palsiz)
  do
      if (i > palsiz -2) then upperboundary = 255
      else upperboundary = (paltemp [i] + paltemp [i + 1])/2; end
      
      while (i2 < upperboundary)
      do
        C8palgorithm [i2] = palindex[i]
        i2 = i2 + 1
      end
    i = i + 1
  end
    
   i= 0
   paltemp = {}
   while (i < 255)
      do
       --paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
       paltemp [i] = palette_r [i] + palette_r [i] + palette_r [i] + palette_b [i] +  palette_g [i] + palette_g [i] + palette_g [i] + palette_g [i]
       paltemp [i] = bit.rshift(paltemp [i],3)
       i = i+ 1
      end
    i = 0
    while (i < 255)
      do
       C8PaletteMap [i] = C8palgorithm [paltemp[i]]
       i = i + 1
      end
  
end

function Colourise (ds)
  local surface = ds:GetDrawingSurface ()
  local i;
  local j;
  local h = ds.Height
  local w = ds.Width
  local cpixel;
  while (j < h)
  do
    while (i < w)
    do
      cpixel = surface:GetPixel (i, j)
      if (cpixel == 0)
        then
          surface.DrawingColor = 0
      else 
          surface.DrawingColor = C8PaletteMap [cpixel]
        end
      surface:DrawPixel (i, j)
      i = j + 1
    end
    i = 0
    j = j + 1
  end
  surface:Release ()
end


It just quits with an unspecified error.
#375
Additional suggestion: Can we get the 8 bit palette arrays accessable in Lua? I'm currently working on a module that relies on the palette and Lua doesn't have access to it (I tried ags.palette.r etc and it came up with nothing).

Also, LuaValueList.ToArray() seems to be missing from the copy of the plugin on the Downloads page? It doesn't show up in Autocomplete, and it doesn't compile, but it IS in the documentation.

Lua.Evaluate is also missing.
#376
I was testing the very edges of the translucency effect, since I only have 8 CLUTs at the moment, change the SetTransparency function in Room 1.asc to 50 to see a more spectacular effect.

And I'll do that, thanks Calin!
#377
The 3.2.1 files are here: https://dl.dropboxusercontent.com/u/50882197/Game/paltest321.zip

Also, how do you access the palette array with Lua? I've tried ags.palette.r et al but it just returns:
Error: [Lua][string "ProcessTranslucency.lua"]:99 attempt to index field 'palette' (a nil value)

Code: Lua
function ProcessPalette (...)
  local palindex = {...}
  local paltemp = {...}
  local i = 0
  local i2 = 1
  local upperboundary
  C8Palgorithm = {}
  C8PaletteMap = {}
  while (i < table.getn(palindex))
  do
    paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
    paltemp [i] = bit.rshift(paltemp [i],3) 
    i = i + 1
  end
  i = 0
  C8palgorithm = {}
  while (i < palsiz)
  do
      if (i > palsiz -2) then upperboundary = 255
      else upperboundary = (paltemp [i] + paltemp [i + 1])/2; end
      
      while (i2 < upperboundary)
      do
        C8palgorithm [i2] = palindex[i]
        i2 = i2 + 1
      end
    i = i + 1
  end
    
   i= 0
   paltemp = {}
   while (i < 255)
      do
       paltemp [i] = ags.palette[i].r + ags.palette[i].r + ags.palette[i].r + ags.palette[i].b +  ags.palette[i].g + ags.palette[i].g + ags.palette[i].g + ags.palette[i].g
       paltemp [i] = bit.rshift(paltemp [i],3)
       i = i+ 1
      end
    i = 0
    while (i < 255)
      do
       C8PaletteMap [i] = C8palgorithm [paltemp[i]]
       i = i + 1
      end
  
end
#378
Hey, I've been using the Lua plugin for a couple of days now, and I'm loving it's speed - this is the best thing for complex scripting. AGS Script has nothing on it.

However, I've been having a few problems with it.

Firstly, if you rename a script, it will duplicate the entry and deleting one of the entries will crash AGS and remove "both" scripts.

Secondly, I've been having some problems with the project getting corrupted if AGS doesn't crash cleanly. In 3.3.0, at least, if the engine stalls and needs to be shut down manually (prompting the "The AGS engine did not shut down properly" error in AGS), any Lua calls will crash a few loops in with:

QuoteAdventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.3.0.1148)

Error: [Lua] [string "local select = select;local error = error;l..."]:1: bad argument #2 to 'setter' (number expected, got nil)

I've included a copy of the ruined project here: https://dl.dropboxusercontent.com/u/50882197/Game/paltest_ruined.zip

Other than that, it's brilliant, and I love it! I want to continue using Lua for engine-intensive code.
#379
Okay, I've moved all of the necessary files over to 3.2.1 and I'll just work on this module from there until it can be confirmed that Lua and 3.3.0 can work nicely together. (And I'll hit up the Lua plugin thread to give my bug reports.)

I'm now converting this code:

Code: AGS

static function PALgorithms::ProcessPalette (int palsiz, int palindex[])
{
  int paltemp [];
  paltemp = new int [palsiz];
  char i = 0;
  int i2 = 1;
  int upperboundary;
  while (i < palsiz)
  {
    paltemp [i] = (palette[palindex[i]].r +  // This algorithm produces an accurate, fast approximation of
                   palette[palindex[i]].r +  // The luminescence value of each of our palette slots.
                   palette[palindex[i]].r +  //
                   palette[palindex[i]].b +  // This ensures that when we colourise the final product, there 
                   palette[palindex[i]].g +  // will be little to no weird artifacts or lightness shifts.
                   palette[palindex[i]].g +  //
                   palette[palindex[i]].g +  // By using addition and bit shifts instead of multiplication, 
                   palette[palindex[i]].g    // the code will run a lot faster and more efficiently.
                   )>>3;
    i++;
  }
  i = 0;
  while (i < palsiz)
  {
      //Display ("%d , %d", i,  i+1);
      if (i > palsiz -2) upperboundary = 255;
      else upperboundary = (paltemp [i] + paltemp [i + 1])/2;
      //Display ("%d",upperboundary);

      while (i2 < upperboundary)
      {
        String output;
        _C8palgorithm [i2] = palindex[i];
        i2++;
      }
    i++;
    }
    
    i= 0;
    paltemp = new int [256];
    while (i < 255)
      {
       paltemp [i] = (palette[i].r +  // This algorithm produces an accurate, fast approximation of
                      palette[i].r +  // The luminescence value of each of our palette slots.
                      palette[i].r +  //
                      palette[i].b +  // This ensures that when we colourise the final product, there 
                      palette[i].g +  // will be little to no weird artifacts or lightness shifts.
                      palette[i].g +  //
                      palette[i].g +  // By using addition and bit shifts instead of multiplication, 
                      palette[i].g    // the code will run a lot faster and more efficiently.
                      )>>3;
                      i++;
      }
    i = 0;
    while (i < 255)
      {
       _C8PaletteMap [i] = _C8palgorithm [paltemp[i]];
       i++;
      }
  } 


But I'm not sure how to pass a dynamic array to Lua. The wiki doesn't seem much help. :( Everything else is fine, I can deal with that, but there isn't much documentation on transferring arrays between AGS and Lua.
#380
Rebuild All Files didn't work. Hmm. I just wish it was a little more stable on my end. :P This makes it very hard to want to use it in a real game, if there's a danger of an editor or engine crash that messes everything up. Not all script errors quit neatly!

I'll upload the project file - It works, you can see the translucency, but on Loop 17 it falls dead.

https://dl.dropboxusercontent.com/u/50882197/Game/paltest_ruined.zip (3.3.0)

And the version of Lua for AGS I'm using is the one from here: http://lua-for-ags.wikispaces.com/Downloads
SMF spam blocked by CleanTalk