Emulating RTC's COMBINE
Posted: Sun Mar 04, 2012 6:19 pm
How can I do something like RTCs COMBINE -- where you have two items in the players hands and you can combine them into one new item?
The 'Dungeon Master' video games community
https://www.dungeon-master.com/forum/
Code: Select all
function create_potion(atype, ppos, who, pow, skill, delay)
local flask = find_arch_in_hand(who, "flask", needs_an_empty_flask)
if (flask) then
dsb_swap(flask, atype.potion)
exvar[flask] = { power = pow }
else
return true
end
return false, flask
end
Code: Select all
obj1 = find_arch_in_hand(who, "first_arch")
obj2 = find_arch_in_hand(who, "second_arch")
if (obj1 and obj2) then
dsb_swap(obj1, "something_else")
dsb_delete(obj2)
end
Code: Select all
function find_arch_in_hand(who, archname, failmsg)
local look = dsb_fetch(CHARACTER, who, INV_L_HAND, 0)
if (not look or dsb_find_arch(look) ~= obj[archname]) then
look = dsb_fetch(CHARACTER, who, INV_R_HAND, 0)
if (not look or dsb_find_arch(look) ~= obj[archname]) then
if (failmsg) then
if (type(failmsg) == "function") then
failmsg(dsb_get_charname(who), archame)
else
dsb_write(system_color, failmsg)
end
end
return nil
end
end
return look
end
Code: Select all
if (type(failmsg) == "function") then
failmsg(dsb_get_charname(who), archame)
else
dsb_write(system_color, failmsg)
end