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 - Dor Hajaj

#1
Exactly what I wanted!
Works great!
A super thanks to you Khris  :smiley:
#2
Thank you for your help.

Maybe I can further elaborate what I tried to do, because given the mentioned restrictions I don't think what I tried to do can work.
I'm trying to create a notebook, that when important information is discovered by the player, that data will be "written" to the notebook.
For that I tried to use a GUI with a listbox, so I can use the listbox.AddItem(), and add new items.
Of course, the problem is not adding the same thing twice.
So how do I check if a value exists before adding?
#3
Hi,
What am I doing wrong in the following?

In GlobalScript.asc I have this function:
Code: ags

bool IsItemInList(String[] itemList, String itemName)
{
  for(int i=0; i< itemList.Length; i++)
  {
    if(itemList[i] == itemName)
      return true;
  }
  return false;
}


In GlobalScript.ash:
Code: ags

import bool IsItemInList(String[] itemList, String itemName);


I'm getting:
"Failed to save room room301.crm; details below
GlobalScript.ash(23): Error (line 23): PE02: Parse error at 'itemList'"

Why room 301? What's the connection to the function I added?
I use the function in other rooms but not in 301.

Thank you!
#4
Hi,
Just updating that the latest code by morganw + the string append fix worked.
:-D

Thank you!
#5
Thank you all for you valuable advices!
I'm still trying to figure this thing out...

Quote from: morganw on Tue 11/12/2018 22:18:16
I imagine the goal of this is to pick 3 unique items from the array, so I thought I'd give it a try as there didn't seem to be an easy or obvious solution. Is there any better way than this, if the array values aren't used elsewhere?
Code: ags

String GetEditorExpectations(int count)
{
  String interviewExpectations[];
  
  interviewExpectations = new String[EXPECTATION_COUNT];
  interviewExpectations[0] = "Aggressive";
  interviewExpectations[1] = "Emotional";
  interviewExpectations[2] = "Fictional";
  interviewExpectations[3] = "Friendly";
  interviewExpectations[4] = "Informative";
  interviewExpectations[5] = "Interesting";
  interviewExpectations[6] = "Intrusive";
  interviewExpectations[7] = "Personally Viewed";
  interviewExpectations[8] = "Tabloid";
  interviewExpectations[9] = "Thrilling";
  
  return ChoosePhrase(interviewExpectations, count, 1);
}


morganw, That's a really lovely piece of code!
I tried using your code - but I get a compilation error : "GlobalScript.asc(78): Error (line 78): Expected array index after 'interviewExpectations'" -  which point to the end of the GetEditorExpectations() function (line 17 on the shortened quote I attached)

About the general idea - The expectations, are supposed to be used later when the player completes the mission, each type of expectation is given a score(I save them on a different array and compare by the indexes).
When the player performance is judged, I take the story(as the player is a journalist) expectations, and check whether the player reached the minimum score for each of them.


#6

1. EMAILInteraction() is called.
2. The last if statement, is a part of a longer function. At some point the if is true and what's inside runs. The problem is that the string is empty after the GetEditorExpectationsInTextFormat() call.


Code: ags



bool interviewExpectations[10];


function InitEditorExpectations()
{
  //init the array
  for(int i=0; i < 10; i++)
  {
    interviewExpectations[i] = true;
  }
}


String GetEditorExpectationsInTextFormat()
{
  String expectations = "";
  if(interviewExpectations[0] == true)
    expectations = expectations.Append("Aggressive, ");
  if(interviewExpectations[1] == true)
    expectations = expectations.Append("Emotional, ");
  if(interviewExpectations[2] == true)
    expectations = expectations.Append("Fictional, ");
  if(interviewExpectations[3] == true)
    expectations = expectations.Append("Friendly, ");
  if(interviewExpectations[4] == true)
    expectations = expectations.Append("Informative, ");
  if(interviewExpectations[5] == true)
    expectations = expectations.Append("Interesting, ");  
  if(interviewExpectations[6] == true)
    expectations = expectations.Append("Intrusive, ");    
  if(interviewExpectations[7] == true)
    expectations = expectations.Append("Personally Viewed, ");
  if(interviewExpectations[8] == true)
    expectations = expectations.Append("Tabloid, ");     
  if(interviewExpectations[9] == true)
    expectations = expectations.Append("Thrilling, ");
  return expectations;
}
function SetEditorExpectations()
{
  int rand = Random(9);
  
  switch(rand)
  {
    case 0:
    interviewExpectations[0] = true;
    break;
    case 1:
    interviewExpectations[1] = true;
    break;
    case 2:
    interviewExpectations[2] = true;
    break;
    case 3:
    interviewExpectations[3] = true;
    break;
    case 4:
    interviewExpectations[4] = true;
    break;
    case 5:
    interviewExpectations[5] = true;
    break;
    case 6:
    interviewExpectations[6] = true;
    break;
    case 7:
    interviewExpectations[7] = true;
    break;
    case 8:
    interviewExpectations[8] = true;
    break;
    case 9:
    interviewExpectations[9] = true;
    break;
  }
}



function EMAILInteraction()
{
  cEgo.ChangeRoom(67);
  CurrentRoom = 67;
  OutputBox.Visible = false;
  BBCOutputBox.Visible = true;
  BBCOutputBox.Text = "Electronic Messaging System:[1.Incoming[2.Outgoing(currently unavailable)";
  if(editorHasSentExpectations)
  {
    InitEditorExpectations();
    SetEditorExpectations();
    SetEditorExpectations();
    SetEditorExpectations();
  }
}



if(TextBox1.Text == "1")
{
      BBCOutputBox.Text = "Retrieving information...";
      Wait(100);
      if(editorHasSentExpectations)
      {
        String expectations = GetEditorExpectationsInTextFormat();
        if(expectations.Length > 0)
        {
          BBCOutputBox.Text = String.Format("The story is expected to be:",expectations);
          WriteToFile(expectations, "editor_Expectations.txt");
        }
      }
}



#7
1) Yes. I also debugged and made sure it does.
2) Everything is done in the GlobalScript. I didn't export anything, I just stated the array like the code snippet shows(was I supposed to?)
3) Yes.
4) I meant there are a couple of more If statements that follow, didn't want to trouble the readers :)

I really appreciate the help!
#8
Well, the code is basically the same as I posted in the original post, plus the fix for the string appending error I did.
So:

I have a Boolean array that should represent a certain desired state for the player.
Some of the cells will be false, some will be true depending on the situation.
For the sake of understanding what am I doing wrong, I set them all to be true.
Now, on the GetEditorExpectationsInTextFormat() function I would like to generate a string representation of the desired state.
So for each cell in true state, add something to a string. In the end return the string.
What I meant is, that despite the entire array set as true, none of my If statements are considered true, so nothing happens.

Code: ags

bool interviewExpectations[10];
 
function InitEditorExpectations()
{
  //init the array
  for(int i=0; i < 10; i++)
  {
    interviewExpectations[i] = true;
  }
}
 
String GetEditorExpectationsInTextFormat()
{
  String expectations = "";
  if(interviewExpectations[0] == true)
    expectations.Append("Aggressive, ");
  if(interviewExpectations[1] == true)
    expectations.Append("Emotional, ");
  if(interviewExpectations[2] == true)
    expectations.Append("Fictional, ");
  if(interviewExpectations[3] == true)
    expectations.Append("Friendly, ");
  ....
  return expectations;
}

Thanks
#9
Well sorry, but I'm still facing the same issue.
My string append usage was wrong, but I'm still unable to understand why the if expression is skipped at run time.
For example:
Code: ags

 String expectations = "";
 interviewExpectations[0] = true;
 if(interviewExpectations[0] == true)
   expectations = expectations.Append("Aggressive, ");

Hope you can help me!
#10
Hi,
Sorry this is really dumb one.
But it's freaking me out!
What could be the reason for the if statements in the GetEditorExpectationsInTextFormat() function not to be interpreted as true?
Code: ags

bool interviewExpectations[10];

function InitEditorExpectations()
{
  //init the array
  for(int i=0; i < 10; i++)
  {
    interviewExpectations[i] = true;
  }
}

String GetEditorExpectationsInTextFormat()
{
  String expectations = "";
  if(interviewExpectations[0] == true)
    expectations.Append("Aggressive, ");
  if(interviewExpectations[1] == true)
    expectations.Append("Emotional, ");
  if(interviewExpectations[2] == true)
    expectations.Append("Fictional, ");
  if(interviewExpectations[3] == true)
    expectations.Append("Friendly, ");
  ....
  return expectations;
}


Thank you!
#11
Quote from: tzachs on Sat 04/08/2018 04:47:24
In terms of best way to clear the inventory, the first question to ask is: are you sure you want to clear the inventory on EVERY inventory interaction? What most games do is clear the inventory after a meaningful interaction with this item when you no longer need it (because if a player wants to try an inventory item on a bunch of places in the room, it's annoying to reselect it every time).
If you don't need it on every interaction you can create a function with the 3 lines (clearing the inventory item and label) and call it from the use inv function (and every meaningful interaction).
If you do want to clear it every time, then one way of doing this would be to wait a frame before clearing the inventory item.
Try adding "Wait(1)" inside the if before clearing the inventory item.

Well explained!
I think you are correct and clearly I did not give this enough thought. I'll go with the meaningful interaction way.
Can you explain a bit more, what will the Wait(1) achieve? It blocks the game for 1 cycle right?
#12
The break point fires.
Looks like the PrcoessClick() runs(and does whatever it does), and then the if statement goes into play and causes the inventory item to be null, which in turn makes the use inventory on something function useless.
What I was trying to ask, let's ignore the code I wrote which does not work, what is the best way the perform an inventory item action on something and clear the mouse, so the inventory item does not remain active after the player used it?
#13
Basically yes.
This is how it looks at the moment:

The mouse does not change its icon according to the inventory item selected. Instead, I use the label to indicate the item name.
When the player makes the interaction I would like to clear the field and set the active inventory item to null.
What I have at the moment is the option to do so by clicking the right mouse button, so it happens AFTER the actual Use_Inv event and there is no problem.
When I try to do this as part of the left click event, by the time the Use_Inv function is called the active item is null, and nothing happens.
#14
Hi,

I'm trying to achieve the following:
1. Select an item from inventory
2. Left click to use inventory on something
3. Restore normal mouse mode

So, when the player clicks on an inventory item, I use a label attached to the mouse that shows the item name.
After the left click I would like to clear the label and restore the mouse back to the previous mode(interact).

I've tried this in GlobalScript:
Code: ags

else if (button == eMouseLeft) {
      ProcessClick(mouse.x, mouse.y, mouse.Mode);
      if(mouse.Mode == eModeUseinv)
      {
        player.ActiveInventory = null;
        gActiveItemText.Visible = false;
        activeItemText.Text = " ";
      }

But the active inventory item is null when the Use_Inv function is called.

Thanks!
#16
But description is not a custom property.
I have this inventory item:

I would like to change the description on at times through the code.
The manual states:
Quote
SetTextProperty (inventory)
bool InventoryItem.SetTextProperty(const string property, const string value)

Sets the new value text for the custom property for the specified inventory item. Returns TRUE if such property exists and FALSE on failure.
This command works with Text properties only. The property's text will be changed to new value.

Use the equivalent SetProperty function to set a non-text property.

Example:

iKey.SetTextProperty("Description", "A rusty key");

will change key's "description" property.
Compatibility: Supported by AGS 3.4.0 and later versions.

See Also: InventoryItem.SetProperty

So it's just a coincidence that the 'Description' property is stated there? this property value is inaccessible in run time?
#17
Hi,

Can you explain why the following does not work?
Code: ags

iMoney.SetTextProperty("Description", final);

I'm getting an error stating that there is no such property in the schema.
I've looked at the manual, and the function is used in the same way.
Thank you.
#18
Critics' Lounge / Combat interface
Sat 09/06/2018 23:25:05
Hi Everyone!

I was working on a combat system for my game recently, and would very much like to get your feedback.
The general idea was to have something you experience from first person perspective(different from the normal game view), but to keep the action not to rough.

You have several options:
Attack, Take Cover, Move in, Move out, Reload
each of those is operated by a designated key on the keyboard.
Your enemy does basically the same, fires at you, takes cover, and moves closer to you.

I did not implement any aiming(I would like an advice about that) as I felt it was too much for the common adventure game player. Instead, the player has a certain skill(I still don't how it will be determined), plus getting closer to your enemy improves your chances to hit(and also the enemy's).
You cannot fire when in cover, and the enemy cannot hit you. Goes the same for the enemy.

Some screenshots:

Enemy exposed, player in cover

player exposed, firing at exposed enemy

Both sides hit each other at the same time

Enemy in cover(unseen)

Thanks!
#19
First of all, thank you all for the replies.

I got a bit confused. I'm using AGS for quite sometime now, but never really gave this issue any thought, i just minimized the walkable area so the character will avoid situations like this one.
It just got a bit annoying to redraw the walkable area a couple of times until I got it right.
To conclude this, what will be the best approach in your opinion?
Make sure the character's feet touch the bottom edge of each frame, or to minimize the walkable area as much as possible like I did until now?
#20
Hi,

Can anyone explain why and how the following occurs?
the walkable area does not include the brick walls yet the character stands on the wall well above the walkable area. Does it have to do with the char's baseline?
Thanks!

SMF spam blocked by CleanTalk