Results 1 to 4 of 4

Thread: GameObj.npcs.find

  1. #1

    Default GameObj.npcs.find

    Hello All,
    I am very new to Ruby but have development experience. I am attempting to make a script that will allow my higher level characters automatically assist my lower level characters while hunting. The script would be passed a variable which would be the creature we are hunting, for example lesser mummy. This would then make my higher level character cast certain spells if we enter a room and that creature is in the room. The spell being cast would be different if there is only 1 of the creatures or multiple. I am in the early stages of creating this script and am struggling trying to filter out the NPCs. I realize that most of the time the NPC will only be the creature I am hunting but wanted to filter it just in case. This is what I have but it is not working:

    npc = GameObj.npcs.find { |x| x.name == "lesser mummy" }


    I believe this should work however, when I test it nothing is coming back in npc. Any thoughts or scripts I could learn from would be appreciated. Thank you.

  2. #2

    Default

    You may have better luck with a regex match like x.name =~ /lesser mummy|other critter|etc/

    Add a lowercase i after for case-insensitive match.

  3. #3

    Default

    that works for me, what are you expecting it to return? Do you just have that one line or are you actually trying to do something with the npc variable after it is assigned and it is not working?

    Code:
    >;e npc = GameObj.npcs.find { |x| x.name == "lesser mummy" };fput("wave #{npc.name}")
    --- Lich: exec1 active.
    [exec1]>wave lesser mummy
    You wave to the mummy.
    >
    --- Lich: exec1 has exited.
    you might find more reliable help posting in the LICH folder btw You can always ask in game as well on the CODE channel. People are generally pretty helpful for coding noobs
    Mithrilschlong, 2015-03-10 to slightly later on 2015-03-10. You will not be forgotten!
    usable Meteor Swarm, late 2020-12-30 to early 2020-12-31. You will also not be forgotten!

  4. #4

    Default

    Thank you for your help and suggestions. I got help on the code channel and was able to get it working by doing the following:

    npc = GameObj.npcs.find_all { |x| x.name == 'lesser mummy' };

Similar Threads

  1. GameObj.npcs.status.
    By crb in forum The Lich Project
    Replies: 4
    Last Post: 07-23-2016, 08:49 PM
  2. Distracted NPCs
    By Samire in forum The Lich Project
    Replies: 1
    Last Post: 07-05-2016, 08:48 AM
  3. Replies: 1
    Last Post: 12-12-2015, 07:47 AM
  4. Looking for NPCs to help with a storyline
    By Satira in forum Role-Playing
    Replies: 0
    Last Post: 01-02-2007, 02:27 AM
  5. prone NPCs
    By in forum Game Mechanics
    Replies: 4
    Last Post: 12-07-2004, 12:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •