Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createItemType Via Lua #3354

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions data/items/items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Game.createItemType(26378):register({
name = "gold converter",
article = "a",
weight = 1800,
duration = 604800,
charges = 500,
showcharges = true,
showduration = true
})

-- Exaple for fields
--[[Game.createItemType(1487):register({
name = "fire field",
article = "a",
type = "magicfield",
decayTo = 1488,
duration = 120,
field = {
name = "fire",
damage = 20,
ticks = 10000,
count = 7
}
})]]

-- Example for multiIds
--[[Game.createItemType(20005, 20080):register({
name = "sign",
article = "a",
allowDistRead = "true"
})]]
7 changes: 0 additions & 7 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36265,13 +36265,6 @@
<attribute key="containerSize" value="40" />
<attribute key="description" value="Tired of carrying lots and lots of backpacks filled with money? In a Gold Pouch you can carry as many gold, platinum or crystal coins as your capacity allows." />
</item>
<item id="26378" article="a" name="gold converter">
<attribute key="weight" value="1800" />
<attribute key="duration" value="604800" />
<attribute key="charges" value="500" />
<attribute key="showcharges" value="1" />
<attribute key="showduration" value="1" />
</item>
<item id="26379" article="a" name="golden dragon tapestry" />
<item id="26380" article="a" name="sword tapestry" />
<item id="26381" article="a" name="brocade tapestry" />
Expand Down
9 changes: 6 additions & 3 deletions data/lib/compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function pushThing(thing)
if thing:isItem() then
t.uid = thing:getUniqueId()
t.itemid = thing:getId()
if ItemType(t.itemid):hasSubType() then
if ItemType(t.itemid):subType() then
t.type = thing:getSubType()
end
t.actionid = thing:getActionId()
Expand Down Expand Up @@ -1390,6 +1390,7 @@ function createFunctions(class)
for strLen, strTable in pairs(exclude) do
if table.contains(strTable, name:sub(1, strLen)) then
add = false
break
end
end
if add then
Expand All @@ -1398,14 +1399,16 @@ function createFunctions(class)
local setFunc = function(self, ...) return func(self, ...) end
local get = "get" .. str
local set = "set" .. str
if not (rawget(class, get) and rawget(class, set)) then
table.insert(temp, {set, setFunc, get, getFunc})
local is = "is" .. str
if not (rawget(class, get) and rawget(class, set) and rawget(class, is)) then
table.insert(temp, {set, setFunc, get, getFunc, is, getFunc})
end
end
end
for _, func in ipairs(temp) do
rawset(class, func[1], func[2])
rawset(class, func[3], func[4])
rawset(class, func[5], func[6])
end
end

Expand Down
1 change: 1 addition & 0 deletions data/scripts/lib/create_functions.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
createFunctions(MonsterType) -- creates get/set functions for MonsterType
createFunctions(Spell) -- creates get/set functions for Spell
createFunctions(ItemType) -- creates get/set functions for ItemType