-
master121
- Posts: 45
- Joined: Mon Dec 29, 2008 10:40 am
#1
Post
by master121 » Sun Oct 11, 2009 4:58 am
Code: Select all
unction convert_utf8_ascii_character( _str, _ascii )
local found;
local tmp = database.utf8_ascii[_ascii];
_str, found = string.gsub(_str, string.char(tmp.utf8_1, tmp.utf8_2), string.char(tmp.ascii) );
return _str, found;
end
function convert_utf8_ascii( _str )
local found, found_all;
found_all = 0;
for i,v in pairs(database.utf8_ascii) do
_str, found = convert_utf8_ascii_character( _str, v.ascii ); -- replace special characters
found_all = found_all + found; -- count replacements
end
if( found_all > 0) then
return _str, true;
else
return _str, false;
end
end
When i call it like this :
Code: Select all
local bagid, icon, name, itemCount = sendMacro("GetBagItemInfo("..k..");");
dofile("string.lua")
name = convert_utf8_ascii(name);
It ends in this error.
string.lua:4 attempt to index local "tmp" <a nil value>
Any solution ?
-
Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
#2
Post
by Administrator » Sun Oct 11, 2009 7:25 am
Why are you loading string.lua? It's not part of the bot, so I don't know what it contains. But that's where your error is.
-
master121
- Posts: 45
- Joined: Mon Dec 29, 2008 10:40 am
#3
Post
by master121 » Sun Oct 11, 2009 7:49 am
function convert_utf8_ascii_character( _str, _ascii ) and function convert_utf8_ascii( _str ) are in there.
I think d003232 gave me the functions.
-
Administrator
- Site Admin
- Posts: 5307
- Joined: Sat Jan 05, 2008 4:21 pm
#4
Post
by Administrator » Sun Oct 11, 2009 7:56 am
If you've got the latest version off of SVN, you should not need string.lua. rom/functions.lua already contains the function you are trying to use.
-
d003232
- Posts: 1252
- Joined: Wed Jun 03, 2009 4:27 pm
#5
Post
by d003232 » Sun Oct 11, 2009 2:25 pm
master121 wrote:function convert_utf8_ascii_character( _str, _ascii ) and function convert_utf8_ascii( _str ) are in there.
I think d003232 gave me the functions.
In the latest SVN, the function for conversion of umlauts was renamed to
Code: Select all
function utf8ToAscii_umlauts(_str)
Who is online
Users browsing this forum: Ahrefs [Bot] and 5 guests