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 - J.E.S.

#1
Have you tried gYourGuiName.setposition(xx, xx)?
#2
Thanks Creator, that did work. I'll mark this one as solved.
#3
Why does this code work...

Code: ags

function hBedroomDoor_Interact()
{
if(Character.GetAtScreenXY(90, 210)==cSlade)
{
  player.ChangeRoom(2, 200, 265);
}
else if (player.View==2)
{
  player.ChangeView(1);
  player.Walk(90, 210);
}
else
{
  player.Walk(90, 210);
}

}



But this code doesn't...

Code: ags


function hSladesCouch_Interact()
{
  if(Character.GetAtScreenXY(210, 260)==cSlade)
  {
    player.ChangeView(2); //to sit on couch
    SetWalkBehindBase(1, 200);
  }
  else
  {
    player.Walk(210, 260);
  }

}



I want the script to check the position of my character before he can sit on the couch. If he is close enough he will be able to sit on the couch when it is clicked again. This code works fine when I want to change rooms and I also like the freedom of walking without eblock.
#4
Yea good point Khris, I went back to check how my sprites were cropped and noticed that the auto crop feature in AGS didn't do a good job, so I had to crop each one seperately...I'll mark this one as solved.
#5
Thanks again Khris, I'm serious thinking about just switching back to a static cursor. Either way I try to code this function I still get little undesirable effects. Accuracy is the main problem, sometimes my character will stop before he even gets to the mouse location. I notice my hotspots don't work as well as they used to either when you mouse over them. I'm sure this has something to do with the cursor hotspot itself, and I don't think you can change that with script, or am I wrong?
#6
Thanks Gilbot, I tried your code also. I'm not quite satisfied with how the cursor jumps all over the place as it dynamically updates while the character is moving, then the cursor would be facing some obscure direction when the character stops. I have also considered tweaking this code to check the mouse coords in relation to screen coords instead. I'm not sure how I could do that though.

How can I change...

Code: ags

float dx = IntToFloat(mouse.x - player.x);
float dy = IntToFloat(player.y - mouse.y);


...to reflect the location of the mouse compared to the center of the screen?
#7
After testing the cursor function for awhile, I got a "Floating point divide by zero" error. I tried to duplicate the error and from what I can see, it happens when I don't move the cursor after I click to make my character walk. In other words, I get the error when I let my character walk to the same point my cursor is sitting at. Can this be fixed?
#8
Wow, thanks Khris! It took me awhile to understand exactly what the code was doing, but I was able to make it work thanks to you. Here is what my working code looks like, but it is only for 8 directions since I haven't created the cursor graphics for the 22.5 degree angles yet.

Code: ags

function repeatedly_execute()
{
//--------------------------------------Cursors------------------------------------------------
float dx = IntToFloat(mouse.x - player.x);
float dy = IntToFloat(player.y - mouse.y);
float len = Maths.Sqrt(dx*dx+dy*dy);
float angle = Maths.RadiansToDegrees(Maths.ArcCos(dy/len));
if (dx<0.0) angle = 360.0-angle;
int curs = FloatToInt((angle+11.25)/22.5);
  
if (curs == 2) mouse.ChangeModeGraphic(eModeWalkto, 132);
else if (curs == 4) mouse.ChangeModeGraphic(eModeWalkto, 130);
else if (curs == 6) mouse.ChangeModeGraphic(eModeWalkto, 136);
else if (curs == 8) mouse.ChangeModeGraphic(eModeWalkto, 135);
else if (curs == 10) mouse.ChangeModeGraphic(eModeWalkto, 137);
else if (curs == 12) mouse.ChangeModeGraphic(eModeWalkto, 129);
else if (curs == 14) mouse.ChangeModeGraphic(eModeWalkto, 133);
else if (curs == 16) mouse.ChangeModeGraphic(eModeWalkto, 131);
}
#9
I want to have the cursor graphic change depending on where it is in relation to the player. For example, it the cursor is on the right side of the player, the cursor will point to the right or whatever direction. I can easily code the basic 4 directions (up,down,left,right) but it gets a bit more complicated trying to code all the directions in between. Another to point out is, it appears that the character can move in a possible 16 different directions, so sometimes it doesn't walk exactly on a 45 degree angle, but on a 22.5. Any help would be appreciated.
#10
After a little more research I found something called,"SetWalkBehindBase". Which all I needed to do was create 2 separate walk-behind areas on my sofa. The piece that stuck out was coded to be drawn behind my character when he sat on the sofa.
#11
Is there a way I can import a new walk-behind mask depending on my characters actions or location? I have 2 images as an example of what I want to do. The image with the green cursor next to the sofa is the effect I want and the image with the red cursor is what I'm struggling with. Changing the baseline does not work because of my room being in isometric view and that particular object.

http://s96.photobucket.com/albums/l183/virgoman25/?action=view&current=Image6.png (What I want)
http://s96.photobucket.com/albums/l183/virgoman25/?action=view&current=Image5.png (What I don't want)


#12
I'll mark this topic as solved. Here is a different version that works also, and uses less code...

Code: ags

// main global script file
bool playedResume = false;
bool playedSave = false;

...

function repeatedly_execute()

{
//------------------------------------Resume Game----------------------------------------------  
if(playedResume==false)
{
if(ResumeGame.Graphic==159)
  PlaySound(1);
  playedResume=true;
}

if(playedResume==true)
{
if(ResumeGame.Graphic==158)
playedResume=false;
}

//-------------------------------------Save Game-------------------------------------------------

 if(playedSave==false)
{
if(Save.Graphic==148)
  PlaySound(1);
  playedSave=true;
}

if(playedSave==true)
{
if(Save.Graphic==147)
playedSave=false;
} 


}    





I want to thank everyone who replied to this topic and pointed me in the right direction.
#13
@Joe Carl...I was able to get your code to work and I thank you for helping me. What I'm trying to do now is apply this functionality to the rest of the buttons on my gui(save, load, quit....etc). Is there a way I can do this with minimal code or will I have to cut and paste this same code for each button?
#14
No I didn't, the name of the button is "ResumeGame" so that's what I put.
#15
@matti...I went back and fixed the capitalization, but I still got the same error.
#16
Thanks for the quick response! I feel stupid for asking this, but is there something else I need to do to my code? because I get this error when I run it:

Parse error: unexpected 'Guibutton'

here is my code:
Code: ags
// main global script file
Guibutton*gbtton;
bool played=false;



#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() // called when the game starts, before the first room is loaded
  {
    
  }
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute()
{
 gbtton=GuiButton.GetAtScreen(mouse.x,mouse.y);
if (gEscMenu.Visible==false) {
played=false;
}
if (gEscMenu.Visible==true) {
if (gbtton==null) {
played=false;
}
if (gbtton!=null) {
if (played==false) {
played=true;
PlaySound(1);
}
}
}


I thought you were trying to say that Guibutton was a placeholder for the real gui button name but that didn't work either.
#17
Hello, I can't seem to figure out how to play a sound once and not loop when you mouseover a gui button. I tried experimenting with the code from this post :http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28715.0 but I still can't get it right. What I'm trying to make is a gui that appears when you press escape to show the main game menu screen and when you mouse over a button, you'll hear a click sound. Thanks in advance.
#18
Thanks everyone for helping me solve this problem!

@Lt. Smash...I've used your updated code and it works, I just have to go back a tweak it for all 12 hotspots.

I will also give the rest of the examples a try because I need to get familiar with scripting in AGS. I would never be offended as long as I'm learning something. I posted my original code to get some opinions about good programming practices. I need to read more about pointers and such, since (at the time of this post) I've only been using AGS for a good 2 weeks.

Thanks again!
#19
@Lt. Smash...I tried your code, but I got an error that says,"A blocking function was called within repeatedly_execute_always".
However, when I cut that section out of rep_ex_always and pasted into rep_ex in the global script, the code did work. Also, even though the code worked like it should have, it made my cursor disappear and I couldn't move my character until after the fade effect was completed. Unfortunately, this is not the desired effect I wanted. I appreciated your help regardless.
#20
@KhrisMUC ...I'm trying to work with your code, but I know I'm missing something really simple or don't know how to complete the rest of it. Here is what I have so far:

In the global script:

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) 
    {
    ProcessClick(mouse.x,mouse.y, mouse.Mode);
  }
  else if (button == eMouseRight)
  {
    Hotspot*h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
    if ((h != null) && (gPlayerDialog.Visible!=1)) 
    {
    gPlayerDialog.BackgroundGraphic = h.ID + 240; // use e.g. slots 241 - X
    SetTimer(1, 120);
    gPlayerDialog.SetPosition(player.x-20, player.y-70);
    gPlayerDialog.Visible = 1;
    }
  }
  
  else // right-click, so cycle cursor
    {   
    mouse.SelectNextMode();
  }
  }


I ran this just to see if any errors would pop up, but i got no errors and nothing happens when I right-click on any hotspots.
What exactly was I supposed to do with the line that says, "bubble"? and is there something that needs to be added to my room script? I have a feeling I'm almost there, but need just a little extra hint. I will also be using the same function in all my rooms. Thanks for your time!
SMF spam blocked by CleanTalk