Page 3 of 3 FirstFirst 1 2 3
Results 21 to 25 of 25

Thread: file_to_map

  1. #21
    Developer
    Join Date
    Aug 2009
    Posts
    2,748

    Default

    file_to_map by default will parse the file as tab-separated values. First column is the key, second column is the value. If you have a multi-dimensional value (e.g. a record, or another map), then that takes up one column per dimension. Since your map value in this case is a scalar (string), map_to_file only parses the first two columns of your datafile.

  2. #22
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    357

    Default

    file_to_map by default will parse the file as tab-separated values. First column is the key, second column is the value. If you have a multi-dimensional value (e.g. a record, or another map), then that takes up one column per dimension. Since your map value in this case is a scalar (string), map_to_file only parses the first two columns of your datafile.
    Originally Posted by heeheehee View Post
    How can I save the data to multiple lines? I've found a temporary way around it, which i'm not happy with.
    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.

  3. #23
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,023

    Default

    How can I save the data to multiple lines?
    Originally Posted by Pazleysox View Post
    WTH does that mean?

    Your file has multiple lines already.

    Are you saying you want something like
    message1
    message1time1
    message1time2
    message2
    message2time1
    message2time2
    message2time3

    ?

    If so multiple lines is NOT the best way to manage the data in ash.

    I feel like there is a disconnect between what we assume you know about maps and what you actually know about maps and I'm not sure how to bridge that.

    Could we step back and look at the problem you are trying to solve and not the details of your solution?

    Where is your data coming from? Specifically is it something you are reading and have no control over the format? Is it something you created, but not in ash, so you have some control over the format? Is it something you are creating in ash, in which case you need to define and use a map that supports the data and the use.

    As a general rule, if it can be represented in a spreadsheet it can be represented as an ash map fairly easily.
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  4. #24
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    357

    Default

    WTH does that mean?
    Originally Posted by fronobulax View Post
    lol
    Where is your data coming from? Specifically is it something you are reading and have no control over the format? Is it something you created, but not in ash, so you have some control over the format?
    Originally Posted by fronobulax View Post
    I'm working on my chatbot script. I was trying to figure out a way to record the last thing someone said, and the time they said it.

    TBT, I didn't want to say that, because every time I mention chatbot, people seem to run away. I did find a way to record what I needed in a setting, so technically what I wanted works. As per our earlier talk, I really didn't want to do it this way, but it DOES work...

    For future reference, here's what I did.
    PHP Code:
        if(contains_text(to_lower_case(sender), "pazsox"))
        {
        
    set_property("pazsoxseen"now_to_string("EEE, h:mm"));  // here's where it records the day and time
        
    set_property("pazsoxsaid"message); // here's where it records the message
        
    }
        if(
    contains_text(to_lower_case(message), "seen pazsox"))
        {
        
    chat_clan("PazSox was last seen " get_property("pazsoxseen") + " and said: " get_property("pazsoxsaid")); //returns time day/time, and then message
            

    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.

  5. #25
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,023

    Default

    OK.

    You are parsing something and extracting a user, message and a time from it. User and message are strings and time is an int.

    I would define this record.

    Code:
    record conversation {
       string user;
       string message;
       int time;
    }
    I would then declare an "array" of the record.

    Code:
    conversation[int] chatz;
    I would read and write using the utilities.

    map_to_file(chatz,"chatHistory.txt");
    file_to_map("chatHistory.txt", chatz);

    I would add a new conversation record by...
    Code:
    conversation newConv;
    newConv.user = ...
    newConv.message = ...
    newConv.time = ...
    
    chatz[count(chatz)+1] = newConv;
    The ... means fill in the data you parsed from elsewhere.

    I think you know how to iterate and search.

    This assumes that the integer used to index the map is not really relevant - it doesn't matter what order the "conversations" occur in the file.

    It might be important to know the date of when things happened. That could be done by using a new file for each date or by adding a date to the record or by converting the time into a timestamp yyyymmddhhmmss.

    I have not tested any of the code.

    I have no game or social reason to use chat and I do keep a character who has never visited the Altar of Literacy to test mafia, but I'm actually OK with you trying things with a chatbot.

Posting Permissions

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