Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Gold Dragon on Wed 22/10/2003 07:59:33

Title: Big Fatal exception Error during runtime
Post by: Gold Dragon on Wed 22/10/2003 07:59:33
I told you guys would hear more of me but I hoped it wouldn't have been this soon.  :( :(   :'( :'(

ok I created a new cursor mode called 'move' in the Cursor's editor

then in the global Script I created this function to simulate moving an Object from one plance to another.
----------------------------------------------
function Move_Object(){
 int Objint;    // integer to store the object number

  // On the first Left click get the object # and store in Objint
  on_mouse_click (LEFT);{
   Objint=GetObjectAt(mouse.x,mouse.y);
 }

 // On the Second left click move the object to the new position the mouse is at
 on_mouse_click(LEFT);{
   MoveObjectDirect(Objint,mouse.x,mouse.y,3);
 }
}
----------------------------------------------

in the room script it looks like this
----------------------------------------------
// room script file

import function Move_Object();  // Import Move_object() from global Script

function room_a() {
 // script for room: Player enters screen (before fadein)
SetObjectIgnoreWalkbehinds(4,1);
SetObjectIgnoreWalkbehinds(5,1);  
}


// this is the script that is excuted when the 'move' cursor is activated in the interactions menu for Object 5

function object5_a() {  
 // script for object5: Move object
Move_Object();
}

-----------------------------------------------

When I click on the object I want to move when testing the game. I get this "illegal exception" message

An exception 0xC00000FD occured in ACWIN.EXE at EIP=0x0044B8E ;program pointer is+6, ACI version 2.56.627,
gtags (0,64)

(the message to notivefy CJ)

(Room 1 script line 116)

-------------------------------------------------

the script line 116 is the line
MoveObjectDirect(Objint,mouse.x,mouse.y,3);

I'm really sorry about this mess..

if you have another way to move an object during runtime by the user from one position to another please let me know.
Title: Re:Big Fatal exception Error during runtime
Post by: Pumaman on Wed 22/10/2003 20:50:22
Well, it really shouldn't be crashing like that, I"ll have to look into why it's not giving a better error message.

Basically, I think you're misunderstanding how the AGS events system works. Your Move_Object function is calling on_mouse_click, expecting to wait for the next mouse click.

However, on_mouse_click is just a normal function, and it gets run by AGS automatically when the user clicks the mouse. Calling it in the manner you have done will not wait for a mouse click, it will just run the script code.

You need to approach the situation differently, using an event-based approach rather than procedural.

Each time the user clicks the mouse, the on_mouse_click function will get run. So, you need to add some code to that to do your processing.

For example, your Move_Object function could set a global variable to indicate that a move has been initiated.

Then, the on_mouse_click function could check if that variable was set, and if so then it could store the object number, and so forth. Something like:

function Move_Object(){
SetGlobalInt(1,1);   // set globalint 1 to 1
}


then inside on_mouse_click:

if (GetGlobalInt(1) == 1) {
 int Objint = GetObjectAt(mouse.x,mouse.y);
 SetGlobalInt(2, Objint);  // store the object number
 SetGlobalInt(1, 2);
}
else if (GetGlobalInt(1) == 2) {
 MoveObjectDirect(GetGlobalInt(2),mouse.x,mouse.y,3);
}
Title: Re:Big Fatal exception Error during runtime
Post by: Gold Dragon on Thu 23/10/2003 06:15:09
Thank you I'll try that