Showing posts with label Scripting. Show all posts
Showing posts with label Scripting. Show all posts
Monday, September 7, 2009
Lua of the temptress
Denzil Quixode tempts us with the sexy scripting language that is Lua. How, you may query? Well, he's only gone and written an editor AND runtime plugin to let you write all your data handling (since Lua is SO much better at that stuff than AGS) in Lua. Not only was Grim Fandango written with Lua but it also allows lots of puns! What more could one want? Check out the thread in the tech archive and then you'll be able to answer the question "Have you used Lua?" with something other than "Yes, sorry did I forget to flush?"
Tuesday, December 16, 2008
Handy code snippet #378
Babar was just asking on Stickam how you'd set a particular inventory item to be first of your inventory window (not rearranging inv item order, but just scrolling the window to the correct point). And here we are:
function settop(this InvWindow *, InventoryItem *thing)
{
int itemi=0;
while (itemi < this.TopItem) {
if (this.ItemAtIndex[itemi]==thing) {
this.TopItem=itemi;
return;
}
itemi++;
}
}
Thursday, November 6, 2008
Teen tutorial
Well, if you recall the video tutorials I mentioned a while ago (and I didn't recall them, thanks to IndieBoy for reminding me) you'll be pleased to hear that no less than the 19th one is out, and covers Text Overlays. densming is doing a great thing here, so a big thanks to him for creating this resource.
Wednesday, July 2, 2008
Your face looks all gooey
Following Dave Gilbert's problem of GUIs obscuring his Sierra-style character portraits, I made up a module that works around the problem by using another GUI to show the portraits on. I guess most people use Lucasarts-style speech so don't have this problem.
Wednesday, March 12, 2008
Upgrading Modules to AGS 3.0
I've been going through the Hypertext, Credits and SpriteFont modules checking if they need to be changed to work better under AGS 3.0. Forrtunately, Credits didn't need anythign doing at all. If you turn off "Enforce object-based scripting" in AGS 3.0, they all should still work, but they would be, still, using the Room background as a temporary draw space, then restoring it, which less efficient.
So, it turned out to be relatively painless to move to the DrawingSurface commands I mentioned before, but I have yet to fully test the upgraded modules at all game resolutions, which can often be the tricky bit to get working. Also, since my own site is on the same server as the AGS forums, I can't upload it right now anyway!
But to make sure the modules still work under 2.72 (and 2.71 and 2.70, where possible) I have to stick lots of
So, it turned out to be relatively painless to move to the DrawingSurface commands I mentioned before, but I have yet to fully test the upgraded modules at all game resolutions, which can often be the tricky bit to get working. Also, since my own site is on the same server as the AGS forums, I can't upload it right now anyway!
But to make sure the modules still work under 2.72 (and 2.71 and 2.70, where possible) I have to stick lots of
#ifver 3.0 and #ifnver 3.0 in all over the place, to wrap up the version-specific code. And then, if you have to support versions before 2.72, then you need to wrap those up in #ifdef AGS_SUPPORTS_IFVER as 2.71 and earlier didn't have the #ifver commands! So it can get quite convoluted. Then, I need to load up all the different versions and check they still work... Maintenance can be pretty non-trivial, sometimes.
Monday, March 10, 2008
Good names for modules?
Today I updated my DeNGVaT module for the first time in ages, as someone found a bug in it (D'oh!). This also probably indicates that they are also probably the first person to use it. I have to admit, the name is pretty cryptic (it stands for Debug, Named Global Variables and Timers) and I sometimes feel that it would be better calling it "Named Global" module or something that at least covered one aspect of it. The trouble is it does too much!
Another module that is similarly burdened is the Hypertext module. This allows you to use mark-up in your text, and it displays it properly, allowing you to change fonts, colours, underlines, etc. in mid-text. Most normally, one might use a bold version of a font in mid-sentence to emphasise a word. This can be marked up as "Yes, he *really* did do it!" for example, and the word "really" is displayed in bold when the module is used. It also does hyperlinks, so one can simulate a simple "intranet" browser within an AGS game. Since the text rendering is already there, I also extended it to do speech bubbles for characters. So perhaps the module should be called "Text markup rendering, hypertext and speech bubbles module". But that makes for a mighty long file name and a poor acronym.
So, I open the floor to suggestions for better names for any of my modules. Answers in the comments section below, please, and the best one wins a free mention in the newly named module and this blog. What more could you want, eh?
Another module that is similarly burdened is the Hypertext module. This allows you to use mark-up in your text, and it displays it properly, allowing you to change fonts, colours, underlines, etc. in mid-text. Most normally, one might use a bold version of a font in mid-sentence to emphasise a word. This can be marked up as "Yes, he *really* did do it!" for example, and the word "really" is displayed in bold when the module is used. It also does hyperlinks, so one can simulate a simple "intranet" browser within an AGS game. Since the text rendering is already there, I also extended it to do speech bubbles for characters. So perhaps the module should be called "Text markup rendering, hypertext and speech bubbles module". But that makes for a mighty long file name and a poor acronym.
So, I open the floor to suggestions for better names for any of my modules. Answers in the comments section below, please, and the best one wins a free mention in the newly named module and this blog. What more could you want, eh?
Wednesday, March 5, 2008
Extender functions
One of the coolest new features of AGS 3.0 is the extender function. Previously, if you wanted to use a function to, say, make your character look at someone before saying their line (e.g. in a 3-way conversation) you could script it manually each time:
Which gets tedious after a while, so you make up a function:
But what looks even better is:
So, you are, in effect, adding a new method to the Character class. This is a noddy example, but it can really lead to much nicer code.
cFred.FaceCharacter(cWilma);
cFred.Say("Hello Wilma");
cFred.FaceCharacter(cBarney);
cFred.Say("Hello Barney");
cFred.FaceCharacter(cWilma);
cFred.Say("How are you, dear");
Which gets tedious after a while, so you make up a function:
function FaceAndSay(Character *speaker, Character *facing, String what) {
speaker.FaceCharacter(facing);
speaker.Say(what);
}
...
// in script header
import function FaceAndSay(Character *speaker, Character *facing, String what);
...
FaceAndSay(cFred, cWilma, "Hello Wilma");
FaceAndSay(cFred, cBarney, "Hello Barney");
FaceAndSay(cFred, cWilma, "How are you, dear");
But what looks even better is:
function FaceAndSay(this Character *, Character *facing, String what) {
this.FaceCharacter(facing);
this.Say(what);
}
...
// in script header
import function FaceAndSay(this Character *, Character *facing, String what);
...
cFred.FaceAndSay(cWilma, "Hello Wilma");
cFred.FaceAndSay(cBarney, "Hello Barney");
cFred.FaceAndSay(cWilma, "How are you, dear");
So, you are, in effect, adding a new method to the Character class. This is a noddy example, but it can really lead to much nicer code.
Tuesday, March 4, 2008
Drawing Surfaces
AGS 3.0 introduces a new type to the game author called the
Previously, if you wanted to modify a sprite on the fly or do any complex drawing you had to save the background, clear it to the "magic pink" colour that turns transparent when grabbed, do your drawing, grab a dynamic sprite and then redraw the background how it was. This wasted time and could make things slower than they needed to be. The Drawing Surface concept lets you draw onto a Dynamic Sprite directly. Not only that, but it adds the ability to use hi-res co-ordinates within that sprite instead of the standardized 320x240 co-ordinates, if you wish. Further capabilities are added in the 3.01 beta where you can also grab the colour of a pixel within the drawing surface, just like the eyedropper tool in a paint program.
Modules like my Hypertext module, which allowed fonts to change in the middle of a piece of text (amongst other things) used the drawing-on-the-background extensively in version 2.72 but now they can be much more efficient and organised, and draw on dynamic sprites, which is great. If only I could get around to updating the module... and all the others that are affected by this: like SimpleSnow, SimpleRain, SpriteFont and Shadow...
DrawingSurface which allows you to do the equivalent of RawDraw commands on an object other than the current Background. You can also use it for the background, too.Previously, if you wanted to modify a sprite on the fly or do any complex drawing you had to save the background, clear it to the "magic pink" colour that turns transparent when grabbed, do your drawing, grab a dynamic sprite and then redraw the background how it was. This wasted time and could make things slower than they needed to be. The Drawing Surface concept lets you draw onto a Dynamic Sprite directly. Not only that, but it adds the ability to use hi-res co-ordinates within that sprite instead of the standardized 320x240 co-ordinates, if you wish. Further capabilities are added in the 3.01 beta where you can also grab the colour of a pixel within the drawing surface, just like the eyedropper tool in a paint program.
Modules like my Hypertext module, which allowed fonts to change in the middle of a piece of text (amongst other things) used the drawing-on-the-background extensively in version 2.72 but now they can be much more efficient and organised, and draw on dynamic sprites, which is great. If only I could get around to updating the module... and all the others that are affected by this: like SimpleSnow, SimpleRain, SpriteFont and Shadow...
Subscribe to:
Posts (Atom)