ryaden
06-05-2018, 12:50 AM
I have been struggling with a script freezing and don't know why.
I have been experimenting with csv files to store information - like scrolls I have saved and gems I am hoarding.
My script has been slowing when I get to this loop, essentially no game data goes through once I do this but I can enter commands but can't see what happens.
while line = get
if line =~ /ACCEPT/
fput "accept"
fput "wear pouch"
break
end
end
I am not concerned there is a problem with the loop, because when copied and pasted into a test script in isolation and it works fine. It is freezing this script in the game. If I kill the script the game goes back to working normally.
I think this problem may be caused by my use of a csv file. I have a few lines in the script that may be causing problems and wonder if anyone has any idea how I might fix this.
1.
require 'csv'
get = CSV.read('hoardgem.csv') #this is a file of #_of_gems and gem_name
2. also I have created a string to use in a regular expression (I need these to be available as an array but also as a string for regular expression search).
get_gems = ["gem_name", "another_gem_name", "ect"]
@gems_to_hoard = ""
get_gems.each do |obj|
if @gems_to_hoard.empty?
@gems_to_hoard = obj
else
@gems_to_hoard = @gems_to_hoard + "|" + obj
end
end
#this should yield "gem name|another gem name|ect"
As I say all the other code seems to work fine. It is simply the while line = get part that freezes. I appreciate any thoughts.
Ryaden
I have been experimenting with csv files to store information - like scrolls I have saved and gems I am hoarding.
My script has been slowing when I get to this loop, essentially no game data goes through once I do this but I can enter commands but can't see what happens.
while line = get
if line =~ /ACCEPT/
fput "accept"
fput "wear pouch"
break
end
end
I am not concerned there is a problem with the loop, because when copied and pasted into a test script in isolation and it works fine. It is freezing this script in the game. If I kill the script the game goes back to working normally.
I think this problem may be caused by my use of a csv file. I have a few lines in the script that may be causing problems and wonder if anyone has any idea how I might fix this.
1.
require 'csv'
get = CSV.read('hoardgem.csv') #this is a file of #_of_gems and gem_name
2. also I have created a string to use in a regular expression (I need these to be available as an array but also as a string for regular expression search).
get_gems = ["gem_name", "another_gem_name", "ect"]
@gems_to_hoard = ""
get_gems.each do |obj|
if @gems_to_hoard.empty?
@gems_to_hoard = obj
else
@gems_to_hoard = @gems_to_hoard + "|" + obj
end
end
#this should yield "gem name|another gem name|ect"
As I say all the other code seems to work fine. It is simply the while line = get part that freezes. I appreciate any thoughts.
Ryaden