Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 26d072e

Browse files
committed
Release 1.4.2
1 parent fbc52e9 commit 26d072e

3 files changed

Lines changed: 76 additions & 23 deletions

File tree

config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
config = {
22
name = 'Raphael\'s Library',
3-
version = '1.4.1',
4-
windbot = '2.5.4',
3+
version = '1.4.2',
4+
windbot = '2.5.6',
55

66
files = {
77
layout = 'Layout.tlua',

dist/Raphael.lua

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
-- Raphael's Library v1.4.1
2-
-- Last Updated: 21/11/2014 - 16:25 UTC
3-
-- Released for WindBot v2.5.4
1+
-- Raphael's Library v1.4.2
2+
-- Last Updated: 15/12/2014 - 05:56 UTC
3+
-- Released for WindBot v2.5.6
44

5-
RAPHAEL_LIB = '1.4.1'
5+
RAPHAEL_LIB = '1.4.2'
66

77
--[[
8-
* Changelog v1.4.1
8+
* Changelog v1.4.2
99
*
10-
* - Fixed a small bug with the Point constructor.
10+
* - Fixed a small bug with the Area constructor.
1111
*
1212
--]]
1313

@@ -110,7 +110,7 @@ CUSTOM_TYPE = {
110110
POINT = {'x', 'y'},
111111
ITEMDATA = {'name', 'id', 'sellprice', 'buyprice', 'weight', 'isbank', 'isclip', 'isbottom', 'istop', 'iscontainer', 'iscumulative', 'isforceuse', 'ismultiuse', 'iswrite', 'iswriteonce', 'isliquidcontainer', 'isliquidpool', 'isunpass', 'isunmove', 'isunsight', 'isavoid', 'isnomovementanimation', 'istake', 'ishang', 'ishooksouth', 'ishookeast', 'isrotate', 'islight', 'isdonthide', 'istranslucent', 'isfloorchange', 'isshift', 'isheight', 'islyingobject', 'isanimatealways', 'isautomap', 'islenshelp', 'isfullbank', 'isignorelook', 'isclothes', 'ismarket', 'ismount', 'isdefaultaction', 'isusable', 'ignoreextradata', 'enchantable', 'destructible', 'hasextradata', 'height', 'sizeinpixels', 'layers', 'patternx', 'patterny', 'patterndepth', 'phase', 'walkspeed', 'textlimit', 'lightradius', 'lightcolor', 'shiftx', 'shifty', 'walkheight', 'automapcolor', 'lenshelp', 'defaultaction', 'clothslot', 'marketcategory', 'markettradeas', 'marketshowas', 'marketrestrictprofession', 'marketrestrictlevel', 'durationtotalinmsecs', 'specialeffect', 'specialeffectgain', 'category', 'attack', 'attackmod', 'hitpercentmod', 'defense', 'defensemod', 'armor', 'holyresistmod', 'deathresistmod', 'earthresistmod', 'fireresistmod', 'iceresistmod', 'energyresistmod', 'physicalresistmod', 'lifedrainresistmod', 'manadrainresistmod', 'itemlossmod', 'mindmg', 'maxdmg', 'dmgtype', 'range', 'mana'},
112112
SUPPLYDATA = {'name', 'id', 'weight', 'buyprice', 'leaveat', 'count', 'rule', 'rulevalue', 'destination', 'category', 'uptocount', 'downtocap', 'amountbought', 'amounttobuy', 'amountused'},
113-
LOOTINGDATA = {'name' ,'id' ,'weight' ,'sellprice' ,'count' ,'action' ,'alert' ,'condition' ,'conditionvalue' ,'destination' ,'category' ,'amountlooted' ,'haslessthan' ,'caphigherthan'},
113+
LOOTINGDATA = {'name' ,'id' ,'weight' ,'sellprice' ,'count' ,'action' ,'alert' ,'condition' ,'conditionvalue' ,'destination' ,'category' ,'amountlooted' ,'haslessthan' ,'caphigherthan', 'lootmessage'},
114114
VIP = {'name', 'id', 'icon', 'isonline', 'notify'},
115115
MOUSEINFO = {'x', 'y', 'z', 'id', 'count', 'crosshair'},
116116
DEATHTIMER = {'timeofdeath', 'target', 'killer', 'time'},
@@ -122,7 +122,7 @@ CUSTOM_TYPE = {
122122

123123
-- Key codes
124124
-- http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
125-
-- CAUTION: This list if fucked up, for some reason
125+
-- CAUTION: This list is fucked up, for some reason
126126
local KEYS = {
127127
MOUSELEFT = 0x01,
128128
MOUSERIGHT = 0x02,
@@ -1442,10 +1442,11 @@ end
14421442

14431443
--[[
14441444
* Runs a routine through every item in the given table. The routine to be ran
1445-
* will receive as arguments, for each item, it's value and correspondet index.
1445+
* will receive as arguments, for each item, it's value and correspondent index
1446+
* and the whole table.
14461447
*
14471448
* @since 0.1.0
1448-
* @updated 1.4.0
1449+
* @updated 1.5.0
14491450
*
14501451
* @param {table} self - The target table
14511452
* @param {function} f - Routine to be ran on each element
@@ -1462,7 +1463,7 @@ function table.each(self, f, recursive)
14621463
if recursive and type(v) == 'table' then
14631464
r[k] = table.each(v, f, recursive)
14641465
else
1465-
r[k] = f(v, k)
1466+
r[k] = f(v, k, self)
14661467
end
14671468
end
14681469

@@ -1472,10 +1473,11 @@ end
14721473
--[[
14731474
* Runs a routine through every item in the given table and replace the item
14741475
* with the value returned by it. The routine to be ran will receive as
1475-
* arguments, for each item, it's value and correspondet index.
1476+
* arguments, for each item, it's value and correspondent index and the whole
1477+
* table.
14761478
*
14771479
* @since 0.1.0
1478-
* @updated 1.4.0
1480+
* @updated 1.5.0
14791481
*
14801482
* @param {table} self - The target table
14811483
* @param {function} f - Routine to be ran on each element
@@ -1487,7 +1489,7 @@ function table.map(self, f, recursive)
14871489
if recursive and type(v) == 'table' then
14881490
table.map(v, f, true)
14891491
else
1490-
self[k] = f(v, k)
1492+
self[k] = f(v, k, self)
14911493
end
14921494
end
14931495
end
@@ -1564,9 +1566,12 @@ end
15641566

15651567
--[[
15661568
* Runs a routine through every item in the given table and remove it from the
1567-
* table if the routine returns false.
1569+
* table if the routine returns false. The routine to be ran will receive as
1570+
* arguments, for each item, it's value and correspondent index and the whole
1571+
* table.
15681572
*
15691573
* @since 1.1.0
1574+
* @updated 1.5.0
15701575
*
15711576
* @param {table} self - The target table
15721577
* @param {function} f - Routine to be ran as filter;
@@ -1579,7 +1584,7 @@ function table.filter(self, f)
15791584
end
15801585

15811586
for k, v in pairs(self) do
1582-
if not f(v, k) then
1587+
if not f(v, k, self) then
15831588
table.remove(self, k)
15841589
end
15851590
end
@@ -1633,28 +1638,28 @@ end
16331638
* Returns the sum of all items in the given table.
16341639
*
16351640
* @since 1.1.0
1641+
* @updated 1.5.0
16361642
*
16371643
* @param {table} self - The target table
16381644
*
16391645
* @returns {number} - The sum of all items
16401646
--]]
16411647
function table.sum(self)
1642-
local s = 0
1643-
table.each(self, function(v) s = s + v end)
1644-
return s
1648+
return table.reduce(self, function (memo, v) return memo + v end)
16451649
end
16461650

16471651
--[[
16481652
* Returns the average of all items in the given table.
16491653
*
16501654
* @since 1.1.0
1655+
* @since 1.5.0
16511656
*
16521657
* @param {table} self - The target table
16531658
*
16541659
* @returns {number} - The average of all items
16551660
--]]
16561661
function table.average(self)
1657-
return table.sum(self) / #self
1662+
return table.sum(self) / table.size(self)
16581663
end
16591664

16601665
--[[
@@ -1713,6 +1718,53 @@ function table.flatten(self, recursive)
17131718
end
17141719
end
17151720

1721+
function table.pick(self, ...)
1722+
local args = {...}
1723+
local r = {}
1724+
1725+
for _, v in ipairs(args) do
1726+
r[v] = self[v]
1727+
end
1728+
1729+
return r
1730+
end
1731+
1732+
function table.reduce(self, f, memo)
1733+
for k, v in pairs(self) do
1734+
if memo == nil then
1735+
memo = v
1736+
else
1737+
memo = f(memo, v, k, self)
1738+
end
1739+
end
1740+
1741+
return memo
1742+
end
1743+
1744+
function table.every(self, f)
1745+
for k, v in pairs(self) do
1746+
if not f(v, k, self) then
1747+
return false
1748+
end
1749+
end
1750+
1751+
return true
1752+
end
1753+
1754+
function table.any(self, f)
1755+
for k, v in pairs(self) do
1756+
if f(v, k, self) then
1757+
return true
1758+
end
1759+
end
1760+
1761+
return false
1762+
end
1763+
1764+
function table.pluck(self, prop)
1765+
return table.each(self, function (v) return v[prop] end)
1766+
end
1767+
17161768

17171769

17181770

@@ -2089,7 +2141,7 @@ function Area:new(firstCorner, width, height)
20892141

20902142
local secondCorner = Point:new(width)
20912143
if secondCorner == nil then
2092-
secondCorner = firstCorner + Point:new(width, height)
2144+
secondCorner = firstCorner + Point:new(width - 1, height - 1)
20932145
end
20942146

20952147
if type(firstCorner) ~= 'Point' or type(secondCorner) ~= 'Point' then

log/changelog-1.4.2.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* - Fixed a small bug with the Area constructor.

0 commit comments

Comments
 (0)