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 - RickJ

#1861
Adventure Related Talk & Chat / Re:Resources?
Wed 03/03/2004 09:49:18
There are several place to find resources that may help.  Search the forum for the following:

  • Insta-Game - click here
  • RON (Reality on the Norm) - search forum
  • AGS Demo Game - AGS Download Page

    Follow link in my sig to BlueGui download for scripting examples.  Hope this helps.

    Cheers
    RickJ
#1862
General Discussion / Re:Internet ads gone wild
Wed 03/03/2004 05:33:22
For anyone thinking abut giving FireFox a try, you may want to check out this link.  

http://www.mozilla.org/products/firefox/why/
#1863
Maybe it could check the cookies the forum uses also.  That way if you login in one place you are already logged in at the other?  
#1864
Kinoko,

I'll try to explain as much as I can for you and perhaps others who  are wondering the same things.  

Quote
Well, this is the code given to me by others to solve the animating background problem I had earlier with blocking functions clashing with the bg animating.
I haven't seen the earlier thread of which you speak so I can't comment on that.

Quote
Even when I take ALL that extra code away ... , and simply have a MoveCharacter function on "any click", and the standard animated background (without any scripting, just importing them into the room), the same thing happens. ...
If you are still having this problem I'll try to help you with that.  I am not at my normal computer at the moment so I can't do any testing until later tonight.  

Quote
Whether it's a messy way of doing it or not (I don't know any other way), to my knowledge, it should be working. I just don't understand what's wrong.
Let me see if I can help you better understand what was wrong with the script you posted above.   You have a function named object0_a().  When a function is called, any memory space that it requires is allocated in a special area called a stack.  When the function finishes execution this meory is freed up.

If you can imagine a cafeteria where the dinner plates are stacked up and sit on a spring mechanism.  When you put more plates on top of the stack or take them away the spring mechanism keeps the top of the stack in the same place.   Stack meory areas are accessed in a similar manner.  

When a function is called, it's parameters are "pushed" on to the stack.  Variable declared inside the bounds of the function are allocated in the stack area as well.  

int waitimer=100;
So when your statement  "int waitimer=100;" creates a variable on the stack that is good only for the time the function is executing.  Whenever the function finishes that memory is free to be used by other functions or processes.   This also means that if you create a variable of the same name in another function, it will be a separate variable, a separate memory location.  

while (waitimer)
The while command will keep executing the code within the bounds of it's braces, {}, until the conditional expression evaluates to false.   I am not sure how AGS evaluates integer numbers other than zero or one.  It is generally considered bad practice to use integer values other than zero or one in such an expression.  A better, more reliable, more readable, way of writing this statement  would be "while (waitimer > 0)".    

Wait(1);
There is not much to say about this, other than read help to see what Wait() does.  :)  

object0_a();
Ouch!!!  This one hurts me for a couple of reasons.  I guess the worst thing is that you are calling the function object0_a() from within itself.  This situation is known as a recursive call.  The function is called from somewhere, and then it calls it self and that call calls itself,  etc.  It's sort of like placing two mirrors in fornt of each other, you get an infinite number of images.  In the case of a recursive function call you end of allocating an infinite amount of memory (remember the stack thing above).  Recursion is normally used to walk through hiearchical tree data structures (i.e. list all directories and sub-directories on the disk).  It works in this case because the number of recursive calls is limited to the depth of the hiearchy.   Although this kind of technique is not considered bad practice, it is seldom required in the scripting of an AGS game and is not recommended, IMHO.

The second thing that I don't like about this is that the function object0_a() is an event handler.  It was created by the AGS editor to be triggered by the game engine.   Although it's possible to do this and get away with it, the likelyhood of problems is greatly increased and it makes debugging difficult.  This is especially  when asking for help on the forums because it's something neither the game engine nor an experienced programmer would expect or anticipate.   Calling event handlers normally triggered by the game engine, I believe, is also considered bad practice.

waitimer--;
This statement decrements the variable "waitimer" by 1.  All is well here.

Bad Practice
When I use the term "Bad Practice"  I am referring to programming techniques that lead to errors, present and future.   It has been my experience that the most time consuming part of debugging a program is finding the bugs.  Once found and understood they are generally easy to  fix.   Bad programming practices make bugs more difficult to locate and to fix.  In addition, things that wok now may not work on a future version of the OS, game engine, compiler, etc...  Avoiding bad practices help avoid bugs in the first place which is the best way to debug a program, IMHO.

How would I do it?
Ok.  If I'm so darn smart then how would I have written this program?   I don't know what you were trying to accomplish by recursively calling the event handler so I can't address that specifically.  But I can show you what I would do in the case where  I wanted to perform the same operations as an event handler from somewhere else.

Original Version
function object0_a()
{
   int waitimer=100;

   while (waitimer) {
      Wait(1);
      object0_a();
      waitimer--;
   }
} 

Improved  Version
// Make our own function to do the common operations
function kinoko_stuff()
{
   int waitimer=100;

   while (waitimer>0) {   // Make sure expression evaluates to 0,1
      Wait(1);
      // object0_a();   don't know what this was supposed to accomplish, but whatever it was it doesn't do it.
      waitimer--;
   }
}

function object0_a()
{
   kinoko_stuff();          // Call function that does the common operations
} 

Original Problem
Kinoko, I know this doesn't help much with your original problem.  I hope it helps you understand a bit more of what is going on.   Post a link to the previous thread to which you are referring to and I will take a look at it later tonight.

Everyone else,  sorry for the lengtlhly explanation but I think that's what kinoko wanted.

Cheers
Rick
#1865
I upgraded to cable modem recently and so consequently I will need to move my AGS creations (3) to a new web location. I am not sure I remember all the passwords to be able to edit  the relevant bits.  In the past I sent off a PM and to ask that it be reset.    Anyway my current situation and previous experiences have inspired this idea:

Would it be a good idea for each author to have a single username and password?   Maybe have it so that an author could login to the games page once and have access to all of his or her games without re-enterng passwords?  Maybe have a list of the author's games as well?  

Admittedly this seems to be a fairly low priority function.   However, if the rest of the group thinks it's a good idea and if we can sketch out how it should work, then maybe it could go on a future todo list or someting.  

#1866
Generally speaking it's not a good practice to call event handler functions, let the AGS engine do that.  If you have functionality that is commmon to two or more events or situations define your own function that does that particular task and call it from the event handler function.
#1867
Are you recursively calling the object0_a() function?

function object0_a()
{
   int waitimer=100;

   while (waitimer) {
      Wait(1);
      object0_a();
      waitimer--;
   }
} 
#1868
  • I think Klaus has the best overall structure.  The navigation seems to be both flexible and intuitive.    

  • I like Loomis' color scheme.  It matches the forum's color scheme.  His banner is pretty cool as well.  

  • I like the Darth-B headline "What is AG?" and his banner.  Both are really cool.  
#1869
General Discussion / Re:Internet ads gone wild
Mon 01/03/2004 00:25:39
Just goto mozilla.org and download firefox, no more popups.  Plus you can right clicl an image and block all images from the same serve.

#1871
Normally this kind of thing is implemented using the option-on/off command.  There is  not an if-then-else construct in the dialog script language.  However, you can use the run-script command to trigger the dialog_request() event handler function in the global script which can have if-then-else constructs and which can enable/disable dialog options using the  SetDialogOption() function.  Lookup the following in the help file:

  • SetDialogOption()
  • Dialog
  • dialog_request()

    From thehep file:
    run-script X 
    Runs global text script function "dialog_request", with X 
    passed as the single parameter. This allows you to do 
    more advanced things in a dialog that are not supported 
    as part of the dialog script. The "dialog_request" function 
    should be placed in your game's global script file, as 
    follows: 
    
      function dialog_request (int xvalue) {
        // your code here
      }
    
     
#1872
Use SetButtonPic() to change the buttons appearance.  Then put an "if" statement in the gloabl script section of the code that handles the functionality for that button(s).

#1873
600x50 sounds to be a very reasonable comprise to me,  providing of course, that the "50" refers to the height .  ;)

Also would it be asking too much that these images not be animated or use anomizers?  Bright colors flashing about make it difficult for an old fart like myself to read the threads and the anomizers really slow things down because of the repetitious nature of sigs and avatars.  


#1874
In the dialog you can do a "Run Script Command".  This will trigger an event handler to run in the global scriopt file.  Check the help file to see how to do this.

In the global script file just do the following to give the NPC one of the inventory-1 objects.  

character[NPC].inv[1] = 1;  

#1875
You need to have cookies enabled in your browser.  When you login your username and paword get written to cookies on your machine.  If cookies are enabled then you may want to try deleting any cookies written by this forum and try loggin in again.  The names of the cookies probably contain  some combination and variation of  "yabb",  "ags", "username", "password".  
#1876
QuoteIn that case, we should remove all pics from sigs.
I guess that would be my point... A spamless forum,what a concept :)
#1877
DG  I guess you missed the point!  Boobs in the sig is spam!  Images in sig is spam!  Images that use anomizers and lousy servers is worse than spam!   I hate spam!!!  

Get it ?  SPAM  sucks, it doesn't matter what kind of spam it is, it still sucks.  

Quote
... they're not going to damage anyone's precious mind.
No but they may be enough to pissoff/embarass/whatever  someone's girlfriend, wife,  mother, kids, etc  or percipitate a sexual harassment lawsuit.   Besides I didn't know this was the place to come for sex.  

Posting a disturbing pic in a thread is quite different than posting it in one's sig.   It's easy enough to scroll past  a single entry in a thread  but you can't avoid the sig being repeated post after post after post after post after post after post after post after post after post after post after post after post.....

It's just annoying and rude INMHO  ....
#1878
I'm with Brusie on this one guys.   We should consider eliminating all images in signature lines or restricting them to 20x60 pix non-animating images.  Further we should also consider banning avatar image not directly accessable.  Why do you ask?

1.  The forum performance has been getting worse and worse.  My browser sit there  with the feakin hourglass while someone's sig is loading a useless cartoon via invis or some other anomomyizer.  

2.  Many of us have down time at work and could contribute to the forum.  Before any of you try lecture me about cheating or being on my companies time, keep in mind I work for myself and lately have been doing fixed price contracts (i.e. mucho waiting time while client catches up and completes their part of the project).   Even though it's my own time, it's not appropriate to have of big busted cartoon, giant pack mem runnign around the computer screen at my client's p[lace of business.  

3.  Images in sigs are completely useless and do noting but slow everything down.  They are also hugely redundant and very annoying.  

That's all of my rant!!!  How's that for an old fart Brusie?

Cheers!!!

[edit]
delete crap ....
[/edit]
#1879
If AuroraBoy or someone else would like to draw a background and gate sprites I could take it a bit further.  I would make an example room and modify the tutorial to have more details, screenies, etc...  Any colaborators?


P.S.  Scumm, Thanks for the graphics you sent me at the end of last year.  I haven't had a chance tyo incorporate them into Bluster yet.  While I was away  my wife bought a new house and the my current client's CEO passed away.    I'll be back to normal soon and will  be releasing Bluster with your graphics shortly.  Thaks for y our contributions.

RickJ

[edit]
P.S. Again, I also have the tutorial in plain text format if that is of any use to anyone I will make it available.
#1880
STEP BY STEP

Animating The Gate
The first thing to is to darw a sequence of pictures of the gate in various stages of opening. The same sequence can be used for closing so only one sequence will be necessary. The sequnce can be stored as a series of frames in a single file or in multiple files (i.e. one frame per file).  Once the pictures are drawn they must be imported using the AGS Sprite Manager. Next use the View Editor to create a "view" or collection of animation loops.  In this case we will need only one animation loop.  So in Loop-0 assign the appropiate sprites to Loop-0's frames to depict the gate opening where frame-0 shows the gate closed and frame-n shows the gate open.  A summary of what we have done follows:

1.  Draw a sequence of pictures showing the gate opening.

2.  Import the picturs into the AGS Sprite Manager  

3.  Create a View and a Loop using the View Editor

Adding the Gate to the Room
At this point it is assumed that you have created a room and have imported a background picture. The background picture should be minus the gate; the gate will be added using an object. To add the gate first open the room file using the Room Editor. Next select the RoomEditor->Objects screen, click the New Object button, and then click on the background picture in the general location of the gate. The infamous blue cup should appear on the background image.  Now click on the Change Image button. A Sprite Manager type screen will appear.  Navigate to the closed gate sprite and double click on it. Now there should be an image of the closed gate on the background image.  Drag the gate image to it's proper location on the background.  The next last thing to do is to set a baseline. The base line determines if characters are drawn in front of or behind the gate.  If the character's baseline is above an object's it will be drawn behind the object and in front og the object otherwise. To set the gate's baseline click on the Set Baseline button and then position the cursor at the bottom edge of the gate and click. A horizontal line should appear denoting the location of the baseline.  A summary of what we have done follows:

1. Create a room and import the background image.

2. Create a new object in the room.

3. Change the object's image to the closed gate sprite.

4. Drag the gate image to it's proper location on the background.

5. Set the gate's baseline.

Adding a Gate Interaction
Using the same RoomEditor->Objects screen, click the Interaction button. The Interaction editor window should popup. Double click on Interact Object in this window to add an action to this event. A Configure Action dialog box appears.  Select "Run Script" from the drop down list and click the OK button to close the dialog box.  Now close the Interaction Editor window also. To see the event handler function we have just created select the RoomEditor->Settings screen and press the Edit Script button denoted by the {} curly bracs.  A Text Editor window will open showing the following script code:  
   // text script for room

   function object0_a() {
        // script for object0: Interact object
  
   }

The name of the event handler function we just created is object0_a and it has no parameters. Click on "File->Exit and save changes" from the Text Editor menu. A summary of what we have done follows:

1. Use Interaction Editor to create an event handler function

2. Use Text Editor to view newly created event handler function in the room script file.

Creating Walkable Areas
Before getting into more scripting there is one more thing we need to do to the room and that is to define walkable areas. We need to have at least three areas. One in front of the gate, one behind the gate, and one at the threshold of the gate.  The walkable area at the threshold of the gate should begin a little before the gate and end a little past the gate.  It should be large enough so that the character can't pass through when it's disabled.  To do this select the RoomEditor->Areas screen and then select "Walkable areas" from the drop down list.  Use the Spin control to select which walkable area to edit. Start with Area-1. Use the line and fill tools to draw the threshold area, Using the spin control select Area-2 and draw the walkable area in front of the gate. Select Area-3 and draw the walkable area behind the gate. A summary of what we have done follows:

1. Add walkable area #1 at gate threshold

2. Add walkable area #2 in front of gate

3. Add walkable area #3 behind gate

Making it All Work
Now it's programming time!!! Let's start by opening the Room Script file with the Text Editor. Select the RoomEditor->Settings screen and clicking on the {} button as we did earlier.  Use the cursor keys to navigate around the the file and juststype to insert text at the cursor.  

The first thing to do is to define constant values to represent the states of the gate. All this does is put a name to a numeric value for our convenience.  This is done using the #define directive as follows.
   // define some constant values
   #define OPENED -1000
   #define CLOSED -1001

I prefer using large negative numbers when defining such terms.  Many AGS functions use/return small negative and positive numbers and there is potential for conflict and confusion.  

The next thing to do is to define a variable to hold the gate's current state. We do thisbyentering the following in the script file. Because it defined is outside the bounds of a function definition it will maintain it's value throughout the game. In addition it's value will be save/restored by the save game mechanism.
   // gate's current state 
   int gate_state = CLOSED;

Next we will create our own function that will operate the gate.  We begin the function definition by typing the following:
   // Operate gate function 
   function OperateGate() {
   }

We want this function to open the gate if it's closed and close it if it's open. So we need to add an if-else construct as shown below.  Each time the function is executed it will toggle the state of the gate.
   // Operate gate function 
   function OperateGate() {
      // if the gate is open then close it ...
      if (gate_state == OPENED) {
                                       // repeat=0, direction=1, blocking=1
          // set gate's current state 
         gate_state = CLOSED;
      }
   
      // otherwise open it
      else {
                                       // repeat=0, direction=0, blocking=1
          // set gate's current state 
         gate_state = OPENED;
      }
   }

Now we can add gate sounds when it opens or closes.  We may as well enable and disable the walkable area under the gate's threshold also. This prevents the characters from walking through a closed gate.
   // Operate gate function 
   function OperateGate() {
      // if the gate is open then close it ...
      if (gate_state == OPENED) {
         //Play sound of gate closing
         PlaySound(1);      // sound1.wav

         // Prevent characters rom walking through closed gate
         RemoveWalkableArea(1);   // area-1 is under gate threshold

          // set gate's current state 
         gate_state = CLOSED;
      }
   
      // otherwise open it
      else {
         //Play sound of gate opening
         PlaySound(2);      // sound2.wav

         // Prevent characters rom walking through closed gate
         ReStoreWalkableArea(1);   // area-1 is under gate threshold

          // set gate's current state 
         gate_state = OPENED;
      }
   }

Finally we can add the animation of the gate as shown below.  One last thing; we have to call our function from an event handler.  This is done via the OperateGate(); statement in function object0_a().
   // text script for room

   // define some constant values
   #define OPENED -1000
   #define CLOSED -1001

   // gate's current state 
   int gate_state = CLOSED;

   // Operate gate function 
   function OperateGate() {
      // if the gate is open then close it ...
      if (gate_state == OPENED) {
         //Play sound of gate closing
         PlaySound(1);      // sound1.wav

         // Prevent characters rom walking through closed gate
         RemoveWalkableArea(1);   // area-1 is under gate threshold

         // Assign an animation loop to object, loop has frames 0..6 
         SetObjectFrame(0,1,0,6);   // object=0, view=1, loop=0, frame=6

         // Animate the gate
         AnimateObjectEx(0,0,0,0,1,1); // object=0, loop=0, delay=0, 
                                       // repeat=0, direction=1, blocking=1
          // set gate's current state 
         gate_state = CLOSED;
      }
   
      // otherwise open it
      else {
         //Play sound of gate opening
         PlaySound(2);      // sound2.wav

         // Prevent characters rom walking through closed gate
         RestoreWalkableArea(1);   // area-1 is under gate threshold

         // Assign an animation loop to object, loop has frames 0..6 
         SetObjectFrame(0,1,0,0);   // object=0, view=1, loop=0, frame=0

         // Animate the gate
         AnimateObjectEx(0,0,0,0,0,1); // object=0, loop=0, delay=0, 
                                       // repeat=0, direction=0, blocking=1
          // set gate's current state 
         gate_state = OPENED;
      }
   }
   
   function object0_a() {
        // script for object0: Interact object
      OperateGate();
   }


That's all I can write for now.  I need a few minutes sleep before going to work this morning.  
SMF spam blocked by CleanTalk