Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: daryl on Mon 09/04/2007 11:26:44

Title: Is there a The Dig template to be found anywhere?
Post by: daryl on Mon 09/04/2007 11:26:44
I have searched the site as well as the Read First and I found some nice templates like the CoMI, but I believe a template such as The Dig would be ideal for me, because it is more simple with only one cursor that does all etc, but I cant find it anywhere..  Anyone knows?

*edit* Also, is it possible to load a template without starting a new game? Like modifying the one you've worked on but want to try out different templates..

Thanks!
Title: Re: Is there a The Dig template to be found anywhere?
Post by: on Mon 09/04/2007 15:38:36
I don't think anyone here has ever made an "original" Dig template. The Beneath A Steel Sky template might be what you're looking for- it has left/right clicks for examine / interact actions. It doesn't have the inventory panel as in the Dig, though (with a small icon to bring up a window), but that could be scripted. The template can be found on the Resources section of AGS- just browse the template section there.

As far as I know it's not possible to open a template once it has been made into one- you'd need the original folder with all the files in order to open and change it. You can, however, create a new game from a template, make the changes you need, and safe it as a template again.

It's also not possible to "plug" different templates into the same game project- best to create a new game with a template, and try it out.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Scorpiorus on Mon 09/04/2007 16:28:30
Additionally, you may probably want to take a look at that thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=30809.0) for a script to interact in a similar way Ghost mentioned:

Right Click -- Interact / Select Active Inventory Item / Use Inventory Item
Left Click  -- Examine (Look At) / Deselect Active Inventory Item
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Mon 09/04/2007 17:49:24
thanks guys you're very kind in assisting me in my quest. I really am trying.. I tried the Beneath a Steel Sky but all I got was another cursor.  I try copying Scorpiorus code but it doesn't work or I get errors and mess up, and I don't know why since I lack coding skills. For instance, where would I put the ProcessClickSpecial() function? I reckoned I would just paste it in it's own column as there was no such thing there already, in the global script.

I think though that every bit of change I want to do to the default game, shaping it like I want it, I need scripting skills. I was hoping that I wouldn't. I'm an artist, and basically all I hope for is to use a template and pretty much just switch existing graphics with my own. Though as The Dig is my favourite inspiration I sure could use such a template, I find it a bit odd if there's no template out there? I'm just thinking maybe there's a way for me to create a game with as much creativity as I want and as little frustration as possible, meaning changing as little as I can of the functions.

Forgive my whining, I'm just a frustrated artist wants to get the show on the road..
Title: Re: Is there a The Dig template to be found anywhere?
Post by: on Mon 09/04/2007 18:11:27
Nah, that's not whining yet  ;)

I understand your worries. Many people here wish to concentrate on the artistic stuff, and would rather not script at all. But just as it says on the front of the box- AGS isn't for everyone, and scripting is so frequently used it can be considered a must.

Where exactly are your problems, though? How do you get "another cursor"? The BASS template is quite robust and simple; I`m working with it myself, so I might be able to help you out. You can, in fact, replace the cursor graphics, and then all you need to take care about is to have a "look at" response for any object/hotspot/character, and an "interact" action- this one depends on the kind of object you have. For a character you'd use the "talk to" tab, for example.

And why nobody has yet created a Dig template, well, the game's popular, yes, but most people here (including myself) seem to prefer classic SCUMM or Sierra...

Don't give up. Scripting isn't that hard, and once you're a bit comfortable with it, you'll never want to miss it.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Ashen on Mon 09/04/2007 18:44:49
Quote
I try copying Scorpiorus code but it doesn't work or I get errors and mess up, and I don't know why since I lack coding skills. For instance, where would I put the ProcessClickSpecial() function? I reckoned I would just paste it in it's own column as there was no such thing there already, in the global script.

As a general rule, if you need help with something, you need to give details. (E.g., what errors? Post the messages you get. If the code works, just not like you want, what's wrong - what is / isn't doing that you didn't expect? What do you mean by "paste it in it's own column"? ...) However, the thread about Scorpiorus' code (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=30809.0) would be the place for that, not here.

I was tempted to lock this thread - questions about finding templates don't belong here, Ghost answered the part of your original post that does (you can't apply templates to a game you've already started), and the other thread is a more appropriate place to get help with Scorpiorus' code. However, if you're likely to be using the existing BASS template, this can stand for help with that, since there's no existing thread for it that I can find. (And there's likely to be a lot of problems with that template, based on the age of it.)
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Mon 09/04/2007 20:06:16
Thanks Ghost, Ashen!. Sorry for being a bit foggy about my troubles, I will try to put some more patience into this and also any upcoming problems on the way. As always I'm too naive thinking how easy it seemed. After all, some scripting skills can't hurt my carrier either, and it would be nice to actually do what you want and understand why too.

Thanks again.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Tue 10/04/2007 12:53:44
I made a Dig template at one point: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26732.msg340864#msg340864

No idea if the download link still works though, but I can e-mail it to you if you want.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Wed 11/04/2007 20:37:43
SupSuper: hey that would be awesome. I checked the links and ironically The Dig template was the only one not functioning, I'd be really greatful if you sent it, check msg. Thanks!
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Rocco on Thu 12/04/2007 16:18:20
im also highly interested in GUI - templates (The Dig + Full Throotle)
please can you re-up these two.

Big thx.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Fri 13/04/2007 23:42:46
By popular demand:
- Full Throttle (http://www.rudolphuebe.com/suf/uploads/Full%20Throttle.zip)
- The Dig (http://www.rudolphuebe.com/suf/uploads/The%20Dig.zip)
Title: Problems with greyed out inventory items
Post by: daryl on Sun 15/04/2007 14:15:21
Hey,

I've played some with SupSupers Dig- template, and managed to have it adjusted for higher resolution and thus another GUI and inventory item positioning, yay! Though I got one problem on the way, and it is that my inventory items are almost invisible, but when clicking on the item it becomes as opaque as it normally should. Does anyone know what the reason for this could be? Changing z-order of the GUI didn't work.. Thanks!
Title: Re: Problems with greyed out inventory items
Post by: Ashen on Sun 15/04/2007 14:25:45
Since there's already a topic about the Dig template (which you started): Topics Merged.

The Inventory GUI is mostly transparent (see the game_start function in the Global Script). So, what you're reporting is the way it's meant up to be. If you don't like it, alter the GUI.Transparency value, or remove that line altogther (line 7), to get the effect you want. And try checking the script yourself, before posting, in future.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sun 15/04/2007 14:33:48
*edit*: solved. it was a solution of 2 inventories.

The inventory items in the template are opaque even though the inventory window is semi transparent, somehow I managed to funk that
up and have the items do the same. I do check the script, even if it doesn't look like that to someone who knows scripting and these problems as something obvious.

I think it could be because it had 2 inventories, one for the inventory graphics and one for the items.

EDIT2:
Ok so I have a few things left to modify to make this work like The Dig. I've searched for a solution and checked manuals etc but I can't find the right feature or solution..

The right click to bring up inventory works, but if I right click again to remove it nothing happens. It looks like this:


sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    if (!IsInteractionAvailable(mouse.x,mouse.y,mouse.Mode)) {
      ProcessClick(mouse.x, mouse.y, eModeWalkto );
    } else {
ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
  }
  else {   // right-click, so show inventory
if (player.ActiveInventory == null) {
show_inventory_window();
} else if (gInventory.Visible) {
  hide_inventory_window();
} else {
  player.ActiveInventory = null;
  mouse.Mode = eModeInteract;
}
  }
}


it feels like the part below should do the work but it doesn't.


else if (gInventory.Visible) {
  hide_inventory_window();


Anyone got an idea?
Thanks.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Ashen on Sun 15/04/2007 17:11:34
Nope, that bit doesn't run, and pretty much shouldn't - the template is in error here, not you. (Although you should've been able to find an answer on the forums, given the number of times it's come up.)

One of the Inventory GUIs is Popup Modal. That means that when it's onscreen, the game is paused. This bit of on_mouse_click:

  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }


Obviously means mouse clicks aren't processed when the game is paused (there's the same thing in on_key_press). You need to re-arrange the code, so that the button == eMouseRight and gInventory.Visible == true checks are performed either before or in the IsGamePaused condition.

On another note, mouse clicks aren't processed over GUIs, so that'll only work if you right click when not over the Inventory GUI. Since it's also code to turn the GUIs off when you move off them (well, when the mouse is within 10 pixels of the edge of the screen), it seems a little redundant anyway. There is a way to register right clicks over GUIs, but I don't remember it off hand.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sun 15/04/2007 19:58:05
Thanks Ashen. I guess I could pass on that one since it's okayish to see inventory gone when moving the mouse outside of it.

So I have 2 issues left before I can get started working on the actual game and I hope that will create a breather for everyone so I won't be a bother for a while.

1: when I use an item in my inventory, the cursor turns into that item as it should, but the item sprite stays in the inventory when it should disappear (until I choose to not use it anymore and it shows again in inventory.) Is there a way to solve that?

2. Is there a way to add a function like, double click on far left or right side of the screen and you will jump to the next room without seeing the character walk? I saw that you could paint a hotspot on each side of a screen and have an action bound to when clicking on the hotspot, but I have no idea how to make that into double-clicking.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Sun 15/04/2007 21:50:37
I apologize about the issues, though I had pointed them out in my other thread.

As you noticed, I tried enabling the inventory to go away on right-click but since I couldn't get it to work I just left the code there since all the other methods work. I also think there's an issue where the description label on the bottom cancels out any mouseclicks there, so you have to set its Clickable property to false.

As for 1:, I also noticed this but I'm not sure if AGS supports it. You'd need to "remove" an item from the inventory whenever it's selected and "add" it back in when it's dropped, but AGS doesn't let characters carry items they don't have.

2: You have to use on_mouse_click to catch double-clicks and then combine that with the hotspot interactions. See here: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=12190.0
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Sparky on Sun 15/04/2007 22:39:03
Quote from: Ashen on Sun 15/04/2007 17:11:34
There is a way to register right clicks over GUIs, but I don't remember it off hand.
I might be wrong, but I think you need to check "handle inventory clicks in script". Then in the on_mouse_click section, add a section for right clicks over the inventory

// left click, right click, etc....
if (mode == eMouseRightInv) {
    // script here
}


Title: Re: Is there a The Dig template to be found anywhere?
Post by: Ashen on Sun 15/04/2007 22:59:54
Re Sparky:
That might be part of it, but there's more to it. That'll only cover right-clicks actually on Inventory Items - there's still the rest of the GUI to deal with. (Also, the code I'm thinking of isn't specific to Inventory GUIs.) Possibly using repeatedly_execute_always and mouse.IsButtonDown(eMouseRight) would achieve it.

SupSuper linked a pretty useful thread for the double click thing. You might also be interested in SkipUntilCharacterStops (http://www.adventuregamestudio.co.uk/manual/SkipUntilCharacterStops.htm)  - I'm not sure how well it'd work in this case, but might be worth a look.

For 1, it's doable with a little coding, but obviously isn't built in to the Dig template. There's a Grid-based Inventory module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28177) that might do what you want, if it works with the template code. I think there was another version somewhere as well, but I can't find that one.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Tue 17/04/2007 20:24:55
thanks a ton for your replies guys, I'm very greatful.

I'll try to focus on one thing at a time, and I've looked into how to make the player move into the next room using double click as a shortcut, I have this so far:

*edit* new progress..


int double_click;

if (button==eMouseLeft) {
//SetMouseCursor(GetCursorMode()); // stops wait cursor appearing
double_click = WaitMouseKey(8);
mouse.IsButtonDown(eMouseLeft);
//SetDefaultCursor(2);

if (double_click) {


So I got past the error msgs.. Now I need to bind a function to the double click. Perhaps by adding a custom property to the hotspot I want to double click in? I'm not sure how to add code such as "if double_click over hotspot X, trigger player.ChangeRoom();"

Oh and the code might have things needed repair too, I can't tell but I try.

Any idea?
Thanks..
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Wed 18/04/2007 15:40:24
To add code such as "if double_click over hotspot X, trigger player.ChangeRoom();", you just create an interaction on hotspot X when it's clicked, and have something like:

import double_click; // Your global script will need a "export double_click;" on the end, too

function hotspot1_a()
{
  if (double_click)
    player.ChangeRoom();
}
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Wed 18/04/2007 19:22:50
Thanks a bunch man, that worked actually great, after some more research. I had to put the int double_click; up in the global script before any sectionstarts to be able to export it. I added the export double_click; like you said, and used your code in the room script but I had to add int before double_click to be able to import it. Also, even though I renamed the script-O-Name to hPortalLeft it still had to be hotspot3_a() for AGS to recognize it, a bit odd?

Anyways, the function does the job perfectly now, but another issue appeared with the WaitMouseKey code, the cursor dissappear when clicking the mouse button for about a second or so, whether I release the button or not. The "i" sprite for inventory in the left bottom corner (as in The Dig) behaves just like the cursor and dissapears in sync with it.

Code is as follows:


//double_click function

if (button==eMouseLeft) {
//Mouse.UseModeGraphic(eModeInteract);
double_click = WaitMouseKey(8);
mouse.IsButtonDown(eMouseLeft);
//Mouse.UseDefaultGraphic();


Anyone knows why? Thanks!
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Ashen on Wed 18/04/2007 22:55:32
For the cursor - it looks like you've commented out the line that should stop that from happening. Remove the '//' from the mouse.UseGraphic line and the UseDefaultGraphic one.
For the GUI, what's your 'When interface disabled' setting ('General Settings' window)? The template default is 'GUIs turn off' - meaning it's perfectly normal for that GUI to vanish during a Wait command. If you don't want that to happen, change the setting.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Khris on Thu 19/04/2007 00:35:21
What exactly does the
mouse.IsButtonDown(eMouseLeft);
line in your code do?
mouse.IsButtonDown() will return whether the button is pressed or not, so calling it alone (and not inside if(..)) is pointless.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Thu 19/04/2007 20:49:52
*edit*
I checked my "wait" cursor and it was transparent, so what I did was changing that to the interact sprite and everything worked as it should. Weird though because I thought the Mouse.UseModeGraphic(eModeInteract); would override the 'wait' cursor. Anyways, I'm pleased with the results!

---------------------------------------------------------------------------------------------------------------------------------------
Ashen: I commented those lines out because there were no change in behaviour. I must be missing something.. The other GUI part you mentioned worked like a charm, thanks a lot.

KrisMUC: Good question.. I think I let that part loose from another line but I put it back so here's the current somewhat less messy code-


if (button==eMouseLeft) {
Mouse.UseDefaultGraphic();

double_click = WaitMouseKey(8)*mouse.IsButtonDown(eMouseLeft);
Mouse.UseModeGraphic(eModeInteract);


}
}

The Mouse.UseDefaultGraphic(); and the Mouse.UseModeGraphic(eModeInteract); doesn't do anything I'm afraid :(

I'm lost.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Fri 20/04/2007 22:20:27
*edit*
So I've found a way of changing item sprite when clicking on the item in the inventory. I just need to have that function triggered when it is over another item/ object/ hotspot/ character etc.

I have in repeatedly execute:

if (player.ActiveInventory != null) {
  mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}


And in my test item (the key) I made a custom property (named Outline), with Number property, so that I can set what sprite number it should change into (another sprite, same look but with an outline). How do I define that I want it to change whenever I have the item over other objects? I suppose I need to use the code under repeatedly execute somewhere else and with more defined conditions..

Thanks!

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

//obsolete
(Ok, so the only thing left for now is to script how to have the items outlined with a color whenever the item used is on another item (in or outside GUI) or on hotspot/ character etc. I've looked for quite some time on both manual and forum but no luck. I guess it's just a sprite switch, but didn't find one that fit when using the interaction editor on any of the items. Anyone knows what to do? Thanks a bunch!)
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Khris on Sat 21/04/2007 14:58:37
Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);
if (o!=null) ...

Same for hotspots and chars.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sat 21/04/2007 18:46:53
Sorry I can't solve this by my own. Was that the complete code? Where does it go?
I tried putting it into rep ex, but it made no difference.
Thanks..
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Sat 21/04/2007 21:36:44
Khris' code checks if the cursor is over an object. You just put it in rep_ex and then add whatever you want to do when the cursor is over an object. And you can modify it for hotspots, characters, etc, by replacing "Object".
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sat 21/04/2007 22:32:05
thanks for your help and time guys..

this is what I've done- I put KrisMUC's code into rep ex along with my definition of what should happen-



Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);

if (o!=null) {
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}


I gave my items this Outline property, which is a Number property. I try it on the key item. The way it works now is that when I use the key on an object in the scene, the cursor changes into another sprite irrerversably (which I define as sprite number in the Custom Property/ Outline), but that's not what I want. I need it to change when on mouse over the objects, and switch back to the original sprite whenever I'm not over another object.. I guess I'm doing something wrong..

Any help is greatly appreaciated.. thanks.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Sat 21/04/2007 23:43:12
Iirc, to restore the cursor you need SaveCursorUntilItLeaves:

Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);

if (o!=null) {
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}


If that doesn't work, use this:

Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);
if (o!=null) {
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
} else {
mouse.ChangeModeGraphic(eModeUseinv, old_slot); // Replace "old_slot" with the original sprite number for the cursor (when not over an object)
}
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sun 22/04/2007 09:27:33
*edit*

- I got rid of one "null pointer referenced" error, made a condition so that it didn't try to change cursor if the mouse mode was anything else but eModeUseInv

- it works great for objects and characters

issues remaining:

1. When I apply the functions for the inventory items, the items change as soon as I've clicked them, it doesn't seem to look for another item, and it keeps the sprite even when hovering over empty GUI slots. When I move the item cursor outside the GUI it acts as it should. As if the GUI was treated as an object or item itself?

2. I still get a  "null pointer referenced" error when I try to apply this code to hotspots as well. Any idea why?

Here is the current code:


//Cursors -> outlined sprites when over interaction objects
if (mouse.Mode == eModeUseinv) { //So that the function don't apply to interact or walk cursors etc.

InventoryItem*i=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);

if (i!=null) {
 
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property

}

//Change cursors only when outside the GUI

if ( GUI.GetAtScreenXY( mouse.x, mouse.y ) == null ) {

Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);

if (o!=null) {
 
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property

}

Character*c=Character.GetAtScreenXY(mouse.x, mouse.y);

if (c!=null) {
 
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property

}
}
}
}


Thanks a lot!




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

SupSuper that worked great! I don't think I could use the 2nd code because then all cursors would get the same default "old_slot", but the first one was just the way I wanted. Thanks a ton!

I had to uncheck the "pixel perfect click detection" or else the cursor didn't change until in the center of the sprite or something like that..

However, I get a "null pointer referenced" error when I use the same code for either hotspots or inventory items, or when using the interact cursor above an object

Here is what it looks


Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y);

if (h!=null) {
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}

InventoryItem*i=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);

if (i!=null) {
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}

Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);

if (o!=null) {
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}

Character*c=Character.GetAtScreenXY(mouse.x, mouse.y);

if (c!=null) {
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Khris on Sun 22/04/2007 12:52:14
Use this:
Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem*i=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);
Character*c=Character.GetAtScreenXY(mouse.x, mouse.y);

if ((h!=null || i!=null || o!=null || c!=null) && player.ActiveInventory!=null) {
  mouse.SaveCursorUntilItLeaves();
  mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline")); // Or whatever you named the property
}

And tell us the line the error occurs in...

EDIT: My guess is that calling GetProperty while ActiveInventory==null throws the error, updated code to reflect that.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sun 22/04/2007 14:51:24
thanks for your suggestions KhrisMUC!

If I exchange my code to the one you suggested I get the following behaviour:

-When clicking on an inventory item it turns directly into the outlined sprite (same as before), but it also doesn't switch back even if I move it outside the GUI.

-If I remove the hotspot function out of the code, I get the same behaviour as I had before- but with cleaner code (which is good). If I remove the InventoryItem function and keep the Hotspot function, the items in the inventory still switch when clicking on them inside the GUI- and there's no Hotspot close by.

-I don't get any null pointer ref error any longer though and for that I'm very greatful.

Still there is something weird going on with the inventoryitems and hotspots :/
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Tue 24/04/2007 21:11:22
Anyone have any idea how I could solve the problem in my previous reply? All help is welcomed.

Thanks!
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Khris on Wed 25/04/2007 00:08:45
InvItems:
From the manual regarding SaveCursorUntilItLeaves()
QuoteSaves the current mouse cursor, and restores it when the mouse leaves the current hotspot, object or character.
So this unfortunately won't work with InvItems.

Hotspots:
From the manual regarding Hotspot.GetAtScreenXY()
QuoteIf there is no hotspot there, or if invalid co-ordinates are specified, the Hotspot* representing hotspot 0 will be returned.
That's something I always forget; the reason for this: hotspots are drawn by the user and handled as bitmap by AGS.
Solution: if (h.ID>0)

Try:
  Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  InventoryItem*i=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);
  Character*c=Character.GetAtScreenXY(mouse.x, mouse.y);

  if (player.ActiveInventory!=null) {
    if (h.ID>0 || o!=null || c!=null || i!=null)     // hotspot code updated
      mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline"));
    else
      mouse.UseDefaultGraphic();
  }
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Thu 26/04/2007 20:13:39
the hotspot mouseover code worked perfect, thanks a lot Khris, much appreciated.

I'll see what else can be done with the inventory items.
thanks again.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Khris on Thu 26/04/2007 20:36:14
The new code should deal with both issues, does it still fail with InvItems?
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sat 28/04/2007 09:18:15
The problem seemed to be the mouse.UseDefaultGraphic(); which didn't work, so the cursor never went back to the original inventory sprite when if once had changed. I did try another thing instead, I created a new custom property for the cursor, named it "NoOutline" which defined the cursor sprite in the original state, and called it back again, and this worked great!


Hotspot*h=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  InventoryItem*i=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  Object*o=Object.GetAtScreenXY(mouse.x, mouse.y);
  Character*c=Character.GetAtScreenXY(mouse.x, mouse.y);

  if (player.ActiveInventory!=null) {
    if (h.ID>0 || i!=null || o!=null || c!=null) {     
      mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("Outline"));
} else {
mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("NoOutline"));
//Mouse.UseDefaultGraphic();

}



thanks!
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sat 28/04/2007 17:44:56
So, getting pretty close to where I want thanks to you guys. Thanks for your patience with me!

One of the things left is, that when I have an Inventory cursor active, and click on the screen so that an action triggers (walk, use etc) it switches temporarily back to the Interact cursor for a second, then back to the Inventory cursor again. Is there any way the Inventory cursor can become/ replace the action cursor whenever the inventory one is active?

I thought of something (probably far-fetched) like this (in on_mouse_click)


if ((mouse.Mode==eModeUseinv) && (button==eMouseLeft)) {
  mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.GetProperty("NoOutline"));   


And it doesn' t do anything. I tried to find a thread like this but hard to know what to search for.

Many thanks /D
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Tue 01/05/2007 14:06:32
Anyone?

I've had no success with this, but supposedly a common problem?
Thanks
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Ashen on Tue 01/05/2007 16:26:05
What makes you say it's a common problem? I don't think I've heard of it before.

What do you mean by "the Interact cursor" - eModeInteract, whatever interaction was used ('Player looks at Hotspot' changes to eModeLookat, etc), the default Inventory cursor...? Apart from the Wait cursor appearing during blocking actions, I can't think of a reason AGS would change the cursor itself. What does your on_mouse_click look like? (Also - Sorry, I've lost track of what template you're using, or if you're using one at all. Are you, and if so which one?)
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Tue 01/05/2007 18:22:20
*EDIT*
It seems to be due to double_click = WaitMouseKey(8 )*mouse.IsButtonDown(eMouseLeft);
But I need that one to be able to jump to the next room quickly by double clicking on a Hotspot.. :/


thanks Ashen for your reply-

I started with SupSuper's The Dig template which had much of the originals way of functions and behaviour, and I modified it to be even closer to The Dig.

Sorry if being a bit unclear, let me try to explain.

The template works in a way that one cursor (looking like crosshairs) does all kinds of actions- Interact, WalkTo, LookAt etc.
So when I for example walk, I don't need to bother what action to use, just to click anywhere on the screen, same with the other actions.

But if the cursor is an inventory item, and I click on the screen (to walk, or use the inventory item with something etc), the cursor changes temporarily to the action cursor (the crosshairs) and then back to the inventory item. I'm looking for a solution when this doesn't happen. Perhaps if the (eModeUseInv) cursor could function as the action cursor whenever it's active, or if the action cursor could adapt to the graphics of the inventory item, hiding the switch between cursor sprites.

This is what my on_mouse_click looks like-


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) {  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    if (!IsInteractionAvailable(mouse.x,mouse.y,mouse.Mode)) {
      ProcessClick(mouse.x, mouse.y, eModeWalkto );
    } else {
ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
  }
  else {   // right-click, so show inventory
if (player.ActiveInventory == null) {
show_inventory_window();
} else if (gInventory.Visible) {
  hide_inventory_window();
} else {
  player.ActiveInventory = null;
  mouse.Mode = eModeInteract;
}

}

//if (button==eMouseLeft) {
//Mouse.UseDefaultGraphic();

double_click = WaitMouseKey(8)*mouse.IsButtonDown(eMouseLeft);

}


Thanks.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sat 05/05/2007 13:43:54
Ok, I can't solve the double_clicking one, a bit surprised if no one else using a double_click feature don't have the same problem.

So basically I just put a "any click on" on the exit/ warp hotspots, for the time being.

Moving on!
I put an object in the scene, set the interactions of it so that "any click/ interact/ use inventory on" would make the character walk to a specified position, then pick it up or whatever.

Question1:
If I click on the object and the character starts moving towards it, how can I interrupt his walk if I decide to walk elsewhere and not to the object?

Question2:
This one might be solved if Q1 is solved but anyways, can I disable the Wait cursor that appears while the character walks towards the object?

Thanks!
Title: Re: Is there a The Dig template to be found anywhere?
Post by: SupSuper on Sun 06/05/2007 04:18:40
The only way to do that is to have a "non-blocking" Walk command, but then the character would pick up the item instantly after starting to walk.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: daryl on Sun 06/05/2007 08:16:46
*EDIT*

I added cEgo.Frame==0 so that he didn't pick up the object when walking across it, but only under the condition that he had stopped walking, which is on frame 0.

---------------------------------------------------------------------------------------------------------------------------------
Yeah. I solved this late yesterday night, here is my solution if anyone else hits the same problem:

First off, in the Interaction Editor for the object (Looking Glass) I put a "Character- Move Character" attribute into "Interact Object"
I specify destination XY location, 662 and 242, and had the "Wait for move to finish" to False, (ie no-blocking) so that I can be able to change action any time after this is triggered.

Then in the room script under Repeatedly execute I did this:


// script for Room: Repeatedly execute



// script for Object 0 (Looking glass): Interact object

if ((cEgo.x==662)&&(cEgo.y==242)&&(cEgo.Frame==0)&&(mouse.Mode == eModeInteract))  {
object[0].Visible=false;
player.AddInventory(inventory[1]);

}
}


This made the character walk to the object, then pick it up, and I could still change my mind while he was walking.

This also solved my 2nd issue with the wait cursor, as it doesn't appear now as the "Wait for move to finish" is False.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Mariano Cirigliano on Wed 27/10/2010 16:23:15
Quote from: SupSuper on Fri 13/04/2007 23:42:46
By popular demand:
- Full Throttle (http://www.rudolphuebe.com/suf/uploads/Full%20Throttle.zip)
- The Dig (http://www.rudolphuebe.com/suf/uploads/The%20Dig.zip)

The web to unload the TEMPLATES they do not work any more.

That someone returns to raise please, especially that of THE DIG.

Thank you!.
Title: Re: Is there a The Dig template to be found anywhere?
Post by: Matti on Wed 27/10/2010 16:40:46
Here's a module for the BASS control, it's pretty similar to the Dig afaik:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38762.0