Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Searching map_to_file

  1. #1
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    434

    Default Searching map_to_file

    Is it possible to search for a specific word, or set of words inside a map?
    Scripts I have written:
    Unlock Dread A Script to save you a bunch of clicks.
    Standard Rollover Bonus A Script that shows best items to pull/equip for bonus turns.
    Standard PVP Bonus A Script that shows the best items to pull/equip for bonus PVP Fights.
    Rollover Management A Script that does all the daily deeds you might have forgotten, or might have missed.
    Chatbot A Chatbot script. Simple start for those who want/need one for their clan.
    Zap Wand A Dungeon of Doom ZAP WAND getting script.

  2. #2
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,264

    Default

    Is it possible to search for a specific word, or set of words inside a map?
    Originally Posted by Pazleysox View Post
    You are going to have to be more specific than that. You can use "contains" to find out whether they map has a particular key but you probably have to iterate over the map and search each value otherwise.
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  3. #3
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    434

    Default

    The search wasn't as difficult as I first thought it would be.

    I've been scouring the forums for over an hour, and I can't find, nor can I figure out how to add info to an existing map.

    IE:

    Current map says:
    0 Mr. Accessory
    1 Mrs. Accessory
    2 Time Sword


    I would like to keep all current information IN the map, and just be able to add to it.
    Scripts I have written:
    Unlock Dread A Script to save you a bunch of clicks.
    Standard Rollover Bonus A Script that shows best items to pull/equip for bonus turns.
    Standard PVP Bonus A Script that shows the best items to pull/equip for bonus PVP Fights.
    Rollover Management A Script that does all the daily deeds you might have forgotten, or might have missed.
    Chatbot A Chatbot script. Simple start for those who want/need one for their clan.
    Zap Wand A Dungeon of Doom ZAP WAND getting script.

  4. #4
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    944

    Default

    If the map is items -- to add an additional entry:

    item[int] mapname;

    mapname[count(mapname)] = NEW $item ENTRY;

    (Assuming the map is 0-indexed, so the count() of the map will be the (highest index +1).)

    ===============

    If you are talking about adding additional information to an existing entry (probably a map of strings or ints, as (all?) other data types aren't additive):

    Code:
    string[int] mapname;
    
    foreach i in mapname {
      if (mapname[i] == "Mr. Accessory" ) {
        mapname[i] += " the text to add";
      }
    }
    Last edited by AlbinoRhino; 01-03-2019 at 07:15 PM.

  5. #5
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    434

    Default

    Ok. Here's the code I'm working on.
    PHP Code:
        string [intmy_list;
        
    file_to_map"pazsox.txt" my_list);
        for 
    i from 0 to (count(my_list) - 1
        {
            if (
    contains_text(my_list[i], sender))
            {    print (
    "true");     return; }
            if(!
    contains_text(my_list[i], sender))
            {    print(
    "false");    record note
                
    {
                
    string message;
                }
            [
    inttest;
                
    int NEcount(test);
                
    test[NE].messagesender;
                
    Map_to_File(test"pazsox.txt");
            }
        } 
    Regardless of if a users name is in the file or not, it adds the name again. I obviously only want a persons name on the list once, and never again.

    I have a feeling the answer is in AlbinoRhino's response above, I just need to figure it out.
    Scripts I have written:
    Unlock Dread A Script to save you a bunch of clicks.
    Standard Rollover Bonus A Script that shows best items to pull/equip for bonus turns.
    Standard PVP Bonus A Script that shows the best items to pull/equip for bonus PVP Fights.
    Rollover Management A Script that does all the daily deeds you might have forgotten, or might have missed.
    Chatbot A Chatbot script. Simple start for those who want/need one for their clan.
    Zap Wand A Dungeon of Doom ZAP WAND getting script.

  6. #6
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,264

    Default

    If you are just making a list of things - what matters is whether the item in your example is in the list, or not, and you don't care abut the order, you could also flip things.

    int[item] things

    things[Mr. Accessory] = 0; would add Mr. A to the list if it is not already there.

    You could use contains to find out whether something was in the list, or not.

  7. #7
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    434

    Default

    I'm trying to make a list of people who have spoken in clan.

  8. #8
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,264

    Default

    I'm trying to make a list of people who have spoken in clan.
    Originally Posted by Pazleysox View Post
    int[string] speakers
    string Name = some_function_that_returns_the_name_of_a_clan_spea ker();
    speakers[Name] = 0;
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  9. #9
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    944

    Default

    Ok. Here's the code I'm working on.
    Code:
        string [int] my_list;
        file_to_map( "pazsox.txt" , my_list);
        for i from 0 to (count(my_list) - 1) 
        {
            if (contains_text(my_list[i], sender))
            {    print ("true");     return; }
             If the 'sender' you are testing for happens to be the first name in the map, then this will print true and return.
             
             If any other name is  first in the map, then this will print false and add the name WHETHER it appears later in the map or not.
            if(!contains_text(my_list[i], sender))
            {    print("false");
                
               'test' can just be a string[int] map.  There is no need to make a record[int] map here (that I can see).
                record note
                {
                string message;
                } [int] test;   --> string[int] test;
    
                int NE= count(test);
                test[NE].message= sender;  --> just test[NE] = sender;
                Map_to_File(test, "pazsox.txt");
            }
        }
    Regardless of if a users name is in the file or not, it adds the name again. I obviously only want a persons name on the list once, and never again.

    I have a feeling the answer is in AlbinoRhino's response above, I just need to figure it out.
    Originally Posted by Pazleysox View Post
    To do what you are trying to do...(I think)...maybe something like this:

    Code:
    string [int] my_list;
    file_to_map( "pazsox.txt" , my_list);
    string storage_string = "";
    foreach i in my_list {
     storage_string += my_list[i] + " ";
    }
    
    All the names in the list are now in a single string....
    
    if ( !contains_text(storage_string, sender) ) {
     my_list[count(my_list)] = sender;
     map_to_file(my_list, "pazsox.txt");
    }
    Last edited by AlbinoRhino; 01-03-2019 at 10:28 PM.

  10. #10
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    434

    Default

    To do what you are trying to do...(I think)...maybe something like this:
    Originally Posted by AlbinoRhino View Post
    YES! That's absolutely perfect, thank you so much. That's exactly what I needed. I appreciate your help!
    Scripts I have written:
    Unlock Dread A Script to save you a bunch of clicks.
    Standard Rollover Bonus A Script that shows best items to pull/equip for bonus turns.
    Standard PVP Bonus A Script that shows the best items to pull/equip for bonus PVP Fights.
    Rollover Management A Script that does all the daily deeds you might have forgotten, or might have missed.
    Chatbot A Chatbot script. Simple start for those who want/need one for their clan.
    Zap Wand A Dungeon of Doom ZAP WAND getting script.

Posting Permissions

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