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

#121
Hello!

Code: AGS

if(GUIControl.GetAtScreenXY(mouse.x, mouse.y) != null){ //Checks whether the mouse is on ANY button
    Mouse.Mode = eModePointer;
  }
else{
    Mouse.Mode = eModeInteract; //Or whatever
  }


Should work in repeatedly_exececute(). If you want it to go back to the specific mouse mode you were in, try:

Code: AGS

//Declare these at the top of the script 
int m;
bool Switch = false;

//Then in repeatedly execute:
if(GUIControl.GetAtScreenXY(mouse.x, mouse.y) != null){
    if(Switch == false){
      m = Mouse.Mode;
      Switch  = true;
    }
    Mouse.Mode = eModePointer;
  }
else{
    if(Switch == true){
      Mouse.Mode = m;
      Switch = false;
    }
  }


Maybe there's a more concise way of doing this, but for now this should work just fine.
#122
I dunno if you have already seen them, but I'd reccomend the densming AGS tutorial videos here:

http://www.youtube.com/watch?v=1Ml_DR76Cl4&list=PL21DB402CB4DAEAEF&feature=plcp

I found them to be very helpful in getting to know my way around (and no, he hasn't paid me to post this ;) )
#123
I dunno if this helps but for creating and randomising questions catagories I would use structs:

  http://www.adventuregamestudio.co.uk/manual/struct.htm

you could define a struct with all the variables of a question, say:

Code: ags

struct Question {
  String q; //The question
  String ans[4]; //The answeres, from ans[0] to ans[3]. You could make 4 seperate variables, I preffer arrays
  int RightAns; //Number of the correct answere;
  int catagory; //Say 1 = Nature, 2 = Poltics etc.
};

//in some other part of code
Question question[50] //or however many questions you want


This is just a concept struct but that's along the lines of how I would organise my questions with catagories. Randomising within these can be done in various ways, but I preffer simply to order the catagories by number, so Nature questions are from 0-9, Politics from 10-19 etc. Then just call:
Code: ags
 int MyVar = Random(9) + MyFactor //Where MyFactor is an integer which changes depending on which catagory is selected
                                                              //E.G. if politics was selected this would be 10. 


  MyVar would then determine which question is asked (question[MyVar].......)

I dunno if this helps with the catagorising thing, that would just be my method

Good luck with this project though, it sounds great! ;-D
#124
It's important to get out of the habit of calling a Wait() command inside a function which is going to loop, as eventually the frame drop is noticeable. Khris' code is the best and most concise, but here is a layman's version (i.e. the version I would probabely make  :P) which tries to again not call Wait():
Code: ags

int CurrentFrame; 
function room_AfterFadeIn(){  
   CurrentFrame = 0;
   SetBackgroundFrame(0);  
   SetTimer(1, 200);
}
function room_RepExec(){   
  if (IsTimerExpired(1)) {
    int MyValue = 5;
    CurrentFrame ++;    
    if (CurrentFrame == 4){ //As there frame numbers go up to 3, when it hits 4 we reset it to 0.
      CurrentFrame = 0; 
      MyValue = 400; //Between Frame 0 and 1 you want a 400 frame interval, not 5
    }
    SetBackgroundFrame(CurrentFrame);  
    SetTimer(1, MyValue);
  }
}


This could will not block any frames! :-D
  So umm.....yeah...this might be easier than the other code to understand (i had trouble!), but certainly less efficient!
#125
Hello

It is possible to highlight several inventory items at once but it will require some scripting. You can do it by having a "normal" graphic and a "highlighted" graphic for each item. The next step depends on if you stack the same type of inventory items:

If so: just change the graphic for that item
Code: ags
 iItem.Graphic = 1 //or whatever the number is for the highlighted graphic

Or if the user has clicked the item
Code: ags
 player.ActiveInventory.Graphic = 1 //Or whatever the number is for the highlighted graphic


If not: I'm not sure if it's possible to change the graphic of an item by index type...maybe one of the wiser members can help you out here. For most games though the above code should do fine.
#126
If it's just for a single room:
  When you create a room, the "Create New Room" window has a checkbox which asks you whether to reset the room once the player has left. Click that.

  The room number will then be 300 + (room number)
#128
Hey all!

This has probabely been answered before, but my searching probabely had all the wrong words :P Is it possible for the same inventory item to be added multiple times at different indexes?

I tried:
Code: ags
 
  int i = 1;
  int Place = 1;
  while(i < (Game.CharacterCount)){
    if(character[i].x <= RightX && character[i].x >= LeftX && character[i].y <= BottomY && character[i].y >= TopY){
      player.AddInventory(iSelection, Place);
      Place ++;
    }
    i ++;
  }

But I only get one index with the iSelection item

Thanks!
#129
Quote
  if (!gInventory.Visible) mouse.Mode = eModeInteract; }

I don't fully understand why it should flicker, as the inventory screen should be visible, but a useful catch is just to check whether the mouse mode is already at interact:

Code: ags
  if (!gInventory.Visible && mouse.Mode != eModeInteract) mouse.Mode = eModeInteract; } 


I don't know much about how you plan to continue the code, but you could combine three lines into one:

Code: ags
 if(mouse.x > 610 && !gInventory.Visible && mouse.Mode != eModeInteract) mouse.Mode = eModeInteract; 


Hope that helped!
#130
 Buttons can display a string, so just format that string using String.Format
Code: ags

  int Value = 0 //or whatever value, this'll change i presume...

  ButtonName.Text = String.Format("%d", Value)
 


If your unsure about String formatting, that's something handy to look up in the manual
#131
Hahaha!  I was just having a bit of fun  8), i'm in debugging stage, so it's all a bit of a drag on the programming thing... glad to have, um, lightened the mood :D
#132
Do you have this in EVERY room? if so, and if you don't like the unelegance of just using room_load(), you could:
Code: ags

 //Global Script
  int R = 1 //or starting room
  bool VisitedRoom[(Game.RoomCount + 1)] //it's probabely not actually Game.RoomCount, but I can't     
                                                                     //remember the real command :P remeber +1, as array counts 
                                                                     //starts with 0.
function assign(){
  int i = 1;
  while(i != (Game.RoomCount + 1)){
    VisitedRoom[i] = false;
    i ++;
  }
}
game_start(){
  assign(); //this is good practice  ;D
}
repeatedly_execute(){
  if(R != cEgo.Room){
     if(VisitedRoom[cEgo.Room] == false){
       myObject.SetView(1, 0);
       VisitedRoom[cEgo.room] = true;
      R = cEgo.Room;
     }
     if(flag==1){   //flag is a global variable
       myObject.Animate(0,5,eRepeat,eNoblock);
     }
     else{
       myObject.Animate(1,5,eRepeat,eNoblock);
     }
   }
}

 (UNTESTED) This will only assign the object view the first time the character enters the room, and AFTER THAT will ask it to animate. However, this solution is a bit clunky and uses up more resources...but in a small or middle sized game, this shouldn't matter too much...
 if you need to assign different views to the object in question depending on room, you can add another array at the top such as
Code: ags
int OViews[Game.RoomCount]; 
then in assign() specify which number for which object, and when setting the view
Code: ags
 myObject.SetView(OViews[cEgo.Room],0); 

 Probabely not helpful...but hey it's just an idea   ;)

EDIT oops, looks like monkey got there first...with a much better solution  ;D
#133
Yay!! it's all working now :D thanks! I guess game_start() only works on the ACTUAL game start, and not when I trying to trick it ;D
thanks again guys
#134
Teehee, thanks for the suggestion, the code is about half the lines now and much nicer! :D
Okay, I've tested definately and game_start is NOT executed when the game is restarted...even when I set the restart point there. Is there any command which will reset data easily other than restarting the game?
thanks :)
#135
oops. Yeah, that command is in there, it's just there's some other junk and I cut out sections (all which don't affect this dilemna, they're just writing other files).
But I did find that when I modified
Code: ags

if(startingChapter == 0) CH(startingChapter); //THIS!
  else{ 
    cEgo.ChangeRoom(9);
    cEgo.Transparency = 100;
    Menu_ClickingState = true;
  }

that when I started the game, it at first carried out CH(0) as usual (which I quickly programmed to make cEgo go to room1), but when I started a new game AGAIN, CH(0) was DEFINATELY not executed, but neither was cEgo sent to room 9. so it basically ignored game_start(), I think...??? Should I recall game_start from the event eEventRestoreGame?
thanks

EDIT: I should probabely also mention that the character seems to be sent back to the room he was in when the new game is started, as in this case he was sent back to room1, but not in the position CH(0) (or any other CH() ) commands him to
#136
Thanks for the advice :) it simplifies everything! However, I'm still stuck with the problem. I simplifies all my code to:
Code: ags

 File *k = File.Open("NewGame.dat",eFileWrite);
 if(btn == 1) startingChapter = 1;
  else if(btn == 2)startingChapter = 2;
  else if(btn == 3)startingChapter = 3;
  k.Close();
  RestartGame();


Code: ags

File *l = File.Open("NewGame.dat",eFileRead);
  startingChapter = l.ReadInt();
  l.Close();
  if(startingChapter != 0) CH(startingChapter);
  else{ //startingChapter is set to 0 when manually exited
    cEgo.ChangeRoom(9);
    cEgo.Transparency = 100;
    Menu_ClickingState = true;
  }

and the CH which you reccommended. However, cEgo always gets teleported to Room 9. Maybe I should manually change a constant in NewGame.dat? I wouldn't know what value to put though (all in code ;) )
thanks
#137
Code: ags

bool IntToBool(int Boolean){
  bool rValue;
  if(Boolean == 0) rValue = false;
  else rValue = true;
  return rValue;
}

I think this function works properly, as I use it when loading games...
#138
Hey all!
I've got into a little trouble with .dat files (again), and I wondered if you could help me out. I have a chapter selection system (similar to the ones in the Half Life games), and what I want to do is to RESTART the game everytime the player decides to start from a different chapter, so that I don't have to reset ALL variables, just reset some of them aftwerwards depending on the chapter selected. So I decided to write a few crucial variables into a .dat file like so:
Code: ags

//This happens when a chapter is selected to be loaded
BegunFromCh1 = true;
BegunFromCh2 = false;
BegunFromCh3 = false;
InMenu = false; //This is set to true when the game is manually exited
InGame = true; 
File *k = File.Open("NewGame.dat",eFileWrite);
k.WriteInt(InMenu);
k.WriteInt(InGame);
k.WriteInt(BegunFromCh1);
k.WriteInt(BegunFromCh2);
k.WriteInt(BegunFromCh3);
k.Close();
RestartGame();

Then, at game_start(), I have the following code:
Code: ags

File *l = File.Open("NewGame.dat",eFileRead);
  InMenu = IntToBool(l.ReadInt());
  InGame = IntToBool(l.ReadInt());
  BegunFromCh1 = IntToBool(l.ReadInt());
  BegunFromCh2 = IntToBool(l.ReadInt());
  BegunFromCh3 = IntToBool(l.ReadInt());
  l.Close();
  if(InGame == true){
    Display("Working");
    if(BegunFromCh1 == true) CH1();
    else if(BegunFromCh2 == true) CH2();
    else if(BegunFromCh3 == true) CH3();
  }
  else{ //InGame is set to false and InMenu set to true when the game is manually exited, so that the character returns 
          //To menu screen (Room9) when game is first started.
    cEgo.ChangeRoom(9);
    cEgo.Transparency = 100;
    Menu_ClickingState = true;
  }

and CH1() Looks like this:
Code: ags

function CH1(){
  Display("Working");
  mainstory = 5;
  cEgo.ChangeRoom(1, 650, 405);
  cEgo.Transparency = 0;
}

However, my problem is that InGame seems to never be true, as both times I have called 'Display("Working")', neither ever show up! And the character ALWAYS goes to Room 9. There is nothing in eEventRestoreGame that should intefer with any of this code, if that is at all relevant...
Thanks in advance :)
#139
 Thanks!
  It's working fine now. In the manual it always writes in big DELETE SPRITE ASAP!, which is why I always did it, now I finally get what it really means  ;D
  Thanks again!
#140
Hey all!
  I'm trying to change a button's graphic to the graphic of a Dynamic Sprite within a function. I have read other posts, and tried to copy what they do, but strangely for me the button just turns up with a blank image. Here's the code:
Code: ags

 // At the top of the Global Script 
  DynamicSprite *s;

 // Later on...
 function bSave_OnClick(GUIControl *control, MouseButton button)
{
  s = DynamicSprite.CreateFromExistingSprite(31); //this is to test, I actually load another DynamicSprite's image
                                                                                // into this one...
  s.Resize(90, 60); //Optional, doesn't work with or without...
  bButton.NormalGraphic = s.Graphic;
  s.Delete();
  SaveGameSlot(btn, date); //these two are established elsewhere
  btn = 0;
  AfterSave(); //just does some business after the save
}

  I've even tried to reload an image into 's' and change the button's normal graphic in AfterSave() instead of bSave_OnClick, but no luck...
  Anyone have a solution?
   Thanks
SMF spam blocked by CleanTalk