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 - The creature

#1
Code: ags
Function game_start()
{
Listbox_Contacts.AddItem("Contact1");
Listbox_Contacts.SelectedIndex=-1;
}


Function repeatedly_execute()
{
 String CurrentContact = Listbox_Contacts.Items[Listbox_Contacts.SelectedIndex];

If(CurrentContact=="Contact1")
{
gContactGUI.Visible=true;
}
}


The error is: Invalid index specified.
#2
As the post title says: is there a way to have no items selected when a listbox is displayed. By default, the first item is always selected.

I'm sure there is a way as it was asked in the forum a while a go, but I've made a forum search and found nothing and I can't find anything in the manual about having all items deselected.

If I set the selectedIndex to -1 (like it says in the manual) it works. But, in a repeatedly executed I'm selecting items via string names and when I do this I get a compile error

Any help would be great.

Chris.
#3
I'm so so sorry.....words cannot express how sorry I am. My only  excuse is I have been very overworked and have been very tired. So I can only profusely apologize for wasting everyone's time....

I know what the issue is...

My function game_start() was:
function start_game()

I feel very stupid and ashamed. I usually try very hard to research an issue before approaching the forum...

I'm very sorry.
#4
Ok it is null when i added this to the repeatedly execute
Code: ags

If (creature[0].name == null)
{
lStable1.Text ="Null";
}


So that is returning true. But if I set some text to the object's name or leave it blank with just ""; I get that error. So how do I exactly set it so it isn't null because I thought that doing something like:
Code: ags
creature [0].Name="DAVE";
would mean it wasn't null. But even with text in the field and a blank field like this:
Code: ags
creature [0].name="";
still produces the null error.

I've used structs many times and I have never had an error like this....
#5
So the struct is being declared in another script above the Global Script and I'm displaying the information in the repeatedly execute of the Global Script.

The header is:
Code: ags

struct ActiveCreature
{
String Name;
};
Import ActiveCreature creature[6];
#6
Ok, so I'm applying it directly and it's giving me the same error. (Null string supplied to CheckForTranslation).

I get this error regardless of what value I type into the field.

My struct is
Code: ags

ActiveCreature creature[6];
export creature;

Function game_start()
{
creature[0].Name="ffhgsfghh";
}


Code: ags

lStable1.Text = creature[0].Name;


Again, I just can't get my head around this because it's something I've done many times before and never ran into issues.
#7
Hello all

I'm running into a problem that I usually do fine without much thought. I have a struct and I'm trying to display text from it in a label

The error I receive is: formatting argument 1 is expected to be a string, but it is a null pointer.

Interestingly enough if I switch it to display an entry that is a number rather than a string it is fine.

I've displayed text this way before in other projects and have never seen this error before.

My code is:

Code: ags

LStable1.Text=String.Format("%s", readyCreature[0].Name);


When I use other entries from the array I get no issues. Just when I use a text items. And again, I've done it this exact way before in other projects and it's been fine.

I tried modifying the label text using another Struct I made and that displayed correctly...so I have no idea what is going on with that other one...

Total loss.
#8
I would have loved to use this module in my game as it's mostly set under water, From my tests with it it looked great...but as you have described, I ran into the same issues that the module doesn't support. There were a few ideas on how to fix this but they were beyond my coding abilities at the moment.

But if this gets resolved I'll be all over this module. I certainly keep an eye on this thread in the case that someone tweaks the module code to work with interactive/animated room objects.
#9
That's pretty amazing. I'm still getting to grips with while loops but it works a charm and really cuts things down a good bit!
#10
Hi everyone. I have a quetion and it might be a complicated one.

In one of my rooms I have 20 objects that are randomly being placed between 2 specified points:
Code: ags

  int Shallows_X = 960;
  int Shallows_Y = 960;
  object[1].SetPosition(Random(Shallows_X)+20, Random(Shallows_Y)+50);
  object[2].SetPosition(Random(Shallows_X)+20, Random(Shallows_Y)+50);
  etc.....


This is fine but there are areas within my environment (like walls and other solid objects I'd ideally not want these objects to be placed on. Is there a way to code in a check that places each object randomly on a walkable area. I am using regions for another game system and use multiple regions but I am only using one walkable area per room (at the moment at least).

Any help is appreciated as it would make such a big visual difference.
#11
That's impressive erico, not sure how you created the effect but it's food for thought. Khris, my environments are like top down, orthographic. So like the old Zelda games, so drawing to the background wouldn't really work especially with other objects scattered about the place.

I'll keep exploring. I was just curious how other people may have tackled the issue.
#12
Hello everyone.

I'm looking for some advice. I have a lot of underwater environments in the project I'm working but at the moment it's very bare and lacking sea life. My question is what would be the best/simplest way (I'm a medium level coder with AGS and wouldn't call myself advanced) to achieve shoals of fish that randomly swim about the room? Not neseceraly in groups.

I did think about just creating a lot of fish characters and have them move to a random x, y from 0 to the max room size, but creating all those characters seems like an awful lot of work, and I don't really want my project cluttered with an army of fish characters. I did look at the steering behaviour plugin but I couldn't really understand it although it sounded perfect for what I want to do (no example project files). So I pose the question? How would you approach this problem?

Any help would be appreciated.
#13
Hi Everyone

I know this is an issue that has come up time and time again but for the life of me I cant find anything about this problem (although I'm sure I have seen posts about this in the past). But I'm trying to display character names in a GUI on mouse over. I need to display a custom text property though as I need to change some character names at runtime.

my script is as follows:
 
Code: ags

// Display character names.
  Character *ch = Character.GetAtScreenXY(mouse.x, mouse.y);
  if (ch != null)
  {
    String npcName = character.GetTextProperty("NPC Name");
    gDetailsBox.Visible=true;
    lPointerOver.Text=String.Format("%s", npcName);
  }


At the moment it gives me a compile error saying it's requiring a [  doesn't make a lot of sense to me. I just cant seem to figure it out although on paper it should be pretty simple. Does anyone have any thoughts?

The help would be appreciated as it's really bugged me for a long time.

The C



*************
** Update
*************

I am very sorry, I figured it out but here is my code for future ref:

Code: ags
  
  //*******
  // Display character names.
  Character *ch = Character.GetAtScreenXY(mouse.x, mouse.y);
  if (ch != null)
  {
    String npcName;
    if (ch) npcName = ch.GetTextProperty("NPC Name");
    gDetailsBox.Visible=true;
    lPointerOver.Text=String.Format("%s", npcName);
  }


again, very sorry.
#14
Yeah that works great!

I'm now not even sure why I was having all that in a loop to be honest. works a charm.

Thank you!
C
#15
I tried that but was presented with this error:

ListboxRemove: invalid listindex specified.
I was curious if it was because it was removing an item that was currently selected so I tried adding: ListBox_Toolbox.SelectedIndex=-1; as that has sometimes caused issue in the past. But no avail. And it's just dawned on me that my unselecting it ListBox_Toolbox.RemoveItem(ListBox_Toolbox.SelectedIndex); wouldn't work anyway...but it didn't work before either.

Code: ags
   if (EquipTool1 == "Crowbar")
    {
      int i = 0;
        while (i < ListBox_Toolbox.ItemCount)
        {
          if (ListBox_Toolbox.Items[i] == "Crowbar")
          {
            bD0_Tool1.NormalGraphic=439;
            diver0_tool1=2; // Crowbar
            ListBox_Toolbox.SelectedIndex=-1;
            ListBox_Toolbox.RemoveItem(ListBox_Toolbox.SelectedIndex);
          }
        i++;
        }
      return;
    }


C
#16
Hi

I'm having an issue with Listboxes. I have a listbox that can have multiples duplicate items. The issue is I want to remove a selected item from the listbox, but as expected it's removing all duplicates of that name.

Is there a way to just remove a single duplicate entry?

My code follows:

Code: ags
String EquipTool1 = ListBox_Toolbox.Items[ListBox_Toolbox.SelectedIndex];
    if (EquipTool1 == "Crowbar")
    {
      int i = 0;
        while (i < ListBox_Toolbox.ItemCount)
        {
          if (ListBox_Toolbox.Items[i] == "Crowbar")
          {
            bD0_Tool1.NormalGraphic=439;
            diver0_tool1=2; // Crowbar
            ListBox_Toolbox.RemoveItem(i);
            ListBox_Toolbox.InsertItemAt(0, "Unequip");
          }
        i++;
        }
      return;
    }


As described in my question, if there are multiple Crowbar items in the list it obviously removes all crowbar items.

Any help would be greatly appreciated in this matter.

C
#17
Looking gorgeous. Love the character portraits!
#18
AGS Games in Production / Re: Blue Odyssey
Sat 15/08/2020 18:18:34
Fundamentally, it really still is a PNC, but I like to try and utilise AGS it in different ways. I love the engine, the accessibility of it and the amazing community, but there's always things I wish it could do. It probably can, I'm just limited on my coding knowledge (and wish I was better). Thankfully there's usually a module that someone has created that does the trick.

Keep experimenting, keep creating. There are some truly beautiful games made by this community.
#19
AGS Games in Production / Re: Blue Odyssey
Thu 13/08/2020 20:29:25
Thanks Matti.

I hope to keep this thread updated, it's not easy though as I'm working through my Nursing degree so that's eating up all the time....
#20
AGS Games in Production / Blue Odyssey
Sat 08/08/2020 21:14:54





I'd like to announce Blue Odyssey. A story driven adventure game set around the tropical paradise of Angel Bay! Search the reefs for hidden salvage, artefacts and the wonderful creatures of the deep. Help the locals in their tasks and unravel the dark mystery of the island fathoms deep.

Angel Bay is filled with colourful NPCs, all with their own story, secrets, and tasks to complete. Visit the 'Drowning Sailor Bar' for jobs, gossip or to hire local divers to aid you in your search for treasure.

Explore sunken wrecks and long forgotten temples and raid them for their artefacts and loot!

















  • Donate artefacts to the Angel Bay museum and unlock the secrets of history.
  • Search up to 13 large dive locations all with their own distinctive look filled with wrecks, sunken caves and lost temples.
  • Upgrade your vessel at the shipyard: increase crew capacity, larger fuel tanks, even a diving bell!
  • Hire and fire local divers to help you scour the depths for treasure, all with their own stats, and special traits!
  • A deep main story line + loads and loads of side quests you can gain from the local islanders.
  • Buy tools and better diving gear to get deeper into the crushing depths.
  • In-Game Achievements


I hope to keep this up to date with features and screenshots as it develops.

Thank you.
SMF spam blocked by CleanTalk