alejandro762
Well-Known Member
- Joined
- Sep 6, 2021
- Messages
- 225
- Reaction score
- 64
Hello everyone
I wish to know if is possible to add a Level and experience system on a modal windows for craft ?
Since i tried with the right parts of level storage and experience storage, working on jobs, but pressing the button "craft" it doesn't show any error and not work.
here is my script
I tried on both, on the action script also on the lib file of modalwindows , if is needed the lib file i will post it
Thanks in advance
The part of Lib while i tried to add the exp & level:
The Parts / Functions i used to create the Experience & Level system on it (made by xikini):
I wish to know if is possible to add a Level and experience system on a modal windows for craft ?
Since i tried with the right parts of level storage and experience storage, working on jobs, but pressing the button "craft" it doesn't show any error and not work.
here is my script
I tried on both, on the action script also on the lib file of modalwindows , if is needed the lib file i will post it
Thanks in advance
Lua:
local skinningCraft = Action()
function capAll(str)
return str:gsub("^(%a)", string.upper):gsub("([^%a]%a)", string.upper)
end
local config = {
mainTitleMsg = "Skinning Craft",
mainMsg = "Welcome to the Skinning Craft System.\nPlease choose a category:",
craftTitle = "Skinning Craft: ",
craftMsg = "Click on Recipe to see the necessary items to craft an item.\n\nHere is a list of all items that can be crafted for the category:",
needItems = "You do not have all the required items to make ",
system = {
[1] = {tiers = "Ressources",
items = {
[1] = {item = "Hardened Skin",
itemID = 10104,
reqItems = {
[1] = {item = 10124, count = 10}, -- 2 Dorsal Fur
[2] = {item = 10137, count = 10}, -- 2 Monster Jaws
[3] = {item = 10128, count = 10}, -- 1 Clog
},
},
[2] = {item = "Monster Skull",
itemID = 10131,
reqItems = {
[1] = {item = 10136, count = 3}, -- 3 Skull of dragon
[2] = {item = 10106, count = 3}, -- 3 Giant Monster Scale
},
},
[3] = {item = "Tail Bone",
itemID = 10129,
reqItems = {
[1] = {item = 10032, count = 10}, -- 10 Monster Pawn
[2] = {item = 10100, count = 3}, -- 3 Large chunk of meat
},
},
[4] = {item = "Monster Horn",
itemID = 10130,
reqItems = {
[1] = {item = 10126, count = 3}, -- 3 Fractured Bones
[2] = {item = 10125, count = 3}, -- 3 Monster Tail
},
},
[5] = {item = "Golden Dragon Scale",
itemID = 10133,
reqItems = {
[1] = {item = 10134, count = 10}, -- 10 Silver Dragon Scale
[2] = {item = 10122, count = 1}, -- 1 Rare Leather
},
},
[6] = {item = "Dorsal Bone",
itemID = 10139,
reqItems = {
[1] = {item = 10109, count = 3}, -- 3 Giant monster ribs
[2] = {item = 10138, count = 2}, -- 2 Vertebral Column
},
},
},
},
},
}
function skinningCraft.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
player:sendMainCraftWindow(config)
return true
end
skinningCraft:id(13946)
skinningCraft:register()
The part of Lib while i tried to add the exp & level:
Code:
if button.text == "Craft" then
local item = config.system[lastChoice].items[choice.id].item
for i = 1, #config.system[lastChoice].items[choice.id].reqItems do
if self:getItemCount(config.system[lastChoice].items[choice.id].reqItems[i].item) < config.system[lastChoice].items[choice.id].reqItems[i].count then
self:say(config.needItems..config.system[lastChoice].items[choice.id].item, TALKTYPE_MONSTER_SAY)
return false
end
end
for i = 1, #config.system[lastChoice].items[choice.id].reqItems do
self:removeItem(config.system[lastChoice].items[choice.id].reqItems[i].item, config.system[lastChoice].items[choice.id].reqItems[i].count)
end
self:addItem(config.system[lastChoice].items[choice.id].itemID)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have crafted "..item..".")
self:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
end
The Parts / Functions i used to create the Experience & Level system on it (made by xikini):
Code:
local Herbalist = {
maxLevel = 400,
experiencePerLevel = 500,
storage = {
level = 45007,
experience = 45008
},
}
local function giveHerbalistExperience(playerId, amount)
local player = Player(playerId)
if not player then
print("Error in function giveHerbalistExperience -> player does not exist (check to ensure playerId being passed to function is correct)")
return false
end
local HerbalistLevel = player:getStorageValue(Herbalist.storage.level)
HerbalistLevel = HerbalistLevel >= 0 and HerbalistLevel or 0
local HerbalistExperience = player:getStorageValue(Herbalist.storage.experience)
HerbalistExperience = HerbalistExperience >= 0 and HerbalistExperience or 0
HerbalistExperience = HerbalistExperience + amount
if HerbalistLevel < Herbalist.maxLevel then
repeat
local ExperienceRequiredForNextLevel = HerbalistLevel * Herbalist.experiencePerLevel
if HerbalistExperience >= ExperienceRequiredForNextLevel then
HerbalistExperience = HerbalistExperience - ExperienceRequiredForNextLevel
HerbalistLevel = HerbalistLevel + 1
local text = "You have advanced to Herbalist level " .. HerbalistLevel .. "."
if HerbalistLevel == Herbalist.maxLevel then
text = "You have reached the maximum Herbalist level."
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
else
break
end
until (HerbalistLevel == Herbalist.maxLevel)
end
player:setStorageValue(Herbalist.storage.level, HerbalistLevel)
player:setStorageValue(Herbalist.storage.experience, HerbalistExperience)
return true
end
-- after function:
local levels = {
expgainmin = 125, -- DO NOT CHANGE !
expgainmax = 225, -- DO NOT CHANGE !
}
local experienceRan = math.random(levels.expgainmin, levels.expgainmax)
if giveHerbalistExperience(player:getId(), experienceRan) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have gained "..experienceRan.." experience on herbalist job.")
end