Jump to content


Photo

Loading ds_map


  • Please log in to reply
7 replies to this topic

#1 alpha_centauri

alpha_centauri

    GMC Member

  • GMC Member
  • 76 posts

Posted 27 May 2012 - 07:59 AM

How do I read a whole ds_map from a text file I created?

First: I have the following code to take a text file....and create a map from the file... then save the map into a different text file.

global.words = ds_map_create();
show_message("hello")
f = file_text_open_read(working_directory+"\diction.txt")
 while(!file_text_eof(f))
{
t = file_text_read_string(f);
ds_map_add(global.words,t,1);
file_text_readln(f)
}
show_message("complete")
file_text_close(f)
show_message(ds_map_exists(global.words, "ANGRY"));
show_message(ds_map_find_first(global.words));
show_message(ds_map_find_last(global.words));

f = file_text_open_write("e:\wordmap.txt")
file_text_write_string(f, ds_map_write(global.words))
file_text_close(f)

then I have this code to load the map (in a different program) However it just freezes without any shown errors.

global.words = ds_map_create();
show_message("hello")
f = file_text_open_read("e:\wordmap.txt")
 while(!file_text_eof(f))
t = file_text_read_string(f);
ds_map_read(global.words,1)
show_message("complete")
file_text_close(f)

what do I need to change and why doesn't this work?
  • 0

#2 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16792 posts
  • Version:GM:Studio

Posted 27 May 2012 - 08:40 AM

Does the "complete" message show at all? And what other program are you loading it into? Does it do anything else that could influence the results?
  • 0

#3 alpha_centauri

alpha_centauri

    GMC Member

  • GMC Member
  • 76 posts

Posted 27 May 2012 - 08:49 AM

Does the "complete" message show at all? And what other program are you loading it into? Does it do anything else that could influence the results?


complete does not show up. And the program its loading in is blank...other than that code to load it in a create event in one object. But no it doesn't load at all... Also the file that it saves it to does not load with a regular text file either...like TextEditor crashes...and the file it saves turns out to be 4.59 mb big.

More information what I'm trying to accomplish is I am loading a 170,000 word list as a map. It will load that list...but when loading on a android device it takes quite some time (a 30 second pause)

after that it is in use... but I was trying to make a faster solution to load this ds_map created and I've been told that saving it is the solution after its been created... well I've yet to have luck and I've been off and on trying it out for the past 2 months
  • 0

#4 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16792 posts
  • Version:GM:Studio

Posted 27 May 2012 - 08:54 AM

Ds_maps should be lightning fast in GM:Studio as the whiole system was re-written. We use it with our game "Word Search" which has a lot more words than that.... I'm not sure what could be going wrong.
  • 0

#5 alpha_centauri

alpha_centauri

    GMC Member

  • GMC Member
  • 76 posts

Posted 27 May 2012 - 07:04 PM

Well how was it implemented in Word Search then..? Like how did you save the ds_list and then how did you reload it? And why is the ds_map file I save 5 megabites ?
  • 0

#6 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1482 posts
  • Version:GM:Studio

Posted 27 May 2012 - 07:32 PM

We used C# to build the map directly into the proper format. We'll be documenting the format at some point....
  • 0

#7 alpha_centauri

alpha_centauri

    GMC Member

  • GMC Member
  • 76 posts

Posted 28 May 2012 - 06:06 AM

so then why does it not load properly after saving.... isn't that what the function ds_map_write(global.words) is for... (along with read?)
  • 0

#8 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1482 posts
  • Version:GM:Studio

Posted 28 May 2012 - 07:09 AM

Yes it should, if there is an issue, then that's a bug. Please file one and upload a simple example and we'll look to fix it.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users