In the current update 3.0.3, os.time() and other os functions are killed. This breaks many addons. This is a quick hack to fix os.time() and os.difftime(x,y). Still I do not find a good way to fix os.date(format), so the current support for the os.date function is not good. However, this small addon revived most of the addons except for pbInfo. Maybe within a few days, I myself or some others will fix os.date in a better way and make pbInfo compatible with 3.0.3.
Fix for addons 3.0.3 and other addons ...
Fix for addons 3.0.3 and other addons ...
not related but from the EU Forms ...
- Attachments
-
- ! - Fix_for_patch303.zip
- (544 Bytes) Downloaded 145 times
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Fix for addons 3.0.3 and other addons ...
That fix doesn't fix anything. It's doesn't cover anything the os.date function is supposed to do. I've been trying to rewrite the origional function to work with what's available in the lua code but have been unsuccessful in translating it. I'll post the functions in a reply.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Fix for addons 3.0.3 and other addons ...
os.date needs to be remade from:
os.time has to use the GetTime(); function and be rewritten from:
I'm not sure if the difftime they wrote will work so here is os.difftime:
I think the only time the bot uses this is in its own interpreter so it doesn't really need these corrected. Still, any help would be great (I couldn't figure out the wildcards for date).
Code: Select all
static int os_date (lua_State *L) {
const char *s = luaL_optstring(L, 1, "%c");
time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
struct tm *stm;
if (*s == '!') { /* UTC? */
stm = gmtime(&t);
s++; /* skip `!' */
}
else
stm = localtime(&t);
if (stm == NULL) /* invalid date? */
lua_pushnil(L);
else if (strcmp(s, "*t") == 0) {
lua_createtable(L, 0, 9); /* 9 = number of fields */
setfield(L, "sec", stm->tm_sec);
setfield(L, "min", stm->tm_min);
setfield(L, "hour", stm->tm_hour);
setfield(L, "day", stm->tm_mday);
setfield(L, "month", stm->tm_mon+1);
setfield(L, "year", stm->tm_year+1900);
setfield(L, "wday", stm->tm_wday+1);
setfield(L, "yday", stm->tm_yday+1);
setboolfield(L, "isdst", stm->tm_isdst);
}
else {
char cc[3];
luaL_Buffer b;
cc[0] = '%'; cc[2] = '\0';
luaL_buffinit(L, &b);
for (; *s; s++) {
if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */
luaL_addchar(&b, *s);
else {
size_t reslen;
char buff[200]; /* should be big enough for any conversion result */
cc[1] = *(++s);
reslen = strftime(buff, sizeof(buff), cc, stm);
luaL_addlstring(&b, buff, reslen);
}
}
luaL_pushresult(&b);
}
return 1;
}
Code: Select all
static int os_time (lua_State *L) {
time_t t;
if (lua_isnoneornil(L, 1)) /* called without args? */
t = time(NULL); /* get current time */
else {
struct tm ts;
luaL_checktype(L, 1, LUA_TTABLE);
lua_settop(L, 1); /* make sure table is at the top */
ts.tm_sec = getfield(L, "sec", 0);
ts.tm_min = getfield(L, "min", 0);
ts.tm_hour = getfield(L, "hour", 12);
ts.tm_mday = getfield(L, "day", -1);
ts.tm_mon = getfield(L, "month", -1) - 1;
ts.tm_year = getfield(L, "year", -1) - 1900;
ts.tm_isdst = getboolfield(L, "isdst");
t = mktime(&ts);
}
if (t == (time_t)(-1))
lua_pushnil(L);
else
lua_pushnumber(L, (lua_Number)t);
return 1;
}
Code: Select all
static int os_difftime (lua_State *L) {
lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
(time_t)(luaL_optnumber(L, 2, 0))));
return 1;
}
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Fix for addons 3.0.3 and other addons ...
Also, the descriptions for reference (what made me realize how poor the fix was).
os.date:
os.time:
And os.difftime description looks exactly like the function in the fix but with all the factors of the above differences you already know it's not so simple.
os.date:
Code: Select all
os.date ([format [, time]])
Returns a string or a table containing date and time, formatted according to the given string format.
If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). Otherwise, date formats the current time.
If format starts with '!', then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string "*t", then date returns a table with the following fields: year (four digits), month (1--12), day (1--31), hour (0--23), min (0--59), sec (0--61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).
If format is not "*t", then date returns the date as a string, formatted according to the same rules as the C function strftime.
When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale (that is, os.date() is equivalent to os.date("%c")).
Code: Select all
os.time ([table])
Returns the current time when called without arguments, or a time representing the date and time specified by the given table. This table must have fields year, month, and day, and may have fields hour, min, sec, and isdst (for a description of these fields, see the os.date function).
The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to date and difftime.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
Re: Fix for addons 3.0.3 and other addons ...
it fixed my Xbar which only used the get time function in it but yes it was a shoddy fix but it was the first one out that fixed many addons with the get time functions in them ... pbinfo has updated the addon dont know if he just removed the date function or found a way around it...
- MiesterMan
- Posts: 543
- Joined: Tue Jul 06, 2010 9:15 pm
- Location: Between the Second and Third Circles of Hell
Re: Fix for addons 3.0.3 and other addons ...
Ah, thx for the info. I was told it was discontinuted, I should have checked myself, hah!
Edit: Lols, so they disabled the stuff that uses the os functions. It says they re-enable them if someone makes a reliable replacement XD. I was also told TonkManager wasn't going to be updated but I'll take a look there too just in case.
Edit: Yea, since TonkManager is wholey dependant on checking the time he says he can't fix it until the functions are replaced. I suppose he could dumb it down but that was seriously degrade the quality of his rather awsome add-on.
Edit: Lols, so they disabled the stuff that uses the os functions. It says they re-enable them if someone makes a reliable replacement XD. I was also told TonkManager wasn't going to be updated but I'll take a look there too just in case.
Edit: Yea, since TonkManager is wholey dependant on checking the time he says he can't fix it until the functions are replaced. I suppose he could dumb it down but that was seriously degrade the quality of his rather awsome add-on.
My RoM Bot toys:
- Object Viewer: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2619
Teleporter Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2605
Waypoint Finder: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2616
Mail Functions: http://www.solarstrike.net/phpBB3/viewt ... =27&t=2612
Equipment Swapper(TempFixed): http://www.solarstrike.net/phpBB3/viewt ... =27&t=2571
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests