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

#1
*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:

Code: ags

// 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.
#2
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!
#3
*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-

Code: ags

#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.
#4
Anyone?

I've had no success with this, but supposedly a common problem?
Thanks
#5
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)

Code: ags

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
#6
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!

Code: ags

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!
#7
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.
#8
Anyone have any idea how I could solve the problem in my previous reply? All help is welcomed.

Thanks!
#9
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 :/
#10
*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:

Code: ags

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

Code: ags

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
}
#11
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-

Code: ags


	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.
#12
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..
#13
*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:
Code: ags

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!)
#14
*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-

Code: ags

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.
#15
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:

Code: ags

//double_click function

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


Anyone knows why? Thanks!
#16
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..

Code: ags

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..
#17
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.
#18
*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:

Code: ags

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.

Code: ags

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


Anyone got an idea?
Thanks.
#19
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!
#20
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!
SMF spam blocked by CleanTalk