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

#521
Beginners' Technical Questions / Re: add value
Mon 17/11/2014 02:07:18
Goddammit. :)

Oh well, it is very too late here in italy, i should go to sleep now.
Tomorrow I MUST test your advice. AND, i really think that the problem it is like that !!! ;-D

Thank youuu again very much, Gurok ^^

Quote from: Gurok on Mon 17/11/2014 00:23:10
There are a couple of things you haven't eliminated.

Maybe i just realize it, i will let you know tomorrow by posting the result here ^^
Ciao, Buona notte
#522
Beginners' Technical Questions / Re: add value
Mon 17/11/2014 01:03:50
Ciao Gurok, oh well :) i got this !

Code: ags

 // 1: health = 0, recover_energy = 5
 protagonista.health += oggetto[Chips].recover_energy;
 // 2: health = 5



after doing this "operation" the labeldescription show always that protagonista.health is 90 (how i set it in the game start)
NOTE: the labeldescription is unique. and it work for every information when the mouse is over something.
So i'm updating the label like this

Code: ags

Gui*g = Gui.GetAtScreenXY(mouse.x, mouse.y);
if (g == glifebar)
{
  labeldescription.Text = String.Format("Health %d %", protagonista.health);
}



Yes, Displaying the variables was helpful ^^ Thank you :)
But i still dunno how to solve this :-\


If i just do something like this
Code: ags

protagonista.health += 5; 

That work fine. On (UseInv on character) or (rep_ex). And the labeldescription show 95 !
I'm wonder why when i use the item on the character the Display show health 0, then, health 5 but the labeldes show 90 :)
#523
Let's say that you have created your inventory item in the node tree, and you rename it : iGiantKey1
Then you can choose if the player start with that item when the game first start
(but this is optional, not to solve this issue)
After this, you interact with your object.
By doing this the object become not visible and the player add the Inventory item, of course, not the object.
So then, where you want to store it ?
In an InventoryWindow i guess.
Just create a Gui. Inside of it add an InventoryWindow.

All you need is to read the dynamic helps. You can check the dynamic helps inside AGS by pressing F1
#524
Okay :)

Did you create the Inventory item ?

To create a new item, right-click on the "Inventory items" node in the tree.

Change the script name of the item, call it :

iGiantKey1

Then, when you interact with the object :
Code: ags

function oGiantKey1_Interact()
{
oGiantKey.Visible = false;
player.AddInventory(iGiantKey1); //add the inventory item
}


#525
Oh well, good luck then, you're welcome ~
#526
Why the @#[* you are not creating an inventory item in the editor ?! :)

From the Manual :

Every inventory item which the player may carry during the game at one time or another is listed under the "Inventory items" node. Here, each item has a number and a script name which you use in scripts to identify the object. To create a new item, right-click on the "Inventory items" node.


The script then should look like something like this.

Code: ags

function oGiantKey1_Interact ()
{
oGiantKey.Visible = false;
player.AddInventory(iGiantKey1); //add the inventory item
}
#527
Beginners' Technical Questions / Re: add value
Sun 16/11/2014 22:27:34
Ciao Gurok, thanks for answering.


Quote from: Gurok on Sun 16/11/2014 21:59:13
How do you know it doesn't work?

Well i know that doesn't work by cheking in rep_ex the formatting string :
Code: ags

LabelDescription.Text = String.Format("Health %d %", protagonista.health); 


When i try to add that value to protagonista.health it remain unvariable.
Code: ags

protagonista.health += oggetto[Chips].recover_energy; // <---- this doesn't work.



Firstly, this interaction was under the Useinv on character function (the default one by AGS),
but for tasting again i moved the entire script on rep_ex and nothing (roll)


Quote from: Gurok on Sun 16/11/2014 21:59:13
Do you get an error message?
Nope, any of them when i compile the game. Everything fine :-\
#528
Beginners' Technical Questions / add value
Sun 16/11/2014 17:56:15
Good evening to all AGSer folks.

For the reason that there's not a forum below the beginner section, i will post it here.
I already found a million threads in the forum about this.
But i dunno why still doesn't work,
the evidence sometimes makes bad jokes.
Can someone please enlighten me ? :-\

i simply need to add a value from an integer to another integer.

Code: ags

// 'Mechanics' ASH Script

enum eItems
{
  Chips // potato chips
};


struct Main_Player
{
  float inv_weight;
  short health, money;
  bool IsDead;
};

struct Items 
{
  String name, type;
  float weight;
  short index, count, recover_energy, sprite;
  bool IsCookable;
};


// 
import function init_item();


// import section
import Items oggetto[1000];
import Main_Player protagonista; 



// 'Mechanics' ASC Script
Main_Player protagonista;
Items oggetto[1000];
export oggetto, protagonista; // the export section is at the very end...

function init_item()
{
  /////////////////////////////////// POTATO CHIPS
  oggetto[Chips].index = Chips; 
  oggetto[Chips].sprite = 71; // POTATO CHIPS
  oggetto[Chips].type = "Food";
  oggetto[Chips].name = "Potato Chips";
  oggetto[Chips].recover_energy = 5;
  oggetto[Chips].IsCookable = false;
  oggetto[Chips].weight = 0.5;
  oggetto[Chips].count = 1;
} 


// 'GlobalScript' ASC Script
Main_Player protagonista;
Items oggetto[1000];
export oggetto, protagonista; // 

function game_start() 
{
  init_item(); // calling this work 

  // Set Up Player // This part too
  protagonista.health = 90; // testing chips
  protagonista.inv_weight = 5.5;
  protagonista.IsDead = false;
  protagonista.money = 0;
}


function Repeatedly_execute()
{
  GUIControl *c = GUIControl.GetAtScreenXY(mouse.x, mouse.y); // not used yet
  GUI *g = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (g == gLifeBar)
  { LabelDescription.Text = String.Format("Health %d %", protagonista.health); }
  else 
  {
    Labeldescription.Text = "";
    Label *l = gDescription.Controls[0].AsLabel;
  }
}

// use inventory on main character
function cCharacter_UseInv()
{
    if (mouse.IsButtonDown(eMouseLeft))
    {
      if (player.ActiveInventory == iChips && protagonista.health < 100)
      {
        protagonista.health += oggetto[Chips].recover_energy; // <---- this doesn't work.
        // player.SayBackground("Nice chips");
        player.ActiveInventory = null;
      }
      else if (player.ActiveInventory == iChips && protagonista.health > 95)
      {
        // player.SayBackground("I am full");
        player.ActiveInventory = null;
      }
    } 
  }
}



basically, in this room test, there is nothing apart of this piece of script..

:EDIT: yes, and i added the function Repeatedly_execute just after the game_start for tasting the label.
#529
Beginners' Technical Questions / Re: Tiredness
Sat 15/11/2014 22:21:26
Quote from: monkey_05_06 on Sat 15/11/2014 18:01:58
Glad you got it working! :)
Yeah, me too.

Quote from: Vincent on Mon 10/11/2014 21:08:00
I was building a function that is used to calculate the tiredness of the main character when he tries to perform a run.
And to calculate the opposite, when he is not moving (so that can recover his energy).
Yes, the intention was only to do that, the animation player part was a testing purpose


Quote from: Vincent on Tue 11/11/2014 01:51:08
I tried so far a better logic to implement on this function.
Ehm, looking at the script and then go back to the top of it, don't seems so.
Code: ags

int run_counter = 0, recover_counter = 0;


Quote from: monkey_05_06 on Sat 15/11/2014 10:14:01
|-- * then check if run_counter is less than or equal to 5 (always true, since you know that it's 0)

;-D


Quote from: monkey_05_06 on Sat 15/11/2014 10:14:01
The problem (as I see it) is that you're treating the loss of energy and the recovery of energy as two separate, totally unrelated things.
Quote from: monkey_05_06 on Sat 15/11/2014 10:14:01
Planning out what you're going to do before you start typing code can help you see and prevent logic errors like you currently have in your code (e.g., checking the value of a variable you just set!).

:)


Quote from: Vincent on Sat 15/11/2014 14:33:51
but i could not call this current function abcdefg() and to check if the player HasExplicitTint ?
Specifically, a bull_s_ hit.


Quote from: monkey_05_06 on Sat 15/11/2014 18:01:58
I can assure you that when you come back to this code in a year or two, your future self will greatly appreciate the few extra seconds you spent typing out the more elaborate/explicit names. 8-)
Ciao Monkey_05_06, Thanks so much for everything.


Quote from: Anpiel on Sat 15/11/2014 01:05:48
This is awesome! My girlfriend and I were talking about something stamina related and now we have something like that!
Quote from: Vincent on Sat 15/11/2014 07:00:16
Nice, thank you
But this is just a testing that i was doing for myself.
Absolutely nothing outstanding, rather.
#530
Beginners' Technical Questions / Re: Tiredness
Sat 15/11/2014 14:33:51
Ciao monkey_05_06

Thanks so much for answering back, I appreciate it.
Well, the second time I tried to write the function is definitely less illogical than the first one ;-D, I assume.
Because at least it was working as I bear in mind (broken logic (or not)) but people do not work like that.


I added the function that you build for me in my block notes.
I tested and adapted it to my requests into the testing room, and it work just like a charm !
Also needless to say, but just to confirm it.


I'm still a beginner AGSer and I learn every day.
Thanks for showing me the right way.


ps:
the only thing that I still have to figure out in your post is as follow:
Quote from: monkey_05_06 on Sat 15/11/2014 10:14:01
I'll also mention that using a name like "Update_Runtoolbar" when you're changing other things like the player's animation speed is a very bad idea, which is why I renamed the function.

I am a lover of perfectionism too, but i could not call this current function abcdefg() and to check if the player HasExplicitTint ?
#531
Beginners' Technical Questions / Re: Tiredness
Sat 15/11/2014 07:00:16
Nice, thank you
#532
Oh well, or if you just miss this part from the manual :)

Global Variables


If you just need to store some information locally (for example, a "door opened" flag that only applies to one particular room)
then you should declare the variable manually at the top of the room's script file instead.


How do I use global variables ?

Code: ags

if (myVariable == 3)
{
  myVariable = 4;
}
#533
Quote from: evildustmite on Wed 12/11/2014 13:42:49
I only want this to happen once.

booleans

Code: ags

bool first_time = true;
function region1_WalksOnto()
{
  int Flash; 
  Flash = 1;
  
  if (Flash > 0 && first_time)
    {Wait(40);  //waits 1 second  
    oWindowFlash.Visible = true;//turns on flash
    Wait(5);                    //waits(keeps flash on for 1/8th of a second
    oWindowFlash.Visible = false; //turns flash off
    first_time = false;
    // Flash = 0;
   }
   // {Flash --; //subtracts 1 from variable Flash
  }
  
}
#534
Indeed, the code was not to solve the problem at all, only showing you the proper order to do something alike..
Quote from: Junkface on Sun 09/11/2014 00:59:56
Is there some command I should be running in order for the character to update its graphic?
I'm glad that in one way or another you've solved this.
Salute
#535
Beginners' Technical Questions / Re: Tiredness
Tue 11/11/2014 01:51:08
Ciao monkey_05_06.

I tried so far a better logic to implement on this function.
On reflection, I thought it is not necessary a while expression.
Your help was very useful. Please, feel free to correct me if you see something wrong.
And of course, if you want.


Code: ags

#define RUN_THRESHOLD 240
#define RECOVER_DELAY 240

int run_counter = 0, recover_counter = 0;
bool ModeWalk, ModeRun;

function Update_Runtoolbar()
{
  if (ModeRun && player.Moving) // Lose energy if player move in ModeRun
  {
    run_counter ++;
  }
  else if (run_counter > 0) run_counter --;
  
  if (run_counter > RUN_THRESHOLD)
  {
    run_counter = 0;
    if (run_counter <= 5)
    {
      if (gRunToolbar.BackgroundGraphic == 56) { gRunToolbar.BackgroundGraphic = 57; } 
      else if (gRunToolbar.BackgroundGraphic == 57) { gRunToolbar.BackgroundGraphic = 58; } 
      // ETC ETC
    }
   }
  // Recover energy if player stands still
  if (!player.Moving || ModeWalk) { recover_counter ++; }
  else if (recover_counter > 0) recover_counter --;

  if (recover_counter > RECOVER_DELAY)
  {
    recover_counter = 0;
    if (recover_counter <= 5)
    {
      if (gRunToolbar.BackgroundGraphic == 57) 
      { gRunToolbar.BackgroundGraphic = 56; player.AnimationSpeed = 3;} 
      else if (gRunToolbar.BackgroundGraphic == 58) 
      { gRunToolbar.BackgroundGraphic = 57; player.AnimationSpeed = 5; }
      // ETC ETC
    }
  }
}


I managed to make it work as i wished.:-D HAPPY !
But it was because of you that have made me think further.
I can go to sleep now, :-D 02:48 am here
#536
Beginners' Technical Questions / Re: Tiredness
Mon 10/11/2014 22:47:41
Thank You Very Much monkey_05_06.

I have to focus firstly on a better logic, that has a meaning at least :-D
I'm reading and reading your comments again. They are vital help.
Thanks also for having responded me.
I'm going to fix this "logic", then I'd love to let you see.
Still Big Thanks :)
#537
Beginners' Technical Questions / Tiredness
Mon 10/11/2014 21:08:00
Good evening to all AGSer.

I was building a function that is used to calculate the tiredness of the main character when he tries to perform a run.
And to calculate the opposite, when he is not moving (so that can recover his energy).
I can get everything working except for one step.
gRunToolbar change his graphic so quickly.
I tried out different ways but i can't make it work as i wish (slowly)
Someone could help me out here ? I have something like this.

Code: ags


bool ModeWalk, ModeRun;
int tiredness, time = -1; // time that detain the player is not moving

function Update_Runtoolbar()
{
  if (ModeRun && player.Moving) // running
  {
    tiredness += 1;
    if (tiredness >= 30 && gRunToolbar.BackgroundGraphic == 56) gRunGraphic.BackgroundGraphic = 57; // start growing
    // etc etc
  }
  else 
  {
    if (!player.Moving && tiredness >= 10) // should mean that he was running before...
    {
      time += 1;
      if (time >= 40) 
      {
        int time_recover = 0; 
        while(time_recover <= 30)
        {
          time_recover ++; // start recover energy
          // here is the problem, too much quickly change graphic. 
          // i tried lately here to put a SetTimer... but with no lucky at all
          if (gRunToolbar.BackgroundGraphic == 57 && IsTimerExpired(1)) // i though a timer was the ideal here
          // but doesn't work...
            { gRunToolbar.BackgroundGraphic = 56; } // go back the graphic for recover
          // etc etc
          tiredness -= 1;
        }
          if (tiredness < 29) time = 0; time_recover = 0; // send everything to back
      }
    } 
  }
} 



Why the SetTimer does not work for what I'm trying to do ? :-\
It's very likely that I'm doing it in worst way possible.
I am aware of...
#538
Advanced Technical Forum / Re: Zooming
Mon 10/11/2014 14:57:57
Certainly.
If you need to perform such operations like this, doubtless, you must need float numbers.
Their are the best choice.

Code: ags

float zoom = 1. ; 
// lens = lens * zoomFactor (God bless you) 


Thanks Snarky for the suggestion, I'll keep it in mind.
#539
Advanced Technical Forum / Re: Zooming
Mon 10/11/2014 13:45:14
Quote from: Crimson Wizard on Mon 10/11/2014 13:30:16
Code: ags

    while (lens <= 200) // say for example the double size
    {  
       DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); // HERE
       <do stuff>
       surface.Release(); // HERE
       Wait(1);
       lens ++;
    }


It's amazing how the simplest things I forget anytime. :)
Thanks Crimson Wizard :)

Code: ags

// This can't be put where i did. 
// This is place it, WHILE, the sequence execution.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); 
// And also, of course.
surface.Release();
// Before the waiting performance.
#540
Advanced Technical Forum / Re: Zooming
Mon 10/11/2014 12:46:41
Quote from: Snarky on Mon 10/11/2014 11:52:13
you could always tween it yourself,


Code: ags

// Prompting by a legendary teacher

function Magnifying_Glass (int x1, int y1, int x2, int y2) 
{
   DynamicSprite*ds = DynamicSprite.CreateFromBackground(x1, y1, x2, y2);
   DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();

   int lens = 100, x, y, width, height;
   
   while (lens <= 200) // say for example the double size
    {   
       width = (ds.Width * lens) / 100;
       // height = (ds.Height * lens) / 100; // queer logic ?!

       x = x1 - (width - ds.Width) / 2;
       // y = y1 - (height - ds.Height) / 2; // queer logic ?!

       surface.DrawImage(x, y, ds.Graphic, width, height); // x, y, slot, transparency, width, height
       Wait(1);
       lens ++;
    }
       ds.Delete();
}
SMF spam blocked by CleanTalk