Help with Changeroom script acting inconsistently/change position of hover text

Started by Woffle, Tue 02/06/2015 07:39:03

Previous topic - Next topic

Woffle

Hello

I've made a short, MacVenture style game in AGS and though I mostly have it working correctly, I have three stubborn problems that I'm hoping for help with.

1)
Given that it's a MacVenture style (first person), I created a character but don't have any graphics assigned to them. To transition between rooms, the player (the character's name is Horace) interacts with a hotspot with the following script.

Code: ags

Horace.ChangeRoom(20);


This works perfectly about 85% of the time. Other times, the player is transported to the incorrect room. I've checked and double checked that the room being referred to in the script is the correct one. The behavior is inconsistent.

2) Some of the Hotspots have deadzones. The player will not transport to the room in question unless a certain area on the Hotspot is clicked or the hotspot is clicked multiple times.

3) I'm using the LW_BASS_V2.0 template as I really only wanted the mouse to examine and interact. Is there a way to change where the hover text appears? The script seems to indicate that will appear near the item but since I don't have items (only hotspots to deliver text or move the player), the hover text always appears in the same location.

I appreciate your patience! I'm incredibly new to coding and the experience has been very rewarding.

-Gary-

Vincent

Hello

1)
I am not sure why you are getting the error when the player try to change the room..
But if you can show your code this could be helpful somehow..


2)
For a testing purpose you could try to set in the room editor pane the (WalkToX, WalkToY) to a specific Hotspot and see if that work
Code: ags

// Example: 
player.Walk(hTable.WalkToX, hTable.WalkToY, eBlock, eWalkableAreas);
// will move the character to hotspot hTable's walk-to point

I am not that kind sure if that could help about the issue but you can have a try


3)
I don't know at all how the 'LW_BASS_V2.0' Template work at all, but I would do something like this
a) Create a Gui and a Label
b) Rename the script name of the Gui in gHotspotname
c) Rename the script name of the label in lblHotspotname
d) Rename the text of the label in @OVERHOTSPOT@
e) In the room editor pane, for a specific Hotspot, rename the (name/description) with some text 
Code: ags

// eg from a great master 
// set every game cycle the position of the Gui just next the mouse

function room_RepExec()
{
  int x = mouse.x, y;
  int width = GetTextWidth(lblHotspotname.Text, lblHotspotname.Font);
  if (mouse.x - (width / 2) < 0) x = 0;
  else if (mouse.x + (width / 2) >= System.ViewportWidth) x = System.ViewportWidth - width;
  mouse.y + (Game.SpriteHeight[mouse.GetModeGraphic(mouse.Mode)] / 2) + 2;
  if (y > System.ViewportHeight) y = mouse.y - GetTextHeight(lblHotspotname.Text, lblHotspotname.Font, width) -
  (Game.SpriteHeight[mouse.GetModeGraphic(mouse.Mode)] / 2) - 2;
  gHotspotname.SetPosition(x, y);
} 



I hope it's been helpful.
But there will probably someone more experienced who can help you further

Khris

1)
What you describe is most definitely user error. There's no way AGS randomly sends the player to the wrong room 15% of the time.
Something else is happening here, and I suspect it's related to...

2)
Hotspots don't have deadzones. If you click on a part of the area where you drew the hotspot and nothing happens, something else is covering the hotspot. It could be a GUI with background color 0, it could be a walkbehind, or something else. Check your rooms, maybe you accidentally drew walkbehinds instead of hotspots.

3)
The script reads what's under the mouse (hence the use of mouse coordinates) and displays it in a label at the bottom of the screen which doesn't move.
If you want the label to appear near the mouse, you have to also position it there.
There are multiple threads on how to do this, since it's a very common question.


I'm not really sure how to help you with this other than suggesting to upload your source files so we can take a look.

Woffle

First, thank you guys very much for the help. I seem to still be having the problem though and if you're willing, I'd like to upload what I have.

In response to the bit about the hover text, I'm using the built in feature in the template I started with. I can't seem to find the part of the code that determines it. I can find the code that prevents hover text when an inventory item is selected but I don't actually have inventory in this game so that bit seems unrelated.

As far as the hotspot room transfer problem goes, I checked for invisible GUI elements, walkbehinds, and the like and I don't see any. I'm still having the same problem.

I've uploaded a zip of my source files. If you're willing to take a look, I'll gladly buy you an internet beer (if such things were possible).

https://dl.dropboxusercontent.com/u/58679530/EFW.zip

Khris

Found the issue: for some reason GlobalScript.asc got overwritten with the BASS template's TwoClickHandler.asc.
This caused every click to be handled twice in the exact same way, firing all the Display() commands twice, queuing up two room changes, and so on.

To fix your game, replace your GlobalScript.asc with this: http://pastebin.com/RD6WpQfh
Then delete all Hotspots that don't do anything, so you don't get the template's default responses ("I can't do anything with that", etc) when you click them.

Woffle

Thank you thank you thank you.

For some reason this killed the description pop up over whatever the mouse is hovering over but I'll comb the threads and see if I can rebuild just that part without the error.

I really, truly appreciate it.


SMF spam blocked by CleanTalk