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

#1
I've tried both examples you suggested and both give the same error "null pointer reference" on mouse click.
This happens as soon as I click anywhere on the screen.

Here's the on mouse click
Code: ags

function on_mouse_click(int button) {////////////////////////////////////On Mouse Click///////////////On Mouse Click
Ã,  // called when a mouse button is clicked. button is either LEFT or RIGHT
Ã,  
// Store type, name and id# of what the player clicked 
// on in global variables GSloctype,GSlocname & GSlocid:
//-----------------------------------------------------

 int mrx=mouse.x+GetViewportX(), mry=mouse.y+GetViewportY();
 GSloctype=GetLocationType(mouse.x,mouse.y);
 InventoryItem *ii=InventoryItem.GetAtScreenXY(mouse.x,mouse.y);
 if (GSloctype==1) {
Ã,  Ã, Hotspot *hh=Hotspot.GetAtScreenXY(mouse.x,mouse.y);
Ã,  Ã, GSlocid=hh.ID;
 } else if (GSloctype==2) {
Ã,  Ã, Character *cc=Character.GetAtScreenXY(mouse.x,mouse.y);
	 GSlocid=cc.ID;
 } else if (GSloctype==3) {
Ã,  Ã, Object *oo=Object.GetAtScreenXY(mouse.x,mouse.y);
	 GSlocid=oo.ID;
 } else if (ii!=null) {
	 GSlocid=ii.ID;
 }
 GSlocname=Game.GetLocationName(mouse.x,mouse.y);

//-----------------------------------------------------

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

//	Handling clicks in map rooms:
//-----------------------------------------------------
Ã,  else if (gMaps.Visible){// if map
Ã,  Ã,  if (button==eMouseLeft){
Ã,  Ã,  Ã,  if (IsInteractionAvailable(mouse.x,mouse.y,eModeUse)) ProcessClick(mouse.x,mouse.y,eModeUse);
Ã,  Ã,  Ã,  else ProcessClick(mouse.x,mouse.y,0);
Ã,  Ã,  }
Ã,  }//end if map
//-----------------------------------------------------

//	Handling room clicks:
//-----------------------------------------------------
Ã,  else if (button==eMouseLeft || button==eMouseRight) {

Ã,  Ã,  String invname;
Ã,  Ã,  if (player.ActiveInventory!=null) invname = player.ActiveInventory.Name;

Ã,  Ã,  if (button==eMouseRight) SetMode(GetDefaultAction(mouse.x,mouse.y));// set the default mode when right click
Ã,  Ã,  
Ã,  Ã,  if (Extension(GSlocname)==EXITS_EXTENSION){// if its an 'exit'
Ã,  Ã,  Ã,  Ã,  HighlightActionBar();
Ã,  Ã,  Ã,  Ã,  WalkOffScreen(); 
Ã,  Ã,  }
Ã,  Ã,  // automatically give items to other player characters:
Ã,  Ã,  else if (ALWAYS_GIVE_ITEMS_TO_PLAYERS==1 && ExtensionEx(2,invname)!='d' && Mode(GIVE) && GetAGSMode(GIVE)==4 && GSloctype==2 && GSlocid<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GoToCharacter(GSlocid,0,1,2)){
Ã,  Ã,  Ã,  Ã,  GiveInv(player.ActiveInventory,character[GSlocid]);

Ã,  Ã,  Ã,  Ã,  SetMode(DEFAULT);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
// ---------------------------------------------------
Ã,  Ã,  else if (ALWAYS_GO_TO_HOTSPOTS==1 && ExtensionEx(2,GSlocname)!='d' && GetLocationType(mouse.x,mouse.y)!=0 ){
Ã,  Ã,  Ã,  Ã, UpdateActionBar(mrx,mry);
Ã,  Ã,  Ã,  Ã, HighlightActionBar();
Ã,  Ã,  Ã,  Ã, if (Go()==1) ProcessAction(GetMode(),mrx,mry);
Ã,  Ã,  Ã,  Ã, return;
Ã,  Ã,  }
Ã,  Ã,  else ProcessAction(GetMode(),mrx,mry);
Ã,  }


//-----------------------------------------------------

//	Handling inventory clicks:
//-----------------------------------------------------
Ã,  else if (button == eMouseLeftInv || button==eMouseRightInv){//click in inventory
Ã,  Ã,  if (button == eMouseLeftInv){
Ã,  Ã,  Ã,  if (GlobalCondition(1)) SetMode(SPECIAL_INV_MODE); //if walk or pickup mode in inventory
Ã,  Ã,  }
Ã,  Ã,  else if (button == eMouseRightInv){
Ã,  Ã,  Ã,  SetMode(GetDefaultAction(mouse.x,mouse.y));
Ã,  Ã,  } 
Ã,  Ã,  ProcessInventoryAction(GSmode,GSlocid);Ã,  
Ã,  }


#2
I get an error saying "cannot convert inventoryitem to int" here's the original

Code: ags

Ã,  else if (button==eMouseLeft || button==eMouseRight) {

Ã,  Ã,  string invname;
Ã,  Ã,  if (character[GetPlayerCharacter()].activeinv>=0) GetInvName(character[GetPlayerCharacter()].activeinv, invname);

Ã,  Ã,  if (button==eMouseRight) SetMode(GetDefaultAction(mouse.x,mouse.y));// set the default mode when right click
Ã,  Ã,  
Ã,  Ã,  if (Extension(GSlocname)==EXITS_EXTENSION){// if its an 'exit'
Ã,  Ã,  Ã,  Ã,  HighlightActionBar();
Ã,  Ã,  Ã,  Ã,  WalkOffScreen(); 
Ã,  Ã,  }
Ã,  Ã,  // automatically give items to other player characters:
Ã,  Ã,  else if (ALWAYS_GIVE_ITEMS_TO_PLAYERS==1 && ExtensionEx(2,invname)!='d' && Mode(GIVE) && GetAGSMode(GIVE)==4 && GSloctype==2 && GSlocid<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GoToCharacter(GSlocid,0,1,2)){

Ã,  Ã,  Ã,  Ã, GiveInv(character[GetPlayerCharacter()].activeinv,GSlocid);

Ã,  Ã,  Ã,  Ã,  SetMode(DEFAULT);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
// ---------------------------------------------------
Ã,  Ã,  else if (ALWAYS_GO_TO_HOTSPOTS==1 && ExtensionEx(2,GSlocname)!='d' && GetLocationType(mouse.x,mouse.y)!=0 ){
Ã,  Ã,  Ã,  Ã, UpdateActionBar(mrx,mry);
Ã,  Ã,  Ã,  Ã, HighlightActionBar();
Ã,  Ã,  Ã,  Ã, if (Go()==1) ProcessAction(GetMode(),mrx,mry);
Ã,  Ã,  Ã,  Ã, return;
Ã,  Ã,  }
Ã,  Ã,  else ProcessAction(GetMode(),mrx,mry);
Ã,  }


And here's what I have so far, I had to also add
Character *charid;
InventoryItem *invitem;
As I got an undefined token with the "GiveInv(invitem, charid);"
Code: ags

Ã,  else if (button==eMouseLeft || button==eMouseRight) {

Ã,  Ã,  String invname;
Ã,  Ã,  if (player.ActiveInventory>=0) invname = player.ActiveInventory.Name;


Ã,  Ã,  if (button==eMouseRight) SetMode(GetDefaultAction(mouse.x,mouse.y));// set the default mode when right click
Ã,  Ã,  
Ã,  Ã,  if (Extension(GSlocname)==EXITS_EXTENSION){// if its an 'exit'
Ã,  Ã,  Ã,  Ã,  HighlightActionBar();
Ã,  Ã,  Ã,  Ã,  WalkOffScreen(); 
Ã,  Ã,  }
Ã,  Ã,  // automatically give items to other player characters:
Ã,  Ã,  else if (ALWAYS_GIVE_ITEMS_TO_PLAYERS==1 && ExtensionEx(2,invname)!='d' && Mode(GIVE) && GetAGSMode(GIVE)==4 && GSloctype==2 && GSlocid<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GoToCharacter(GSlocid,0,1,2)){

Character *charid;
InventoryItem *invitem;
Ã,  Ã,  Ã,  Ã, GiveInv(invitem, charid);

Ã,  Ã,  Ã,  Ã,  SetMode(DEFAULT);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }

#3
Would I be right with turning this
Code: ags

GiveInv(character[GetPlayerCharacter()].activeinv,GSlocid);

into this as the function is now
GiveInv(InventoryItem *invitem, Character *charid)
Code: ags

GiveInv(invitem, charid);


and my next question is with this code
Code: ags

if (character[GetPlayerCharacter()].activeinv>=0) GetInvName(character[GetPlayerCharacter()].activeinv, invname);

I've tried this
Code: ags

if (player.ActiveInventory>=0) player.ActiveInventory.Name;

but it's not working any helk would be grateful
#4
I'm assuming my last code is okay, as I would like to check that this next function is right.
Here's the original
Code: ags

function WalkOffScreen(){
 //handles the action of hotspots with exit extension ('>e' by default).
 //double click in such hotspots/objects... will make the player skip
 //walking to it. Look the documentation for more information on exits.
Ã,  if (IsTimerExpired(19)==1){ 
Ã,  Ã,  SetTimer(19,GetGameSpeed()/3);
Ã,  Ã,  if (Go()){
Ã,  Ã,  Ã,  int x=character[GetPlayerCharacter()].x,y=character[GetPlayerCharacter()].y;

Ã,  Ã,  Ã,  int offset=30;
Ã,  Ã,  Ã,  int dir=ExtensionEx(2,GSlocname);
Ã,  Ã,  Ã,  ifÃ,  Ã,  Ã,  (dir=='u') y-=offset;
Ã,  Ã,  Ã,  else if (dir=='d') y+=offset;
Ã,  Ã,  Ã,  else if (dir=='l') x-=offset;
Ã,  Ã,  Ã,  else if (dir=='r') x+=offset;
Ã,  Ã,  Ã,  if (MovePlayerEx(x,y,1)==1)
Ã,  Ã,  Ã,  Ã,  RunHotspotInteraction(GSlocid,9);
Ã,  Ã,  }
Ã,  }
Ã,  else RunHotspotInteraction(GSlocid,9);
}


And here's mine.
Code: ags

function WalkOffScreen(){

Ã,  if (IsTimerExpired(19)==1){ 
Ã,  Ã,  SetTimer(19,GetGameSpeed()/3);
Ã,  Ã,  if (Go()){
Ã,  Ã,  Ã,  int x=character[player.ID].x,y=character[player.ID].y;// <---Here

Ã,  Ã,  Ã,  int offset=30;
Ã,  Ã,  Ã,  int dir=ExtensionEx(2,GSlocname);
Ã,  Ã,  Ã,  ifÃ,  Ã,  Ã,  (dir=='u') y-=offset;
Ã,  Ã,  Ã,  else if (dir=='d') y+=offset;
Ã,  Ã,  Ã,  else if (dir=='l') x-=offset;
Ã,  Ã,  Ã,  else if (dir=='r') x+=offset;
Ã,  Ã,  Ã,  if (MovePlayerEx(x,y,1)==1)
Ã,  Ã,  Ã,  Ã, hotspot[GSlocid].RunInteraction(9);//<---Here
Ã,  Ã,  }
Ã,  }
Ã,  else hotspot[GSlocid].RunInteraction(9);//<---Here
}


*Edit*
My next problem is with
Code: ags

Ã,  else if (button==eMouseLeft || button==eMouseRight) {

Ã,  Ã,  string invname;
Ã,  Ã,  if (character[GetPlayerCharacter()].activeinv>=0) GetInvName(character[GetPlayerCharacter()].activeinv, invname);
Ã,  Ã,  if (button==eMouseRight) SetMode(GetDefaultAction(mouse.x,mouse.y));// set the default mode when right click
Ã,  Ã,  
Ã,  Ã,  if (Extension(GSlocname)==EXITS_EXTENSION){// if its an 'exit'
Ã,  Ã,  Ã,  Ã,  HighlightActionBar();
Ã,  Ã,  Ã,  Ã,  WalkOffScreen(); 
Ã,  Ã,  }
Ã,  Ã,  // automatically give items to other player characters:
Ã,  Ã,  else if (ALWAYS_GIVE_ITEMS_TO_PLAYERS==1 && ExtensionEx(2,invname)!='d' && Mode(GIVE) && GetAGSMode(GIVE)==4 && GSloctype==2 && GSlocid<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GoToCharacter(GSlocid,0,1,2)){
Ã,  Ã,  Ã,  Ã, GiveInv(character[GetPlayerCharacter()].activeinv,GSlocid);
Ã,  Ã,  Ã,  Ã,  SetMode(DEFAULT);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }


I've tried this but doesn't work
Code: ags

Ã,  else if (button==eMouseLeft || button==eMouseRight) {
if (player.ActiveInventory>=0) player.ActiveInventory.Name;//<---here
Ã,  Ã,  if (button==eMouseRight) SetMode(GetDefaultAction(mouse.x,mouse.y));// set the default mode when right click
Ã,  Ã,  
Ã,  Ã,  if (Extension(GSlocname)==EXITS_EXTENSION){// if its an 'exit'
Ã,  Ã,  Ã,  Ã,  HighlightActionBar();
Ã,  Ã,  Ã,  Ã,  WalkOffScreen(); 
Ã,  Ã,  }
Ã,  Ã,  // automatically give items to other player characters:
Ã,  Ã,  else if (ALWAYS_GIVE_ITEMS_TO_PLAYERS==1 && ExtensionEx(2,invname)!='d' && Mode(GIVE) && GetAGSMode(GIVE)==4 && GSloctype==2 && GSlocid<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GoToCharacter(GSlocid,0,1,2)){
Ã,  Ã,  Ã,  Ã, GiveInv(character[GetPlayerCharacter()].activeinv,GSlocid);
Ã,  Ã,  Ã,  Ã,  SetMode(DEFAULT);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }

And how would I change
Code: ags

GiveInv(character[GetPlayerCharacter()].activeinv,GSlocid);

As I think it is linking to the function
Code: ags

function GiveInv(InventoryItem *invitem, Character *charid){


Thanks in advance
#5
Thanks Ashen
Yes MAX_PLAYERS is defined with this
Code: ags

#define MAX_PLAYERS 3//Put here how many player characters your game has

My next problem, am I right with turning this
Code: ags

if (Tposition[counter].smallpicbevelbutton==GetGUIObjectAt(mouse.x,mouse.y) ){

into this
Code: ags

if (gMaingui.Controls[Tposition[counter].smallpicbevelbutton]){


If this is okay then would this
Code: ags

Ã,  string buffer;
Ã,  string madetext;
Ã,  int mode;
Ã,  mode=GSmode;

if (Tposition[counter].smallpicbevelbutton== GUIControl.GetAtScreenXY(mouse.x, mouse.y){
 GetInvName(character[GetPlayerCharacter()].activeinv,buffer);
 RemoveExtension(buffer);
 StrFormat(madetext,"%s %s %s %s",Tmode[GIVE].name,buffer,Tmode[GIVE].preposition,character[Tposition[counter].charac].name);
Ã, }


turn into this?
Code: ags

Ã,  String buffer;
Ã,  String madetext;
Ã,  int mode;
Ã,  mode=GSmode;

if (gMaingui.Controls[Tposition[counter].smallpicbevelbutton] ){
 madetext=String.Format("%s %s %s %s", madetext, Tmode[GIVE].name, RemoveExtension(player.ActiveInventory.Name), Tmode[mode].preposition);
}

#6
Thanks SSH
I've been using your code from MI2 template into this template hope you don't mind.

My next problem is with
Code: ags

function GlobalConditionEx(int parameter, int roomx, int roomy){
// here are some conditions that are used many times in the script
Ã,  if (parameter==1){//if the mouse is in the inventory and modes Walk or pickup are selected
Ã,  Ã,  return ( GetInvAt(roomx-GetViewportX(),roomy-GetViewportY())>=0 && (GetAGSMode(GetMode())==9 || GetAGSMode(GetMode())==5) );
Ã,  }
Ã,  else if (parameter==2){//if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
Ã,  Ã,  return (character[GetPlayerCharacter()].activeinv==GetInvAt(mouse.x,mouse.y) && GetAGSMode(GetMode())==4);
Ã,  }
Ã,  else if (parameter==3){//if the mode is talk, or "Give", and the mouse isnt over a character
Ã,  Ã,  return (Ã,  Ã, (GetAGSMode(GetMode())==MODE_TALK || (Mode(GIVE) && GetAGSMode(GIVE)==4) ) && GetLocationType(roomx-GetViewportX(),roomy-GetViewportY())!=2Ã,  );
Ã,  }
Ã,  else if (parameter==4){//if its a 'only inventory' mode (like GIVE), and the mouse isnt over a inv.item
Ã,  Ã,  return (GetAGSMode(GetMode())==MODE_USE && Tmode[GSmode].onlyinv==1 && GetInvAt(mouse.x,mouse.y)<0);
Ã,  }
Ã,  else if (parameter==5){
Ã,  Ã,  int counter=1;
Ã,  Ã,  while (counter<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GetGUIAt(mouse.x,mouse.y)==MAINGUI && GetGUIObjectAt(mouse.x,mouse.y)==Tposition[counter].smallpicbevelbutton) return 1;
Ã,  Ã,  Ã,  counter++;
Ã,  Ã,  }
Ã,  Ã,  return 0;
Ã,  }
}

And I sort of ended up with this which I think is probably not right, haven't tried parameter 5 yet.
Code: ags

function GlobalConditionEx(int parameter, int roomx, int roomy){
// here are some conditions that are used many times in the script
Ã,  InventoryItem *ii=InventoryItem.GetAtScreenXY(mouse.x,mouse.y);
Ã,  if (parameter==1){//if the mouse is in the inventory and modes Walk or pickup are selected
Ã,  Ã,  return ( ii!=null && (roomx-GetViewportX(),roomy-GetViewportY())>=0 && (GetAGSMode(GetMode())==9 || (GetAGSMode(GetMode())==5) );
Ã,  }
Ã,  else if (parameter==2){//if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
Ã,  Ã,  return (player.ActiveInventory==ii && GetAGSMode(GetMode())==4);
Ã,  }
Ã,  else if (parameter==3){//if the mode is talk, or "Give", and the mouse isnt over a character
Ã,  Ã,  return (Ã,  Ã, (GetAGSMode(GetMode())==eModeTalkto || (Mode(GIVE) && GetAGSMode(GetMode())==4) ) && GetLocationType(roomx-GetViewportX(),roomy-GetViewportY())!=2Ã,  );
Ã,  }
Ã,  else if (parameter==4){//if its a 'only inventory' mode (like GIVE), and the mouse isnt over a inv.item
Ã,  Ã,  return (GetAGSMode(GetMode())==eModeUse && Tmode[GSmode].onlyinv==1 && ii==null);
Ã,  }
Ã,  else if (parameter==5){
Ã,  Ã,  int counter=1;
Ã,  Ã,  while (counter<MAX_PLAYERS){
Ã,  Ã,  Ã,  if (GetGUIAt(mouse.x,mouse.y)==MAINGUI && GetGUIObjectAt(mouse.x,mouse.y)==Tposition[counter].smallpicbevelbutton) return 1;
Ã,  Ã,  Ã,  counter++;
Ã,  Ã,  }
Ã,  Ã,  return 0;
Ã,  }
}

function GlobalCondition(int parameter){
Ã,  return GlobalConditionEx(parameter, mouse.x+GetViewportX(), mouse.y+GetViewportY());
}


*EDIT*
Just realised that maybe parameter 1 could be
Code: ags

Ã,  if (parameter==1){//if the mouse is in the inventory and modes Walk or pickup are selected
Ã,  Ã,  return ( ii!=null && (GetAGSMode(GetMode())==9 || GetAGSMode(GetMode())==5) );

Just need help with parameter 5

any help would be grateful thanks again.
#7
How would I change this function as it is also linked with the "function GiveInv(InventoryItem *invitem, Character *charid){"

Code: ags

function GiveInvChronOJohn(int invitem, int charid){
Ã,  String invname;
Ã,  GetInvName(invitem, invname);
Ã,  if (ExtensionEx(3,invname)!='d') {
Ã,  Ã,  GSmode=GIVECHRON;
Ã,  Ã,  GSusedmode=GIVECHRON;
Ã,  Ã,  SetGraphicalVariable("Used Mode", GIVECHRON);
Ã,  Ã,  GiveInv(invitem, charid);
Ã,  Ã,  SetMode(DEFAULT);
Ã,  }
Ã,  else {
Ã,  //you could put here different messages or actions for different items when the player
Ã,  //tries to give them via the chron-o-john (i.e. the little icons in the GUI)
Ã,  //and it doesnt do the default behaviour (giving the item), because the second extension of 
Ã,  //that inventory item is 'd'.
Ã,  Ã,  if (invitem==2) Display("The hamster wouldn't survive to a Chron-O-John travel");//if tried to give the hamster
Ã,  Ã,  else Display ("I think i can't put that in the Chron-O-John"); //generic message
Ã,  }
}


Thanks in advance
#8
How do you mean? just leave out "invname" or the whole function?
If it's just the "invname" do you mean so that all that is left would be something like
Code: ags

 function GiveInv(int invitem, int charid){
Ã,  character[charid].inv[invitem]=player.ID.inv[invitem];
Ã,  player.ID.inv[invitem]=0;
Ã,  UpdateInventory();
Ã,  player.ID.activeinv=invitem;

Ã,  GSloctype=0;
Ã,  RunCharacterInteraction(charid, MODE_USEINV);
}

*Edit*
As this is also linked to this function
Code: ags

function GiveInvChronOJohn(int invitem, int charid){
Ã,  String invname;
Ã,  GetInvName(invitem, invname);
Ã,  if (ExtensionEx(3,invname)!='d') {
Ã,  Ã,  GSmode=GIVECHRON;
Ã,  Ã,  GSusedmode=GIVECHRON;
Ã,  Ã,  SetGraphicalVariable("Used Mode", GIVECHRON);
Ã,  Ã,  GiveInv(invitem, charid);
Ã,  Ã,  SetMode(DEFAULT);
Ã,  }
Ã,  else {
Ã,  //you could put here different messages or actions for different items when the player
Ã,  //tries to give them via the chron-o-john (i.e. the little icons in the GUI)
Ã,  //and it doesnt do the default behaviour (giving the item), because the second extension of 
Ã,  //that inventory item is 'd'.
Ã,  Ã,  if (invitem==2) Display("The hamster wouldn't survive to a Chron-O-John travel");//if tried to give the hamster
Ã,  Ã,  else Display ("I think i can't put that in the Chron-O-John"); //generic message
Ã,  }
}

which would be the next problem.
#9
Great that fixed that problem.
Now my next problem seems to be with the new "Strings" commands.
I have this code and it's saying "undefined token GetInvName"
here's the function in question
Code: ags

function GiveInv(int invitem, int charid){
Ã,  String invname;
Ã,  GetInvName(invitem,invname);

Ã,  character[charid].inv[invitem]=character[GetPlayerCharacter()].inv[invitem];
Ã,  character[GetPlayerCharacter()].inv[invitem]=0;
Ã,  UpdateInventory();
Ã,  character[GetPlayerCharacter()].activeinv=invitem;

Ã,  GSloctype=0;
Ã,  RunCharacterInteraction(charid, MODE_USEINV);
}

Also would I be right with using this code?
Code: ags

Ã,  character[charid].inv[invitem]=player.ID.inv[invitem];
Ã,  player.ID.inv[invitem]=0;
Ã,  UpdateInventory();
Ã,  player.ID.activeinv=invitem;

#10
I tried your shortened version of
Code: ags

Tposition[counter].smallpicbutton.NormalGraphic = Tplayer[player.ID].smallpic;

and this gave an error stating NormalGraphic is not a member of "int". So I used your second version which seems to work.

My next problem is with this code
Code: ags

if (Tmode[counter].button[charid]>=0) SetButtonPic(MAINGUI,Tmode[counter].button[charid],2,Tmode[counter].highlightedbutton[charid]);

I've tried this code below, but I get a Parse error in expr near "Tmode"
Code: ags

if (Tmode[counter].button[charid]>=0) gMaingui.Controls[Tmode[counter].button[charid]].AsButton.MouseOverGraphic = Tmode[counter].highlightedbutton[charid]);

I know I'm missing something but I cannot see it

*Edit*
Also would I be right with changing
Code: ags

Ã,  SetLabelColor(ACTION,0,Tplayer[charid].actionlabelcolor);

Ã,  Tplayer[GetPlayerCharacter()].topinvitem=game.top_inv_item;
Ã,  if (Tplayer[charid].topinvitem>=0) game.top_inv_item=Tplayer[charid].topinvitem;

Ã,  SetCharacterClickable(GetPlayerCharacter(),1);
Ã,  SetCharacterClickable(charid,0);
Ã,  StopMoving(charid);
Ã,  SetPlayerCharacter(charid);

To this
Code: ags

Ã,  labelStatus.TextColor = Tplayer[charid].actionlabelcolor;

Ã,  Tplayer[charid].topinvitem=MainInventory.TopItem;// MainInventory script name.
Ã,  if (Tplayer[charid].topinvitem>=0) MainInventory.TopItem=Tplayer[charid].topinvitem;

Ã,  character[player.ID].Clickable = 1;// Yes
Ã,  character[charid].Clickable = 0;Ã,  Ã, // No
Ã,  player.StopMoving();
Ã,  character[charid].SetAsPlayer();
Ã,  SetMode(DEFAULT);

#11
Hi I'm having a go with updating the DOTT template to use with ags 2.72, I'm wanting to use the enforce object based scripting and enforce new style strings and was wondering how you upate the following code.
Code: ags

function SetPlayer(int charid){
Ã,  //use this instead of SetPlayerCharacter function for switching to other players
Ã,  int counter=1;
Ã,  while (counter<MAX_PLAYERS){
Ã,  Ã,  if (charid==Tposition[counter].charac){
Ã,  Ã,  Ã,  SetButtonPic(MAINGUI,Tposition[counter].smallpicbutton,1,Tplayer[GetPlayerCharacter()].smallpic);
Ã,  Ã,  Ã,  Tposition[counter].charac=GetPlayerCharacter();
Ã,  Ã,  }
Ã,  Ã,  SetButtonPic(MAINGUI,Tposition[counter].smallpicbevelbutton,1,Tplayer[charid].smallpicbevel);
Ã,  Ã,  counter++;
Ã,  }
Ã,  Tposition[0].charac=charid;
Ã,  counter=0;Ã,  Ã, 
Ã,  while (counter<MAX_MODES){
Ã,  Ã,  if (Tmode[counter].button[charid]>=0) SetButtonPic(MAINGUI,Tmode[counter].button[charid],2,Tmode[counter].highlightedbutton[charid]);
Ã,  Ã,  counter++;
Ã,  }
Ã,  SetLabelColor(ACTION,0,Tplayer[charid].actionlabelcolor);

Ã,  Tplayer[GetPlayerCharacter()].topinvitem=game.top_inv_item;
Ã,  if (Tplayer[charid].topinvitem>=0) game.top_inv_item=Tplayer[charid].topinvitem;

Ã,  SetCharacterClickable(GetPlayerCharacter(),1);
Ã,  SetCharacterClickable(charid,0);
Ã,  StopMoving(GetPlayerCharacter());
Ã,  SetPlayerCharacter(charid);
Ã,  SetMode(DEFAULT);

}


I get an error with the "SetButtonPic" undefined token.
Any help would be grateful
#12
One thing I have noticed is with the status line,
in that for example. If you give a character an inventory item and this in turn causes the player to change room, in the new room it will briefly show that you have given an inventory item to a character.

So what I then did was to give the status label a script name "lblStatus" and then add to the on event function the following:
Code: ags

function on_event (int event, int data) {//////////////////////////////////////On Event/////////////////////On Event
Ã,  if (event == eEventEnterRoomBeforeFadein) player.PlaceOnWalkableArea();

Ã,  else if (event == eEventLeaveRoom) { // Reset Label to "walk to".
Ã,  Ã,  SetDefaultMode(WALK);
Ã,  Ã,  lblStatus.Text = ("Walk to");
Ã,  }

}


which seems to have solved the problem.
#13
I had a quick look using 2.72, I also had the same error only it was with line 428.
Code: ags

ViewFrame *vf2=Game.GetViewFrame(CURSOR, 0, counter/DELAY);


So I then chaged it too :
Code: ags

ViewFrame *vf2=Game.GetViewFrame(CURSOR,0,1);

This may not be right, but for now it seems to work.
#14
With regards to the voodoo doll interactions yes your quite right it is in the 2.70 version. (Slaps face repeatedly)
And maybe that should have been taken out.

*Edit* The example shown with the voodoo doll uses the drop down menu conditional and it's this that doesn't kick in the unhandled event for other inventory items used on it.*

With reagrds to the
Code: ags

if (MainInventory.TopItem > 0){Ã,  Ã,  Ã, //if invent. can scroll up 
Ã,  Ã,  gMaingui.Controls[9].AsButton.NormalGraphic=INV_UP_ARROW_ON_SPRITE;
Ã,  }
Ã,  else //if can not scroll up
Ã,  Ã,  gMaingui.Controls[9].AsButton.NormalGraphic=INV_UP_ARROW_OFF_SPRITE;Ã,  Ã, 
Ã,  if (MainInventory.TopItem < MainInventory.ItemCount - (MainInventory.RowCount*MainInventory.ItemsPerRow))Ã,  Ã, //if invent. can scroll down 
Ã,  Ã,  gMaingui.Controls[10].AsButton.NormalGraphic=INV_DOWN_ARROW_ON_SPRITE;Ã,  
Ã,  elseÃ,  // if can not scroll down
Ã,  Ã,  gMaingui.Controls[10].AsButton.NormalGraphic=INV_DOWN_ARROW_OFF_SPRITE;
//-----------------------------------------------------
}



that was to show anyone else looking where you had named the inventory box.

#15
Hi SSH
Good work on the updating.
I was going to ask you if you had sorted out the unhandled event for inventory items on other inventory items as with the 2.70 version they didn't always work.

I thought when testing your version you had the same problem, but what I found with your example with the "needles" inventory was that you were missing the unhandled function it should read like:

Code: ags

Ã,  Ã,  if (UsedInvMode(USE,3)){ // (mode used,inventory number)
// Display ("Chachipiruli");Ã,  
player.LoseInventory(inventory[1]);
player.LoseInventory(inventory[3]);
player.AddInventory(inventory[2]);
}

else Unhandled(); // <---


I also found the interactions for the "voodoo doll" example you show doesn't work if other inventory items are used on it. So it's better to use the above example.


Also you might want to comment out the
Code: ags

#define FIRST_INV_SLOT_COORDS


As you have named the inventory box so when moving the gui's around you don't need to set new coordinates for it.

Code: ags

Ã,  if (MainInventory.TopItem > 0){Ã,  Ã,  Ã, //if invent. can scroll up 
Ã,  Ã,  gMaingui.Controls[9].AsButton.NormalGraphic=INV_UP_ARROW_ON_SPRITE;
Ã,  }
Ã,  else //if can not scroll up
Ã,  Ã,  gMaingui.Controls[9].AsButton.NormalGraphic=INV_UP_ARROW_OFF_SPRITE;Ã,  Ã, 
Ã,  if (MainInventory.TopItem < MainInventory.ItemCount - (MainInventory.RowCount*MainInventory.ItemsPerRow))Ã,  Ã, //if invent. can scroll down 
Ã,  Ã,  gMaingui.Controls[10].AsButton.NormalGraphic=INV_DOWN_ARROW_ON_SPRITE;Ã,  
Ã,  elseÃ,  // if can not scroll down
Ã,  Ã,  gMaingui.Controls[10].AsButton.NormalGraphic=INV_DOWN_ARROW_OFF_SPRITE;
//-----------------------------------------------------
}


Thats my findings at present I'll keep testing it.

Keep up the good work

Lazarus
#16
SSH:

I didn't think!, sorry!

I hope the template is okay but it may need tweaking here and there (I am relatively new to this scripting lark).

Arrays and struts will be my next headache me thinks  ::)

... so you guys will be fed-up with me and my postings before too long  ;D
#17
I'm progressing well with my game using the MI2 template (thanks to the creator Proskrito for making the template!) and converted the template for use with AGS 2.7.

Here's my problem:

I now am at a point where I have around 25 inventory items active for use on each other, obviously only a few will combine! 

The problem I have is that if I "use inventory item on another inventory item" sometimes it works (displaying the message I have scripted for it), sometimes it does nothing, sometimes it says the unhandled event (i.e "That doesn't work") ...

What I don't understand is there doesn't seem to be a pattern to it.

I would like the player to receive a message everytime they try to combine items.

Is anyone else experiencing this?  Or, if you are using the template can you tell me if you can use inventory items on each other and always get a message and not nothingness?

Hope I haven't babbled!

Thanks ...

PS  I haven't "fiddled" with the original Inventory Scripting on the template.
#18
I've seem to have found away around my problem, in that by using ">td" (talk don't go) at the end of the characters name in the main character profile.
eg... guybrush>td

and then if I want to talk to the character I manually put move player command to the character in question before talking to them and so far it works every time with no problems.

I think the problem is with "always goto hotspot" and "clickable chacters" in the global script, but I could be wrong tho.

but by using the >td command the problem goes, and using the ">td" doesn't show up in the game if this is any help
#19
Thanks for the reply I will certainly have ago that.

My other problem i've got is that using MI2 template I have, is that when I select another chacter on screen and the "Talk To" is highlighted and I use either the GUI button or using the right button to activate the conversation is that it doesn't work first time, I've got to press the buttons acouple of times before it works.

Any help or ideas would be grateful
#20
I'm not sure if i should be posting this here so feel free to move if not.Ã,  ;D

I can script all the buttons on the inventry (MI2 Template) ie Push, Pull etc..

The problem i have is that say i have 1 hotspot (say a rock) and 1 object (say a stick) in a room, what i would like to happen is that the player has to push the hotspot(rock) then displaying "the rock has moved abit " then allowing the player to pickup the object(stick) is this possible?

And if it is possible, then could you please help

I'm using ags version 2.7

thanks inadvance.
SMF spam blocked by CleanTalk