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

Topics - Knox

#61
Hi,

I modified the guiPortrait module a bit and I was wondering if someone had an idea on how to add the speed for blink frames...right now this is ignored, so if I place a delay of 40 on a certain blink frame, the animation ignores it completly. SSH is currently too busy to help me out with this so Ive been trying on my own for a while now...and well...I suck! heheh

I think I have to do something with the ".Speed" command, but Im not too sure how to implement it. To test, if I remove the "Portrait_vf.Speed" part in these lines:
Code: ags
Portrait_Counter = (Portrait_AnimSpeed + Portrait_vf.Speed + 1);
, the script no longer takes into account  the delays in the speech views either, so I believe somehow I need to do something like that, but for the blinking (which I really dont know how to proceed, Ive been trying all night... :-[)

Code: ags

function Portrait_DoFrame() 
{
  Portrait_vf = Game.GetViewFrame(Portrait_View, Portrait_Loop, Portrait_Frame);
  bool flip = Portrait_vf.Flipped;
  // Something like:
  if (Portrait_AutoFlip && Portrait_AtRight) flip =! flip;
  Portrait_Mod = DynamicSprite.CreateFromExistingSprite(Portrait_vf.Graphic, true);
  if (Portrait_BlinkTimer == 0) 
  {
    DrawingSurface *mod = Portrait_Mod.GetDrawingSurface();
    Portrait_bvf = Game.GetViewFrame(Portrait_BlinkView, Portrait_BlinkLoop, Portrait_BlinkFrame);
      
    mod.DrawImage(0, 0, Portrait_bvf.Graphic);
    mod.Release();

    Portrait_BlinkFrame++;
    if (Portrait_BlinkFrame == Game.GetFrameCountForLoop(Portrait_BlinkView, Portrait_BlinkLoop)) 
    {
      Portrait_BlinkTimer = Portrait_BlinkInterval;
      Portrait_BlinkFrame = 0;
    }
  }
  // Flip AFTER blink, if required
  if (flip) Portrait_Mod.Flip(eFlipLeftToRight);
  Portrait_GUI.BackgroundGraphic = Portrait_Mod.Graphic;
}

function repeatedly_execute_always() 
{
  if (Portrait_Counter == 0) 
  {
    Portrait_Frame++;
    if (Portrait_Frame == Game.GetFrameCountForLoop(Portrait_View, Portrait_Loop)) Portrait_Frame = 0;
    Portrait_DoFrame();
    Portrait_Counter = (Portrait_AnimSpeed + Portrait_vf.Speed + 1);
  } 
  else if (Portrait_Counter >= 0) Portrait_Counter--;
  if (Portrait_BlinkTimer > 0) Portrait_BlinkTimer--;   
}

// TBD: Animate
// Check for flipped frames
// Blinking: goes on top of speech view
  
function GSay(this Character*, String what, int view, int loop) 
{
  if (view < 1) view = this.SpeechView;
  Portrait_Frame = 0;
  Portrait_Loop = loop;
  Portrait_View = view;
  Portrait_AnimSpeed = this.SpeechAnimationDelay;
  int positioning = GetGameOption(OPT_PORTRAITPOSITION);
  int x;
  //Left
  if (positioning == 0) Portrait_AtRight = false;
  //Right
  else if (positioning == 1) Portrait_AtRight = true;
	//Alternate
  else if (positioning == 2)
  {
    if (this != Portrait_Last_Talker) Portrait_AtRight =! Portrait_AtRight;
  }
  // Based on Character Position Relation to the Main Player
  else
  { 
    if (this == player)
    { 
      player.SetupCharacterPortrait(playerFaceAnim, playerClothes, playerProp);
      if (BasePortrait_BASE.BackgroundGraphic != 372) BasePortrait_BASE.BackgroundGraphic = 372;       
      if (this.x <= partner.x) Portrait_AtRight = false;
      else if (this.x > partner.x) Portrait_AtRight = true;
    } 
    else if (this == partner)
    {
      //Display("Partner's Clothes being st to: %d", partnerClothes);
      partner.SetupCharacterPortrait(partnerFaceAnim, partnerClothes, partnerProp);
      if (partner == cDispatcherA) BasePortrait_BASE.BackgroundGraphic = 1105;
      else if (BasePortrait_BASE.BackgroundGraphic != 372) BasePortrait_BASE.BackgroundGraphic = 372; 
      
      if (this.x >= player.x) Portrait_AtRight = true;
      else if (this.x < player.x)Portrait_AtRight = false;
    }  
  }
  Portrait_DoFrame();
  if (Portrait_AtRight == true)
  {
    x = (System.ViewportWidth - Game.SpriteWidth[Portrait_vf.Graphic] - Portrait_Right_Indent);
    BasePortrait_FRAME.X = x;
    if (this == player)
    {
      BasePortrait_PLAYERCLOTHES.X = x;
      BasePortrait_PLAYERPROPS.X = x;
    }
    else if (this == partner)
    {
      BasePortrait_PARTNERCLOTHES.X = x;
      BasePortrait_PARTNERPROPS.X = x;      
    }
  }
  else if (Portrait_AtRight == false)
  {
    x = Portrait_Left_Indent; 
    BasePortrait_FRAME.X = Portrait_Left_Indent;
    if (this == player)
    {
      BasePortrait_PLAYERCLOTHES.X = Portrait_Left_Indent;
      BasePortrait_PLAYERPROPS.X = Portrait_Left_Indent;
    }
    else if (this == partner)
    {
      BasePortrait_PARTNERCLOTHES.X = Portrait_Left_Indent;
      BasePortrait_PARTNERPROPS.X = Portrait_Left_Indent;      
    }
  }
		
  Portrait_GUI.X = x;
  Portrait_GUI.Y = Portrait_Sierra_Y;
  BasePortrait_BASE.X = x; //ACL MODIFICATIONS
  BasePortrait_BASE.Y = Portrait_Sierra_Y; //ACL MODIFICATIONS 
  SetGameOption(OPT_PORTRAITPOSITION, Portrait_AtRight);
  BasePortrait_BASE.Visible = true;
  if(BasePortrait_BASE.BackgroundGraphic == 1105 )
  {
    BasePortrait_BASE.LockView(19);
    BasePortrait_BASE.Animate(0, 5, eRepeat, eNoBlock);
  } 
  else BasePortrait_BASE.UnlockView(false);
  BasePortrait_FRAME.Visible = true;
  if (this == player)
  {
    BasePortrait_PLAYERCLOTHES.Visible = true;
    BasePortrait_PLAYERPROPS.Visible = true;
  }
  else if (this == partner)
  {
    BasePortrait_PARTNERCLOTHES.Visible = true;
    BasePortrait_PARTNERPROPS.Visible = true;    
  }
  Portrait_GUI.Visible = true;
  Portrait_Counter = (Portrait_AnimSpeed + Portrait_vf.Speed + 1);
  if (this.BlinkView > 0) 
  {
    Portrait_BlinkTimer = this.BlinkInterval;
    Portrait_BlinkInterval = this.BlinkInterval;
    Portrait_BlinkView = this.BlinkView;
    Portrait_BlinkLoop = 0;
    Portrait_BlinkFrame = 0;
  }
  else Portrait_BlinkTimer = -1;
  this.Say(what);
  BasePortrait_BASE.Visible = false;
  BasePortrait_FRAME.Visible = false;
  if (this == player)
  {
    BasePortrait_PLAYERCLOTHES.Visible = false; 
    BasePortrait_PLAYERPROPS.Visible = false;
  }
  else if (this == partner)
  {
    BasePortrait_PARTNERCLOTHES.Visible = false; 
    BasePortrait_PARTNERPROPS.Visible = false;    
  }
  Portrait_GUI.Visible = false;
  SetGameOption(OPT_PORTRAITPOSITION, positioning);
  Portrait_Counter = -1;
  Portrait_BlinkTimer = -1;
  player.SetupCharacterPortrait(playerFaceAnim, playerClothes, playerProp);
}
#62
Hi guys,

Im not sure if this is a simple one, but seems to me it should be pretty easy.

I looked up view and viewframe but  I didnt seem to find the "x,y" property of a view. Right now Im showing a view over a gui for a custom portrait animation and Id like to change the view's position directly (not creating a new gui, and moving the gui)...is this possible?

The view in question is a series of sprites smaller than the base of the portrait so I dont have to use large sprites for parts that arent animating.

Hope this makes sense, if not I can clarify with pics.
#63
Say I have a function "void updateConfirmBox(int iSpriteTitle, int iSpriteQuestion)"

If this function is kept in my global script, when I start typing the function and add the parenthesis, autocomplete gives me a pop-up of what goes inside "(int iSpriteTitle, int iSpriteQuestion)"...

However, if I place the function in another script and import it into the .ash, I have to write it like this:
Code: ags

import void updateConfirmBox(int, int);


If I try to include the int's name, Ill get an error...so how do I write it in the .ash so I dont get an error--->
Code: ags
(cannot define body of imported function)


Id like it when Autocomplete shows me a pop-up of what goes inside the parenthesis, it doesnt just show "(int, int)", but "(int iSpriteTitle, int iSpriteQuestion)"?

#64
Hi,

Ive got a mouse mode that permits the player to discard items from the inventory. When you click on an item to discard, the screen fades 75% black in 1 second, and then the confirm box GUI opens up over the darkened screen...when the confirm box GUI finally gets closed, everything goes back to its normal lightness, in 1 second.

Right now what Im doing is I have a gui called "gBlack" 1024x768 (the full size of my screen) and I tween its transparency (with the Tween module) on top of everything at 75%, in 1 second...and then I open my confirm box GUI over it (z orders are set so everything is in the right order)...when its time to return everything to normal, I just tween the gBlack GUI back to fully transparent (and then set its visibility to false).

The thing is, it seems kind of slow since Im tweening the GUI "gBlack" (which is a full-screen GUI) over other gui's that have tweened animations running in "eRepeatTween"...I heard somewhere that tweening GUI's can be slow(?)

My question is, is there a better, faster/simpler way of doing this?

I tried "TintScreen" but I can't get it to only tint the screen behind the confirm box GUI...it tints everything :P

ps: Ive got animation going on in the background so Im not sure if saving a darkened version with a dynamic sprite is what Im looking for...I still would like to see the animation going on while everything that is behind the confirm box GUI is 75% darkened.


--the confirm box isnt darkened...what's behind it, is
#65
Hi,

Im currently resizing dynamic sprites with the resize function but I feel the quality seems a bit "choppy" compared to if I did it in photoshop. I know I can just save an additional sprite with the resized one from photoshop, but Id rather save memory by redrawing + resizing than save a 2nd load of sprites, resized.

Is  there a way in AGS to somehow "mimic" the resizing of images in photoshop where it seems its much smoother/blurry than the AGS resize?




**EDIT**
Does this have something to do with this thread?
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41551.0
#66
Hi guys,

I was able to use Calin's AGS Blend plugin to blend 2 alpha sprites together to make a "resume" cursor when my mouse hovers over the resume button in my inventory...it uses the item's cursor sprite and combines it with an arrow + resume text so the player knows he can resume with that item.

Everything is fine up until I try to restore the item's "normal" cursor sprite...so when the mouse cursor is no longer hovering over the resume button, I would like it to "revert" back to the item's normal cursor without the drawn "resume arrow" over it.

Im guessing I need to somehow store the item's cursor image somewhere? Does this mean I need to store copies of all my different item's cursors? (That would suck)...

Im using Calin's plugin so I dont have  to make new "resume" cursors for all the game's inventory items.

Im not too sure how to proceed  :-[
#67
Hi,

Ive got a custom script that shows character expressions (not finished, still debugging):

Code: ags

void showExpression(this Character*, Expressions eExpressionType, Expression_Length eLength, String sSay)
{
  int iView;
  int iBlink;
  int iLength;
  int iDefaultLength;
  bool bIsGamePaused;
  iDefaultLength = Game.MinimumTextDisplayTimeMs;
  
  bIsGamePaused = IsGamePaused();
  
  if (eLength == eShort) iLength = 750;
  else if (eLength == eMedium) iLength = 1500;
  else if (eLength == eLong) iLength = 2500;
  
  previousView = this.GetSpeechView();
  
  if (eExpressionType == eSmile)
  {
    if (this == player)
    {
      //getSpeechView to know which expressions to show depending on what version of Brian...
      iView = 17;
      iBlink = 40;
    }
  }
  else if (eExpressionType == eAhhhh)
  {
    iView = 39;
    iBlink = 40;    
  }
  
  this.SpeechView = iView;
  this.BlinkView = iBlink;
  Game.MinimumTextDisplayTimeMs = iLength;
  
  if (bIsGamePaused == true) UnPauseGame(); //if  the game is paused, unpause so the portrait can close itself...
  
  if (sSay == "") Display("Debug, just show the portrait");
  else player.GSay(String.Format("%s", sSay));
  
  if (bIsGamePaused == true) PauseGame();
  
  Game.MinimumTextDisplayTimeMs = iDefaultLength; //(should be 1000)
  this.restoreSpeechView(previousView);
  
  bIsGamePaused = false; //reset
}


At this line:  
Code: ags
if (sSay == "") Display("Debug, just show the portrait");
, Im not sure what to place so  that if the text to display is "nothing", I just want to show the portrait animation with no text...right now if the text is blank (sSay == ""), no portrait is displayed at all.

Im guessing its something to do with AGS's built-in "say" that wont show the portrait animation if there is no text?
#68
Hi,

Ive never used the drawing functions yet, other then simple stuff when its on a room background.

Ive got a script setup so that when the mouse is over a certain part of the customDialogGui, I want to draw a sprite over it so thats its on top of everything else. This sprite stays on top of everything else until the mouse leaves that area, in which case I would just delete it.

The problem is I dont know how to draw onto this custom gui...I got this working (as a debugging to see if my script logic is ok)...it just doesnt draw on top of the custom gui, it does it on the room's background, behind the customDialogGUI (obviously cause Im not doing the right thing!)

Code: ags

        DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
        surface.DrawImage(0, 100, 1568, 0);
        surface.Release();


I checked the manual on drawing and I have to admit I dont understand it :P...


**EDIT**

OK I found this thread Ill see if it helps:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41116.0
#69
Hi,

I was wondering about something and wanted to get some feedback from you guys on what you think of this:

Ive got a "RediRef" booklet with lots of useful information for proper police procedure/penal + traffic + radio codes/alphabet, etc...and Im trying to decide wether to include this booklet as a PDF/word doc outside of the game, or to implement it as an inventory item that you can actually open up in-game. This booklet is around 110 pages long.

If I were to make it an inventory item in-game, it would  require me to either:
1) make 110 sprites pages on a GUI
2) have an external .txt file read and transfered into text within a gui that accepts text

The main reason why I would like to have the booklet in-game is so that I can add a "search" feature, so a player can do a search on codes/procedures related to "high-risk traffic stop", for example, and it will give you the appropriate page numbers, etc...

The main reason why I wouldnt want to do this booklet in-game is I realize how much work it will take...

In your opinion, is it worth it? Should I just release an external pdf/doc instead?
#70
Hi,

In the manual, I found an entry "Multiple Scripts" which explains that you can break up your Global script into pieces if it starts to get large. Right now mine is about 6000 lines, but this includes many "custom scripts" to manage inventory items, various gameplay elements, etc...

Here is all I could find in that entry that explains what to keep in the GS:
Quote
The main global script still has to contain all the event functions (Look At Character scripts, Interact With Inventory scripts and so forth) and all the GUI handlers (btnSave_Click, etc).

The thing is, Im still not too sure what needs to be in the GS, it just says "and so forth"...for those who have done this already, is it a "trial and error" kind of deal?

"All the event" functions Im not to sure what it means, exactly...GUI handlers, its ok though, I understand that...
#71
Hi,

Im sure this is another simple one, I tried to get the right syntax for this but I cant seem to get it to work. I just want to make the file name in the following line to be a variable. I tried String.Format in conjunction with File.Exists + savegame dir without luck.

This works if I name the actual file name (which I dont want, but to debug, it worked)

Code: ags

if (!File.Exists("$SAVEGAMEDIR$/input.bmp"))


This doesnt work, but what I want (make the filename a variable):
Code: ags

if (!File.Exists(String.Format("$SAVEGAMEDIR$/%s.bmp", input))
{
   stuff....
}


Im guessing Im missing a parenthesis somewhere, or I cant use string.format with file.exists?
#72
Hi guys,

Recently with the help of people here, I was able to get something to work with arrays + pointers. This is what it was:

Code: ags

#define guiAmount         32
GUI* guiList[guiAmount];

(in game start)
  guiList[0] = gPanel; guiList[1] = gHelp; guiList[2] = gSave; guiList[3] = gLoad; guiList[4] = gRestart...etc



I used the same concept with buttons, and it also worked (Button* borderListTct[borderAmount])

How can I use this with a list of bools? This is my list of bools I declared at the top of my global script:

Code: ags

bool bIsGuiOpenA = false;
bool bIsGuiOpenB = false;
bool bIsGuiOpenC = false;
bool bIsGuiOpenD = false;
bool bIsGuiOpenE = false;


I tried this and I get an error:

Code: ags

#define gleamAmount       5 
Bool* gleamList[gleamAmount]; 
(in game start):
gleamList[0] = bIsGuiOpenA; gleamList[1] = bIsGuiOpenB; gleamList[2] = bIsGuiOpenC; gleamList[3] = bIsGuiOpenD; gleamList[4] = bIsGuiOpenE;


The function Im trying to use all that with:
Code: ags

function showGleamType_HideOthers(bool bType)
{
  // first make the type "true"
  if (bType == false) bType = true;

  // second, make all the others false
  int i;
  while (i < gleamAmount) //5 types of gleams (A,B,C,D,E)
  {
    if (bType != gleamList[i])
    {
      if (gleamList[i] == true) gleamList[i] = false;
    }
    i++;
  }
}


Note that "(bool bType)" isnt exactly what I want, Im not sure how to write so that its "one of the elements in the array of gleamList"...which are all bools.

What I want this function to do is set the selected bool to true and all the other ones that are in the list to false... so when I use it, it would look someting like this:

Code: ags

showGleamType_HideOthers(bIsGuiOpenA); //show typeA, hide all other types


Im sure Im almost there...
#73
Hi,

This probably is something very simple once again but I dont understand the "why" of this little "problem":

Currently Im debugging something and I placed these lines in my on_mouse_click in -->  if (mouse.IsButtonDown(eMouseLeft))
Code: ags

    //Display("Mouse Mode:%d", mouse.Mode);
    Display("Click");


It works most of the time except when I get to my menus GUI's (that pause the game when opened). When Im in eModePointer, usually, when I click on the left mouse button I never see the "click" message, nor the other debug message (which gives me the current mouse mode)...I just get no display at all, although if I use the pointer mode in the normal gameplay screen, Ill ge those display messages no prob...

So obviously something in my menus are not letting me see those debug displays when I click on the left mouse button. I really dont know what though, I dont think I did anything different to those menus that would make AGS not able to tell me when the left mouse is being clicked. I noticed if I set the GUI menu flag "Clickable" to "0", it will display those debug messages...so I guess the menu GUI absorbs the click, but how come it wont display my messages?

PS: its not a eMouseLeftInv issue though, its really a leftmouse click issue.

How do I get those display debug messages for left-mouse clicks working like I want to when the mouse is over a clickable menu?
#74
Hi guys,

Ive got a character that is never visible on screen but visible for dialogs (a 911 dispatcher). When the player uses the radio, I placed this at the top of the "send" button's script:

Code: ags
 
  int iPlayerX = player.x;
  if (iPlayerX >= 512) //player is to the right
  {
    cDispatcherA.Move(0, -100); //move DispatcherA to the left
  }
  else if (iPlayerX < 512) //player is to the left
  {
    cDispatcherA.Move(1000, -100); //move DispatcherA to the right    
  }


I figured that by moving the dispatcher character the opposite side of the main player, when they engage in a conversation the portraits speech views would be also opposite each other...however, surprisingly regardless of my above code, the dispatcher's speech portrait is always on  the left, no matter what.

I placed the dispatcher's starting room to "none" and have this code in "on_event" to automatically place the dispatcher character into the room that is being loaded:

Code: ags

void on_event (EventType event, int data)
{
  if ((event == eEventEnterRoomBeforeFadein) && ((data != 0) || (data != 7))) 
  {
    cDispatcherA.ChangeRoom(data, -100, -100);
  } 
}


Sierra-Style portrait location is set to "BasedOnCharacterPosition" in General Settings.

Any ideas why I cant seem to make the dispatcher's speech portrait to display opposite of the player's speech portrait?
#75
Hi,

Im not too sure if this makes sense but now Im at the stage of implementing something probably easy for the most of you but hard for me :P

Ok, right now my savegame saves a screenshot 320x240, but I resize it to 120x90 to fit my button in the previewGUI. I was thinking that when I click on this button, I could "restore" the 320x240 image by simply resizing it "back" to its "original" 320x240 resolution. I was wrong.

Right now it seems resizing is destructive, as in, when I restore the resized image back to its original size, its all pixelated.

Is there a way I can resize a large savegame screenshot, resize it for previewing purposes, but once clicked on, the "full-res" version gets displayed...without having to save 2 versions of the screenshot, of course :P

(ps: I guess as a work-around I might have to save a low-res and hi-res version of each savegame screenshot, right?)
#76
Hi guys,

I currently making it so I save the date+time inside a savegame...here is what I wrote, it works:

Code: ags

function saveWithDateTime(int iTrunc,)
{
  //suffix date+time to savegamefile
  dt = DateTime.Now;
  sSaveGameTextDateTime = String.Format("%s%02d%02d%04d%02d%02d%02d",saveGameText, dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second);
  //Display("%s", sSaveGameTextDateTime);
  iLengthSaveGame = sSaveGameTextDateTime.Length;
  iTruncateNum = (iLengthSaveGame - 14); //length of the savegame input minus the 14 characters of the date + time
  sSaveGameTruncated = sSaveGameTextDateTime.Truncate(iTruncateNum);
  sSaveGameTruncatedUpper = sSaveGameTruncated.UpperCase();
  //Display("%s", sSaveGameTruncatedUpper);
  if (iTrunc == 0) saveGameText = sSaveGameTextDateTime; //means we want the date time saved 
  else if (iTrunc == 1) saveGameText = sSaveGameTruncatedUpper; //means we want to display the name without the date + time
}


The problem I have though is Im like 95% of the way there, and I dont know how to get that last 5%. Where Im stuck is Ive got a way to save the date+time info within the savegame text, and I know how to write a String variable that shows the savegaem name WITHOUT the date+time info...if I use "Display" command.

What I dont know how to do is when I get to this point (lstSaveGames.FillSaveGameList)...how to convert the savegame list (FillSaveGameList) so that I can use the variable to make sure I dont see the date+time : the string that "hides" the date+time info--> String sSaveGameTruncatedUpper

#77
Hi,

I have the exact same question as this person "rich" (check link below), way back in 2005. Its about how to divert keypresses away from a textbox so it can be used to simulate a mouse click instead.

Its for the savegame GUI, I have a savegame button and a textbox. Since the textbox is always visible, when you press the "return" key, the textbox processes the key press, however, Id rather the return key simulates clicking on the "savegame" button on the GUI.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20141.0

"Rich" in the thread above found the solution to the same problem Im having, however, if Im not mistaken, it seems to be pointing to something that is now obselete.

I tried setting the
Code: ags
txtBox.enabled = false 
upon pressing the return key in on_key_press but of course the textbox absorbs that key press before I can disable it so I cant disable the txtBox when the return key is pressed. :P

I have to admit Im not quite sure what function/process I can use to get around this (if its impossible, I can live without it I guess...just would be nice!)
#78
Hi,

Probably another simple 1 question/1 answer deal, but Ive been searching for a solution to this for a while without luck.

Im aware you can simulate mouse clicks within GUI buttons, but what about simulating actual keyboard buttons within GUI buttons? What Im trying to do is I have a button that Id like to simulate the "Backspace" key so that when the player clicks on that button, it will act as if the actual Backspace key was pressed and deletes characters in a text box. I know I can just press the actual "Backspace" key, but Id rather it be called not by pressing the actual keyboard in real life but by clicking the "fake" keyboard button within the GUI I created.

Something like this (which doesnt work, of course):
Code: ags

function btnRadio_Delete_OnClick(GUIControl *control, MouseButton button)
{
  on_key_press(eKeyBackspace);
}


I tried to get around that with the truncate command with the string in the text box, and I guess I can get that to work with a hack but I thought it would be easier to just somehow tell AGS that when that particular button is pressed, pretend it acts like the actual keyboard "backspace" key.
#79
I found this thread about the problem Im trying to solve, and I was wondering if there was any other way, or is this the best way to "replace" Wait() so its non-blocking?

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40783.0

What Im doing is when a player receives damage, the health goes down and I display this change by changing the health bar sprite. Im making the bar go down in increments of 1, so say you lose 5 points, it goes down by 1 bar, 5 times...I decided to use Wait(5), seems to be the nicest wait time between sprite changes. The only down-side to this is that wait blocks, and I see my wait cursor flicker cause its constantly waiting and chaning sprites while in the function's loop. I could just render the cursor invisible duing the short Wait(5), but it would be even better to get around this another way all together.

So what Im asking is...what would some other options be (if any)?

#80
Hi,

I just want to be able to display a player's health in percentage using floats. I tried with int's at first hoping (somehow!) it would convert automatically to a 1 decimal float...anyways, I tried this by placing 1 decimal for my initial floats:

Declared at top of global script:
Code: ags

float playerHealth = 18.0;
float playerHealthPercent = 100.0;

In a custom function:
Code: ags

function playerModifyHealth(float fHealthAmount)
{
  playerHealth = (playerHealth + fHealthAmount);
  playerHealthPercent = ((playerHealth/18.0)*100.0);
}

When player is clicked on:
Code: ags

cEgo.Say("My health is %f percent", playerHealthPercent)


However, the float percentage gets displayed with 6 decimal points...I thought of "truncate" but it seems to be for strings only. Is there a way outside of using a module or converting the numbers to strings to truncate the 6 decimal precision on floats to 1 decimal, as in...95.5%, or 1.5%...?

If not, is there a way to round off the float to the nearest number so that 93.4% would give me 93% ?
SMF spam blocked by CleanTalk