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

#141
Okay, tried the following:

Code: ags
  gInventory.Visible=true;
  Debug(0, 0);
  
  
  
  //use i on j
  for (int i=1;i<=Game.InventoryItemCount;i++) {
    
    InventoryItem *a;
    a = invCustomInv.ItemAtIndex[i];
    Display("a.Name %s",a.Name);
    player.ActiveInventory=a;
    game.inv_activated=a.ID;
    
    Display("inv_active activeinventory is %d",game.inv_activated);
    Display("pl.activeinventory is %d",player.ActiveInventory);
    
    Display("activeinv %d %d",player.ActiveInventory, game.inv_activated);
    
    for (int j=1;j<=Game.InventoryItemCount;j++) {
      Display("combining object index %s (%d/%d) with %s (%d/%d)",inventory[i].Name, i, Game.InventoryItemCount, inventory[j].Name, j, Game.InventoryItemCount);
      
      Display("modeusinv interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModeUseinv));
      inventory[j].RunInteraction(eModeUseinv);
      Display("modelookat interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModeLookat));
      inventory[j].RunInteraction(eModeLookat);
      Display("modeinteract interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModeInteract));
      inventory[j].RunInteraction(eModeInteract);
      Display("modepickup interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModePickup));
      inventory[j].RunInteraction(eModePickup);
      Display("modetalkto interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModeTalkto));
      inventory[j].RunInteraction(eModeTalkto);
      Display("modewalkto interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModeWalkto));
      inventory[j].RunInteraction(eModeWalkto);
      
    }
  }


Output is:
a.Name Knife
inv_active activeinventory is 2
pl.activeinventory is 0
activeinv 0 2
combining object index Art Notebook (1/144) with Art Notebook (1/144)
modeusinv interaction with Art Notebook is 1
modelookat interaction with Art Notebook is 1
modeinteract interaction with Art Notebook is 0
modepickup interaction with Art Notebook is 0
modewalkto interaction with Art Notebook is 0

etc.

Nothing happens and no functions are run at any point. I'm in the dark, can anybody help? All I want to is simulate: item A being ActiveInventory, player clicks mouse on item B, iB_useinv() runs, it goes on to next combination.
#142
I wrote the below to test all my inventory objects combining with all other inventory objects. This is speed up testing.

Code: ags
  for (int i=1;i<=Game.InventoryItemCount;i++) {
    player.ActiveInventory=inventory[i];
    for (int j=1;j<=Game.InventoryItemCount;j++) {
      Display("combining object index %s (%d/%d) with %s (%d/%d)",inventory[i].Name, i, Game.InventoryItemCount, inventory[j].Name, j, Game.InventoryItemCount);
      Display("modeusinv interaction with %s is %d",inventory[j].Name, inventory[j].IsInteractionAvailable(eModeUseinv));
      inventory[j].RunInteraction(eModeUseinv);
    }
  }


Always comes up as 1/true interaction available, runs the interaction, nothing happens. Don't know if this is supposed to go to a pre-existing function (of which there are many), or something else, but no useinv ever works or responds. No 'I can't use these objects together' standard programmed response; nothing.
#143
I'm trying to add/remove ONLY items that a player starts with, however InvWindow, Inventory, Game, player.Inventory* etc. doesn't contain a function to check for this, or a property.
How do I do the following (pseudocode):

Code: ags
//add all 'starts game with' items back to empty inventory
for (int x=1; x<=Game.InventoryItemCount; x++) {
  if (player.InventoryItemStartsWith[x])
    player.InventoryQuantity=1;   
}
#144
It's my edited, awful code, but it now works perfectly:

GlobalScript.ash
Code: ags
...
//for gFloatingText 'description of what mouse is over'
#define FLOATING_TEXT_GUI gFloatingText
#define FLOATING_TEXT_FONT eFontSpeech
#define FLOATING_TEXT_OUTLINE_WIDTH 2
#define FLOATING_TEXT_COLOR 11
#define FLOATING_TEXT_OUTLINE_COLOR 0
#define FLOATING_TEXT_BACKGROUND_COLOR 15
#define FLOATING_TEXT_H_PADDING 20
#define FLOATING_TEXT_V_PADDING 40
#define FLOATING_TEXT_BASELINE 4
...


GlobalScript.asc
Code: ags
function SetFloatingText(String floatingText)
{ 
  if (Intro) return;

  if(textContent == null)
    textContent = "";
  
  if(old_mouse_x!=mouse.x || old_mouse_y!=mouse.y) {
  
    textContent = floatingText;
    if(String.IsNullOrEmpty(textContent)) {
      if(sprtFloatingText != null && (mouse.y>120)) {   //a bit of a kludge for mouse.y for when conversation is on, to wipe the sprite when it's on the lower half of the screen, away from conversation icons at the top
        DrawingSurface* dsFloatingText = sprtFloatingText.GetDrawingSurface();
        dsFloatingText.Clear(COLOR_TRANSPARENT);
        dsFloatingText.Release();
        FLOATING_TEXT_GUI.BackgroundGraphic = sprtFloatingText.Graphic;
        FLOATING_TEXT_GUI.Width = 1;
        FLOATING_TEXT_GUI.Height = 1;
      }
    } else {
      
      int w;
      int h;
      
      if (ConversationIsOn) {
        w = 1366;   //width of conversation icons
        h = 150;   //height+a bit of conversation icons
      } else {
        w = GetTextWidth(floatingText, FLOATING_TEXT_FONT) + 2*FLOATING_TEXT_OUTLINE_WIDTH + 2*FLOATING_TEXT_H_PADDING;
        h = GetTextHeight(floatingText, FLOATING_TEXT_FONT, w+1) + 2*FLOATING_TEXT_OUTLINE_WIDTH + 2*FLOATING_TEXT_V_PADDING;        
      }
      
      sprtFloatingText = DynamicSprite.Create(w, h, true);
      
      DrawingSurface* dsFloatingText = sprtFloatingText.GetDrawingSurface();
 
      dsFloatingText.Clear(COLOR_TRANSPARENT);   //TRANSPARENT because otherwise was coming up as a black square
      dsFloatingText.DrawingColor = FLOATING_TEXT_COLOR;
      
      if (ConversationIsOn) {
        dsFloatingText.drawStringWrappedOutline((FLOATING_TEXT_OUTLINE_WIDTH+FLOATING_TEXT_H_PADDING),
                                                120,
                                                w - 2*FLOATING_TEXT_OUTLINE_WIDTH - 2*FLOATING_TEXT_H_PADDING + 1,
                                                eTextOutlineRounded,
                                                FLOATING_TEXT_FONT,
                                                eAlignCentre,
                                                textContent,
                                                0,
                                                FLOATING_TEXT_OUTLINE_COLOR,
                                                FLOATING_TEXT_OUTLINE_WIDTH);
      } else {
        dsFloatingText.drawStringWrappedOutline((FLOATING_TEXT_OUTLINE_WIDTH+FLOATING_TEXT_H_PADDING)+15,
                                                (FLOATING_TEXT_OUTLINE_WIDTH+FLOATING_TEXT_V_PADDING-FLOATING_TEXT_BASELINE)-35,
                                                w - 2*FLOATING_TEXT_OUTLINE_WIDTH - 2*FLOATING_TEXT_H_PADDING + 1,
                                                eTextOutlineRounded,
                                                FLOATING_TEXT_FONT,
                                                eAlignLeft,
                                                textContent,
                                                0,
                                                FLOATING_TEXT_OUTLINE_COLOR,
                                                FLOATING_TEXT_OUTLINE_WIDTH);
      }
      
      dsFloatingText.Release();
      FLOATING_TEXT_GUI.Width = w;
      FLOATING_TEXT_GUI.Height = h;
      FLOATING_TEXT_GUI.BackgroundGraphic = sprtFloatingText.Graphic;
    }
  }
}



function repeatedly_execute_always()
{  
...
  //floating text description
if (Game.GetLocationName(mouse.x, mouse.y)!=null) {
	  gFloatingText.Visible = true;
    SetFloatingText(Game.GetLocationName(mouse.x, mouse.y));  // SetFloatingText() handles null, so we don't need to test for it
  }
  
  // Position the floating text
  if (ConversationIsOn) {
    gFloatingText.X = 0;
    gFloatingText.Y = 0;
  } else {
    gFloatingText.X = mouse.x;
    gFloatingText.Y = mouse.y-17;  //will take the corner of the description sprite up above the y-coord of the cursor, otherwise it's sits forever too far down
    
  }
...
}


Incidentally, here is my custom dialog system, which calls SetFloatingText() in dialog_options_repexec():
LangTrialHappening is a switch which is only on during a conversation with the pirates, which has custom icon size, custom background etc. etc. - please ignore, LangTrialHappenig=false for this.
The question text in a dDialog is of the form:
1234|An Apple
or
1234
1234 is a sprite number; |Text is what displays below the icon.

GlobalScript.asc
Code: ags
//----------------------------------------------------------------------------------------------------------------------
// Dialogue Options Get Dimensions
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_get_dimensions(DialogOptionsRenderingInfo* info)
{
	ConversationIsOn=true;
	beartrap=false;
  
  
	if (LangTrialHappening) {
    ConvoIconSize=110;        //redundant?
    dialog_left=507;
    info.Height =110+1;
  } else {
    ConvoIconSize=96;
    dialog_left=11;
    info.Height = 96+14;
  }

  info.X = 0;
  info.Y = 0;
  info.Width = 1366;
  
	
  gIconbar.Visible=false; //turn off top-bar
    
	MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
  DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
	if (InPirateBay) {
    ds.DrawImage(0, 0, 2639); //draw wood-panel dialog box over the top of what was there at 0,0 
  } else {
    ds.DrawImage(0, 0, 2604); //draw alternate dialog box over the top of what was there at 0,0
  }
	ds.Release();
	
	gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
  gFakeDialogOptions.Visible = true;
}

//----------------------------------------------------------------------------------------------------------------------
// Draw Dialog Options
//----------------------------------------------------------------------------------------------------------------------

function DrawDialogOptions(DrawingSurface* ds, DialogOptionsRenderingInfo* info)
{
	int i = 1, ypos = 7, xpos = dialog_left;  
  if (LangTrialHappening) ypos=1;
  
  while (i <= info.DialogToRender.OptionCount) {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn) {
			gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
			gFakeDialogOptions.Visible = true;
			
      String str = info.DialogToRender.GetOptionText(i);  //get glyph number from option text
      
      int strposdiv=str.IndexOf("|");
      int cur_img=0;
      String displayText="";
      
      if (strposdiv != -1) {     //has | in it...
        String temp=str.Substring(0, strposdiv);         //get glyph as sprite number
        cur_img=temp.AsInt;
        
      } else {      
        cur_img = str.AsInt;                                      //get glyph as sprite number
      }
      
      ds.DrawImage(xpos, ypos, cur_img);                          //draw this glyph
      
      if (LangTrialHappening) {
        xpos += PirateIconSize;
      } else {
        xpos += ConvoIconSize;																		//xpos+=width of glyph
      }
      
    }
    
    i++;
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Render
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_render(DialogOptionsRenderingInfo* info)
{
  DrawDialogOptions(info.Surface, info);
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Repeat Exec
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_repexec(DialogOptionsRenderingInfo* info)
{
	gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
  gFakeDialogOptions.Visible = true;
	
	int i = 1, xpos = dialog_left;
  while (i <= info.DialogToRender.OptionCount) {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn) {
      if (LangTrialHappening) {  
        
        if (	 mouse.y >= info.Y
            && mouse.y <= info.Y+PirateIconSize
            && mouse.x >= xpos
            && mouse.x <= xpos+PirateIconSize
            && mouse.x <= 837 )
        {
          info.ActiveOptionID = i;
          
          DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
          
          DrawDialogOptions(ds, info);
          ds.Release();
          
          return;
        }
        
      } else {
        
        if (	 mouse.y >= info.Y
            && mouse.y <= info.Y+ConvoIconSize+10
            && mouse.x >= xpos
            && mouse.x <= xpos+ConvoIconSize)
        {
          info.ActiveOptionID = i;
          
          DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
          
          DrawDialogOptions(ds, info);
          ds.Release();
          
          String str = info.DialogToRender.GetOptionText(i);  //get glyph number from option text
          
          int strposdiv = str.IndexOf("|");
          if (strposdiv!=-1) {
            ConvoDisplayText = str.Substring(strposdiv+1, str.Length-1);  //get associated text
          }
          
          SetFloatingText(ConvoDisplayText);  //set it to floatingText
          
          return;
        }
      }
    
      if (LangTrialHappening) {
        xpos += PirateIconSize;
      } else {
        xpos += ConvoIconSize;																		//xpos+=width of glyph
      }
    }
    i++;
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Mouse Click
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_mouse_click(DialogOptionsRenderingInfo* info, MouseButton button)
{
  if (info.ActiveOptionID > 0)
  {
    DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
		DrawDialogOptions(ds, info);
    ds.Release();

    gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
    gFakeDialogOptions.Visible = true;
    
    if (LangTrialHappening) {
      if (mouse.x>507 && mouse.x<837) {
        info.RunActiveOption();
      }
    } else {
      info.RunActiveOption();
    }
    
  }
}


some pictures:
</br>
</br>
</br>
</br>
</br>
</br>
</br>
#145
I realised this, but unless you have a screen-sized GUI on which to display the text, it will cut off the GUI as the mouse moves beyond it's border.
Eg. you have a 100x200 area, put the text on to that, as soon as your mouse reaches 150x220 absolute the text will be cut off and eventually disappear. I'm probably misunderstanding something - I definitely am - but this was what lead to make the GUI screen-sized.
As it is, it's not too inefficient, but there's a definite 200ms lag as the description catches up to the mouse. Then again, I'm using a Mac Pro 2010, so..... :P
#146
Here's something that seems to work so far....

old_mouse_x and _y are global variables, int's set to 0 initially.


Code: ags
function SetFloatingText(String floatingText)
{
	if (textContent == null)
		textContent = "";
	
	if(sprtFloatingText == null)
		sprtFloatingText = DynamicSprite.Create(FLOATING_TEXT_GUI.Width, FLOATING_TEXT_GUI.Height, true);

	if (mouse.x!=old_mouse_x || mouse.y!=old_mouse_y) {
		textContent = floatingText;
		
		DrawingSurface* dsFloatingText = sprtFloatingText.GetDrawingSurface();
		dsFloatingText.Clear(COLOR_TRANSPARENT);
		
		if(!String.IsNullOrEmpty(textContent)) {
			dsFloatingText.DrawingColor = FLOATING_TEXT_COLOR;
			dsFloatingText.drawStringWrappedOutline(mouse.x+30,
								mouse.y-30,
								FLOATING_TEXT_GUI.Width - 2*FLOATING_TEXT_OUTLINE_WIDTH,
								eTextOutlineRounded,
								FLOATING_TEXT_FONT,
								eAlignLeft,
								textContent,				
								0,						
								FLOATING_TEXT_OUTLINE_COLOR,
								FLOATING_TEXT_OUTLINE_WIDTH);
		}
		
		dsFloatingText.Release();
		
		FLOATING_TEXT_GUI.BackgroundGraphic = sprtFloatingText.Graphic;
     
		old_mouse_x=mouse.x;
		old_mouse_y=mouse.y;
	}
}
#147
Doesn't work either. Does anyone know where any of version of Description is?
#149
This function currently takes the current location at mouse.x/mouse.y, and in repeatedly_execute_always(), put's the Game.GetLocationName (ie. the editor's 'Description') at a predetermined location on the screen.
This is the editor's 'Description' for Objects, Hotspots etc.
It almost works perfectly, but I can't get it to follow and constantly update it's position on mouse.x,mouse.y

GlobalScript.asc
Code: ags
function SetFloatingText(String floatingText)
{
	if (ConversationIsOn) {
			DrawingSurface* dsFloatingText_2 = sprtFloatingText.GetDrawingSurface();
			dsFloatingText_2.Clear(COLOR_TRANSPARENT);
			dsFloatingText_2.Release();
	} else {
		if (textContent == null)
			textContent = "";
		
		if(sprtFloatingText == null)
			sprtFloatingText = DynamicSprite.Create(FLOATING_TEXT_GUI.Width, FLOATING_TEXT_GUI.Height, true);
	
		if (floatingText != textContent) {
			textContent = floatingText;
			
			DrawingSurface* dsFloatingText = sprtFloatingText.GetDrawingSurface();
			dsFloatingText.Clear(COLOR_TRANSPARENT);
			
			if(!String.IsNullOrEmpty(textContent)) {
				dsFloatingText.DrawingColor = FLOATING_TEXT_COLOR;
				dsFloatingText.drawStringWrappedOutline(mouse.x,
											mouse.y
											FLOATING_TEXT_GUI.Width - 2*FLOATING_TEXT_OUTLINE_WIDTH,
											eTextOutlineRounded,																			
											FLOATING_TEXT_FONT,																				
											eAlignLeft,																							
											textContent,																							
											0,																												
											FLOATING_TEXT_OUTLINE_COLOR,														
											FLOATING_TEXT_OUTLINE_WIDTH);
			}
			
			dsFloatingText.Release();
			
			FLOATING_TEXT_GUI.BackgroundGraphic = sprtFloatingText.Graphic;
		}
	}
}

...

function repeatedly_execute_always()
{  
...	 
	if (Game.GetLocationName(mouse.x, mouse.y)!=null) {
		SetFloatingText(Game.GetLocationName(mouse.x, mouse.y));
	}
...
}



GlobalScript.ash
Code: ags
//for gFloatingText 'description of what mouse is over'
#define FLOATING_TEXT_GUI gFloatingText
#define FLOATING_TEXT_FONT eFontSpeech
#define FLOATING_TEXT_OUTLINE_WIDTH 2
#define FLOATING_TEXT_COLOR 2047
#define FLOATING_TEXT_OUTLINE_COLOR 0


gFloatingText:
Width: 1366 (game screen width)
Height: 768 (game screen height)
Left, Top: 0
Clickable: False
Visible: True
ZOrder: 999
no controls, thats it.

What's supposed to happen: Description/Name text is supposed to follow the mouse around over an area with a Description/Name (floatingText)
What actually happens: When the mouse enters a Named area, it displays the text at those coords, but doesn't follow the mouse around.

How do I make it float around at mouse.x,mouse.y, constantly updating as it changes location?

Bonus super-advanced question: How do I get the floatingText background to have a white rectangle on it - shaped on Description words width/height - rather than translucency?
#151
Thank you :)
Any plans to add new functionality to the parser? I can't imagine it's the main method for adventure game interfaces but still.
#152
I have a console; what's entered into it is checked by a short list of words. If the word(s) are recognised (eg. "eat apple"), or in other words a specific command matching search criteria is run, I want the Parser to make a sound. This sound would probably be triggered by something like
Code: ags
if (Parser.LastRunCommandMatched) aSound.Play(....


Is anything like the above possible? Otherwise it'll become a case of repeating code:

Code: ags
if (Parser.Said("eat apple")) {
....
x=true;
}

if (Parser.Said("steal apple")) {
....
x=true;
}

if (Parser.Said("get,buy drink")) {
....
x=true;
}

if (Parser.Said("steal drink")) {
....
x=true;
}

if (x) aSound.Play(...);
x=false;


#153
Thank you oh thank you :D

Khris - solved my problems :)  I'm reading up on on_event types.
Crimson Wizard - thank you for this code, I'm saving it ad using it (in the coming weeks) to make mine more efficient :)
#154
Alright - worked on the code. The only problem which remains is the dreaded dialogue not disappearing when I restore a game.

globlscript.asc

Code: ags
DynamicSprite *buttonSavePic1;
DynamicSprite *buttonSavePic2;
DynamicSprite *buttonSavePic3;
DynamicSprite *buttonSavePic4;

function PrepareSaveGUI(int slot) {
  if (InStartupMenu) {
    buttonSave1.Visible=false;
    buttonSave2.Visible=false;
    buttonSave3.Visible=false;
    buttonSave4.Visible=false;
  } else {
    buttonSave1.Visible=true;
    buttonSave2.Visible=true;
    buttonSave3.Visible=true;
    buttonSave4.Visible=true;
  }
  
  buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 171, 96);
  if (buttonSavePic1 != null) {
    buttonLoad1.Visible=true;
    LabelDescr1.Text=Game.GetSaveSlotDescription(1);
    buttonSaveSlot1.NormalGraphic = buttonSavePic1.Graphic;
    buttonSaveSlot1.Visible=true;
    RefreshGameSlots=0;
  } else {
    if (File.Exists("$SAVEGAMEDIR$/agssave001.lociv")) { 
      buttonLoad1.Visible=false;
      RefreshGameSlots=1;
      return;
    }   
  }
  
  buttonSavePic2 = DynamicSprite.CreateFromSaveGame(2, 171, 96);
  if (buttonSavePic2 != null) {
    buttonLoad2.Visible=true;
    LabelDescr2.Text=Game.GetSaveSlotDescription(2);
    buttonSaveSlot2.NormalGraphic = buttonSavePic2.Graphic;
    buttonSaveSlot2.Visible=true;
    RefreshGameSlots=0;
  } else {
    if (File.Exists("$SAVEGAMEDIR$/agssave002.lociv")) { 
      buttonLoad2.Visible=false;
      RefreshGameSlots=2;
      return;
    }
  }
  
  buttonSavePic3 = DynamicSprite.CreateFromSaveGame(3, 171, 96);
  if (buttonSavePic3 != null) {
    buttonLoad3.Visible=true;
    LabelDescr3.Text=Game.GetSaveSlotDescription(3);
    buttonSaveSlot3.NormalGraphic = buttonSavePic3.Graphic;
    buttonSaveSlot3.Visible=true;
    RefreshGameSlots=0;
  } else {
    if (File.Exists("$SAVEGAMEDIR$/agssave003.lociv")) { 
      buttonLoad3.Visible=false;
      RefreshGameSlots=3;
      return;
    }
  }
  
  buttonSavePic4 = DynamicSprite.CreateFromSaveGame(4, 171, 96);
  if (buttonSavePic4 != null) {
    buttonLoad4.Visible=true;
    LabelDescr4.Text=Game.GetSaveSlotDescription(4);
    buttonSaveSlot4.NormalGraphic = buttonSavePic4.Graphic;
    buttonSaveSlot4.Visible=true;
    RefreshGameSlots=0;
  } else {
    if (File.Exists("$SAVEGAMEDIR$/agssave004.lociv")) { 
      buttonLoad4.Visible=false;
      RefreshGameSlots=4;
      return;
    }
  }  
}

...

function repeatedly_execute()
{
...
  if (RestoreCheck) {
    if (gSaveLoad.Visible) {
      gSaveLoad.Visible=false;
    } else {
      RestoreGameSlot(RestoreSlotNm);
      RestoreSlotNm=0;
      RestoreCheck=false;
    }
  }
...
}

...


function SaveTheGame(int slot, String desc)
{
  SaveGameSlot(slot, desc);
}

function LoadTheGame(int slot)
{
  RestoreCheck=true;
  RestoreSlotNm=slot;
}

// SAVE gSaveLoad save button functions

function buttonSave1_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("slot #1 @%02d:%02d:%02d_%02d/%02d/%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveTheGame(1, SaveDesc);
  
  if (buttonSavePic1!=null) buttonSavePic1.Delete();
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic1 != null) {
    buttonSaveSlot1.NormalGraphic = buttonSavePic1.Graphic;
    buttonSaveSlot1.Visible=true;
    buttonLoad1.Visible=true;
    LabelDescr1.Text=Game.GetSaveSlotDescription(1);
  }
  
  RefreshGameSlots=1;
}
function buttonSave2_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("slot #2 @%02d:%02d:%02d_%02d/%02d/%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(2, SaveDesc);
  
  if (buttonSavePic2!=null) buttonSavePic2.Delete();
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic2 = DynamicSprite.CreateFromSaveGame(2, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic2 != null) {
    buttonSaveSlot2.NormalGraphic = buttonSavePic2.Graphic;
    buttonSaveSlot2.Visible=true;
    buttonLoad2.Visible=true;
    LabelDescr2.Text=Game.GetSaveSlotDescription(2);
  }
  
  RefreshGameSlots=2;
}
function buttonSave3_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("slot #3 @%02d:%02d:%02d_%02d/%02d/%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(3, SaveDesc);
  
  if (buttonSavePic3!=null) buttonSavePic3.Delete();
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic3 = DynamicSprite.CreateFromSaveGame(3, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic3 != null) {
    buttonSaveSlot3.NormalGraphic = buttonSavePic3.Graphic;
    buttonSaveSlot3.Visible=true;
    buttonLoad3.Visible=true;
    LabelDescr3.Text=Game.GetSaveSlotDescription(3);
  }
  
  RefreshGameSlots=3;
}
function buttonSave4_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("slot #4 @%02d:%02d:%02d_%02d/%02d/%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(4, SaveDesc);
  
  if (buttonSavePic4!=null) buttonSavePic4.Delete();
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic4 = DynamicSprite.CreateFromSaveGame(4, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic4 != null) {
    buttonSaveSlot4.NormalGraphic = buttonSavePic4.Graphic;
    buttonSaveSlot4.Visible=true;
    buttonLoad4.Visible=true;
    LabelDescr4.Text=Game.GetSaveSlotDescription(4);
  }
  
  RefreshGameSlots=4;
}


// LOAD  gSaveLoaad load button functions

function buttonLoad1_OnClick(GUIControl *control, MouseButton button)
{
  LoadTheGame(1);
}
function buttonLoad2_OnClick(GUIControl *control, MouseButton button)
{
  LoadTheGame(2);
}
function buttonLoad3_OnClick(GUIControl *control, MouseButton button)
{
  LoadTheGame(3);
}
function buttonLoad4_OnClick(GUIControl *control, MouseButton button)
{
  LoadTheGame(4);
}



// click save icon in giconbar
function btnIconSave_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  gIconbar.Visible = false;
  mouse.UseModeGraphic(eModePointer);
  PrepareSaveGUI(0);
  gSaveLoad.Visible = true;
}


function SaveLoadExit_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  if (!InStartupMenu) {
    gIconbar.Visible=true;
  } else {
    FadeInControls_startup();
    
    for (int x=100;x>=0;x-=2) {
      object[0].Transparency=x;
      object[1].Transparency=x;
      object[2].Transparency=x;
      object[3].Transparency=x;
    }
  } 
}


I know this may give you an odd desire for Italian food (caus it's spaghetti? :P) - but can anyone suggest what might be:
a) Causing the gSaveLoad dialogue to come up visible when a game is restored (ie. despite the fact it was specifically visible=false when the game was saved); and
b) How do I actually know when a process like RestoreGameSlot() has finished? How can I do something *after* it's executed? I've used repeatedly_execute() and some flags, but it still won't separate from the final final operation being 'okay, now restore the game (and bring up the dialog as part of this)'

I have a theory it has the amount of time it pauses when saving that it still brings up the gSaveLoad as visible with a restore -- but no idea.
#155
In AGS, is it possible to use substitutions to write a variable name, and then keep it as a symbol?

I'm trying to write a for loop which goes numbers 1 to 4, and then changes properties of a GUI control with a set name 'Load4' or 'Load3' etc.

Can I write e.g. LoadX or String.Format("Load%d",x), etc?

Bit of a stretch but I thought someone might have a solution for runtime symbol names.
#156
I *have* gotten them working, but problems remain.
The two main ones are:

1. Savegame screenshots are slow by one; when you save the first screenshot it's blank; the second, it has the first one's screenshot; and so on.

2. I can't figure out how to close the gSaveLoad dialog when a save is restored. Despite the fact that the diaog is never visible when the game's doing it's saving, the dialog refuses to disappear when the game is restored.

code:

globalscript.asc:
Code: ags
DynamicSprite *buttonSavePic1;
DynamicSprite *buttonSavePic2;
DynamicSprite *buttonSavePic3;
DynamicSprite *buttonSavePic4;


function ShowSaveGUI() {
  
  buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 171, 96);
  if (buttonSavePic1 != null) {
    buttonLoad1.Visible=true;
    //LabelLoad1.Visible=true;
    LabelDescr1.Text=Game.GetSaveSlotDescription(1);
    buttonSaveSlot1.NormalGraphic = buttonSavePic1.Graphic;
    buttonSaveSlot1.Visible=true;
  }  
  buttonSavePic2 = DynamicSprite.CreateFromSaveGame(2, 171, 96);
  if (buttonSavePic2 != null) {
    buttonLoad2.Visible=true;
    //LabelLoad2.Visible=true;
    LabelDescr2.Text=Game.GetSaveSlotDescription(2);
    buttonSaveSlot2.NormalGraphic = buttonSavePic2.Graphic;
    buttonSaveSlot2.Visible=true;
  }  
  buttonSavePic3 = DynamicSprite.CreateFromSaveGame(3, 171, 96);
  if (buttonSavePic3 != null) {
    buttonLoad3.Visible=true;
    //LabelLoad3.Visible=true;
    LabelDescr3.Text=Game.GetSaveSlotDescription(3);
    buttonSaveSlot3.NormalGraphic = buttonSavePic3.Graphic;
    buttonSaveSlot3.Visible=true;
  }  
  buttonSavePic4 = DynamicSprite.CreateFromSaveGame(4, 171, 96);
  if (buttonSavePic4 != null) {
    buttonLoad4.Visible=true;
    //LabelLoad4.Visible=true;
    LabelDescr4.Text=Game.GetSaveSlotDescription(4);
    buttonSaveSlot4.NormalGraphic = buttonSavePic4.Graphic;
    buttonSaveSlot4.Visible=true;
  }
  
  gSaveLoad.Visible = true;
}


// SAVE gSaveLoad save button functions

function buttonSave1_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("SLOT #1 @%02d:%02d:%02d %02d:%02d:%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(1, SaveDesc);
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 171, 96);
  Wait(GetGameSpeed()*1);
  
  if (buttonSavePic1 != null) {
    buttonSaveSlot1.NormalGraphic = buttonSavePic1.Graphic;
    buttonSaveSlot1.Visible=true;
    buttonLoad1.Visible=true;
    //LabelLoad1.Visible=true;
    LabelDescr1.Text=Game.GetSaveSlotDescription(1);
  }
  
  gSaveLoad.Visible=true;
}
function buttonSave2_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("SLOT #2 @%02d:%02d:%02d %02d:%02d:%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(2, SaveDesc);
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic2 = DynamicSprite.CreateFromSaveGame(2, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic2 != null) {
    buttonSaveSlot2.NormalGraphic = buttonSavePic2.Graphic;
    buttonSaveSlot2.Visible=true;
    buttonLoad2.Visible=true;
    //LabelLoad2.Visible=true;
    LabelDescr2.Text=Game.GetSaveSlotDescription(2);
  }
}
function buttonSave3_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("SLOT #3 @%02d:%02d:%02d %02d:%02d:%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(3, SaveDesc);
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic3 = DynamicSprite.CreateFromSaveGame(3, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic3 != null) {
    buttonSaveSlot3.NormalGraphic = buttonSavePic3.Graphic;
    buttonSaveSlot3.Visible=true;
    buttonLoad3.Visible=true;
    //LabelLoad3.Visible=true;
    LabelDescr3.Text=Game.GetSaveSlotDescription(3);
  }

}
function buttonSave4_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  
  DateTime *dt = DateTime.Now;
  String SaveDesc=String.Format("SLOT #4 @%02d:%02d:%02d %02d:%02d:%04d",dt.Hour, dt.Minute, dt.Second, dt.DayOfMonth, dt.Month, dt.Year);
  SaveGameSlot(4, SaveDesc);
  
  aCameraSnap.Play(eAudioPriorityNormal, eOnce);
  buttonSavePic4 = DynamicSprite.CreateFromSaveGame(4, 171, 96);
  Wait(GetGameSpeed()*1);
  gSaveLoad.Visible=true;
  
  if (buttonSavePic4 != null) {
    buttonSaveSlot4.NormalGraphic = buttonSavePic4.Graphic;
    buttonSaveSlot4.Visible=true;
    buttonLoad4.Visible=true;
    //LabelLoad4.Visible=true;
    LabelDescr4.Text=Game.GetSaveSlotDescription(4);
  }

}



// LOAD  gSaveLoaad load button functions

function buttonLoad1_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(1);
  GameJustRestored=1;
}
function buttonLoad2_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(2);
  GameJustRestored=2;
}
function buttonLoad3_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(3);
  GameJustRestored=3;
}
function buttonLoad4_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(4);
  GameJustRestored=4;
}



// click save icon in giconbar
function btnIconSave_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  gIconbar.Visible = false;
  mouse.UseModeGraphic(eModePointer);
  ShowSaveGUI();
}
// click load icon in gIconbar
function btnIconLoad_Click(GUIControl* control, MouseButton button) 
{
  gPanel.Visible=false;
  gIconbar.Visible=false;
  gSaveLoad.Visible=true;
  mouse.UseModeGraphic(eModePointer);
}


#157
Solved it - I named the buttonSavePic1 after a GUI element. I'll go and shoot myself now.

btw: should I have GlobalScript at the bottom of the tree?
#158
I put ShowSaveGUI() only in a new script called 'testsaveload', deleted it from GlobalScript.asc, ran it with F5, and now it's telling me the same "Local variable cannot have the same name as an import" on the same first line of function.
(and it's on top of all scripts)
#159
Nope.
#160
Nowhere else - all in ShowSaveGUI().
SMF spam blocked by CleanTalk