Any fix to that? Having same problemNice script !!
Is working all at 90%
Just while clicking on Details it doesnt show the Windows , just like 3 seconds and disappear,
You need press Exit, and it shows the recipe, can be changed to show it directly while clicking on details ?
I believe I had the same issue.Are you sure you have the right itemID? Think that fixed it for meAny fix to that? Having same problem
regards
Fixed that myselfI believe I had the same issue.Are you sure you have the right itemID? Think that fixed it for me
function capAll(str)
local newStr = ""; wordSeparate = string.gmatch(str, "([^%s]+)")
for v in wordSeparate do
v = v:gsub("^%l", string.upper)
if newStr ~= "" then
newStr = newStr.." "..v
else
newStr = v
end
end
return newStr
end
-- Main Crafting Window -- This is the modal window that is displayed first
function Player:sendMainCraftWindow(config)
local function buttonCallback(button, choice)
-- Modal Window Functionallity
if button.text == "Select" then
self:sendVocCraftWindow(config, choice.id)
end
end
-- Modal window design
local window = ModalWindow {
title = config.mainTitleMsg, -- Title of the main craft modal window
message = config.mainMsg.."\n\n" -- Message of the main craft modal window
}
-- Add buttons to the window (Note: if you change the names of these you must change the functions in the modal window functionallity!)
window:addButton("Select", buttonCallback)
window:addButton("Exit", buttonCallback)
-- Add choices from the action script
for i = 1, #config.system do
window:addChoice(config.system[i].vocation)
end
-- Set what button is pressed when the player presses enter or escape.
window:setDefaultEnterButton("Select")
window:setDefaultEscapeButton("Exit")
-- Send the window to player
window:sendToPlayer(self)
end
-- End of the first modal window
-- This is the modal window that displays all avalible items for the chosen vocation.
function Player:sendVocCraftWindow(config, lastChoice)
local function buttonCallback(button, choice)
-- Modal Window Functionallity
-- If the user presses the back button they will be redirected to the main window.
if button.text == "Back" then
self:sendMainCraftWindow(config)
end
-- If the user presses the details button they will be redirected to a text window with information about the item they want to craft.
if button.text == "Details" then
local item = config.system[lastChoice].items[choice.id].item
local details = "In order to craft "..item.." you must collect the following items.\n\nRequired Items:"
for i = 1, #config.system[lastChoice].items[choice.id].reqItems do
local reqItems = config.system[lastChoice].items[choice.id].reqItems[i].item
local reqItemsCount = config.system[lastChoice].items[choice.id].reqItems[i].count
local reqItemsOnPlayer = self:getItemCount(config.system[lastChoice].items[choice.id].reqItems[i].item)
details = details.."\n- "..capAll(getItemName(reqItems).." ["..reqItemsOnPlayer.."/"..reqItemsCount.."]")
end
self:showTextDialog(item, details)
end
-- if the player presses the craft button then begin checks.
if button.text == "Craft" then
-- Check if player has required items to craft the item. If they dont send needItems message.
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
-- Remove the required items and there count from the player.
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
-- Send effect and give player item.
self:addItem(config.system[lastChoice].items[choice.id].itemID)
self:getPosition():sendMagicEffect(CONST_ME_FIREATTACK)
end
end
-- Modal window design
local window = ModalWindow {
title = config.craftTitle..config.system[lastChoice].vocation, -- The title of the vocation specific window
message = config.craftMsg..config.system[lastChoice].vocation..".\n\n", -- The message of the vocation specific window
}
-- Add buttons to the window (Note: if you change the names of these you must change the functions in the modal window functionallity!)
window:addButton("Back", buttonCallback)
window:addButton("Exit")
window:addButton("Details", buttonCallback)
window:addButton("Craft", buttonCallback)
-- Set what button is pressed when the player presses enter or escape
window:setDefaultEnterButton("Craft")
window:setDefaultEscapeButton("Exit")
-- Add choices from the action script
for i = 1, #config.system[lastChoice].items do
window:addChoice(config.system[lastChoice].items[i].item)
end
-- Send the window to player
window:sendToPlayer(self)
end
The fix is Easy,Any fix to that? Having same problem
regards
end
tag remove self:sendVocCraftWindow(config, lastChoice)
self:showTextDialog(item, details)
local window = ModalWindow {
title = "Recipe",
message = details,
}
window:addButton("Go Back", function() self:sendVocCraftWindow(config, lastChoice) end)
window:sendToPlayer(self)
technically i was already thinking about it you could use opcodes to open container that is 1x1 width and height and displays item that does not respond to :hover or click etcIn Case its not important you want to see the picture of the item crafted and you wish a Button 'Back' while looking the recipe,
add on "Details" at the final:
Remove this:
Lua:self:showTextDialog(item, details)
Replace:
Lua:local window = ModalWindow { title = "Recipe", message = details, } window:addButton("Go Back", function() self:sendVocCraftWindow(config, lastChoice) end) window:sendToPlayer(self)
It will replace the "Book" view to a Modal Windows, then it add's a button "Go Back" to the category.
Doing that the problem is you lose the picture of the item view on recipe.
Of course, one day when we reach higher lua you will be able to add pictures on modal windows.
Will this work in revscripts? I do not know where to add this.Hello,
Wasn't going to release this because there is already a couple but open source right?
Like always it is using @Non Sequitur modal window system which can be found HERE
You will have to install that in order to be able to use this system.
Pictures
Main Screen
Selection Screen
Item Selection Screen (Please note pressing ok brings you back to the selection screen.)
Why use this?
Much cleaner then all the other crafting systems.. easy configurable and you just need to add the action script and the lib files. There is no need to register the scripts on login.lua or add creaturescripts!
Information on the system
It has an easy config section for you to customize it how you would like it! You just need to fill out the config table found in the action script (pictured below)
Code:-- Window Config mainTitleMsg = "Crafting System", -- Main window title mainMsg = "Welcome to the crafting system. Please choose a vocation to begin.", -- Main window message craftTitle = "Crafting System: ", -- Title of the crafting screen after player picks of vocation craftMsg = "Here is a list of all items that can be crafted for the ", -- Message on the crafting screen after player picks of vocation -- End Window Config -- Player Notifications Config needItems = "You do not have all the required items to make ", -- This is the message the player recieves if he does not have all required items -- Crafting Config system = { [1] = {vocation = "Master Sorcerer", -- This is the category can be anything. items = { [1] = {item = "Shadow's Sceptre", -- item name (THIS MUST BE EXACT OR IT WILL NOT WORK!) itemID = 25249, -- item to be made reqItems = { -- items and the amounts in order to craft. [1] = {item = 25224, count = 50}, -- Silver Tokens [2] = {item = 9969, count = 1}, -- Black Skull [3] = {item = 5904, count = 30}, -- Magic Sulphur [4] = {item = 7451, count = 1}, -- Shadow Sceptre [5] = {item = 22396, count = 50}, -- Cluster of Solace }, },
Installation
1) Install the modal window helper HERE
2) Register the script in /data/actions/actions.xml by adding this line (Replacing "ITEMID" with the item you want to use:
3) Create a new text document in /data/actions/scripts and name it "crafting.lua" and paste the following:Code:<action itemid="ITEMID" script="crafting.lua"/>
local config = {-- Window Config mainTitleMsg = "Crafting System", -- Main w - Pastebin.com (http://pastebin.com/dF2Qp7wx)
4) Add the following line to your global.lua:
5) Create a new text document in /data/lib/ and name it "crafting.lua" and paste the following:Code:dofile('data/lib/crafting.lua')
-- Main Crafting Window -- This is the modal window that is displayed first fu - Pastebin.com (http://pastebin.com/5QwAviAP)
Enjoy =)
action = Action()
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
function action.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
action:id(Your_Item_Id)
action:register()
It is automatically set to display the names of the items and quantities, etc. It's already done. All you need to do is install everything until you must notice this comment and make the changes, and you're good to go. Everything is functioning as you wanted it to.I know this is an old thread by now, but I was wondering if its possible to display the item description for the item you want to crafts, within in "Details" window? So if you add a item description in item.xml it displays that description somewhere on the "Details" window in the crafting system?
Hope someone can provide me with some info about this.
Thanks
In Case its not important you want to see the picture of the item crafted and you wish a Button 'Back' while looking the recipe,
add on "Details" at the final:
Remove this:
Lua:self:showTextDialog(item, details)
Replace:
Lua:local window = ModalWindow { title = "Recipe", message = details, } window:addButton("Go Back", function() self:sendVocCraftWindow(config, lastChoice) end) window:sendToPlayer(self)
It will replace the "Book" view to a Modal Windows, then it add's a button "Go Back" to the category.
Doing that the problem is you lose the picture of the item view on recipe.
Of course, one day when we reach higher lua you will be able to add pictures on modal windows.
Thank you for your answerIt is automatically set to display the names of the items and quantities, etc. It's already done. All you need to do is install everything until you must notice this comment and make the changes, and you're good to go. Everything is functioning as you wanted it to.
\/
<item id="26735" name="seal of the shieldmaiden">
<attribute key="weight" value="900" />
[B] <attribute key="description" value="+2 shielding, +15 hp, -25 mp" />[/B]
</item>
I managed to install it from this link here, which displays a simple image and information about the item. However, it's still possible to add a description of the item if you'd like to understand more.Thank you for your answer
Iam not sure if it made sense what I said, but what I meant was that I want the "Details" window to show the item description aswell as the name of the item and the required items to craft.
This part of the item:
XML:<item id="26735" name="seal of the shieldmaiden"> <attribute key="weight" value="900" /> [B] <attribute key="description" value="+2 shielding, +15 hp, -25 mp" />[/B] </item>
So that the player actually know more about the item they are going to craft.
If possible, it would also be nice if it could provide the player with all the info about the item that is written in items.xml, so that the player knows the stats of an item, the weight and the description.
Ps, I like how the text was displayed in the script you provided, but can you include the image of the item aswell?
- Erik
<attribute key="description" value="Spell: Bear Claw. This spells targets a single enemy in front on you. It does initial damage calculated by this formula: (player:getLevel() / 5) + (skill * attack * 0.08) + 17, and bleed damage calculated by this formula: (creature:getLevel() / 3) + (skill * 0.4) + 8." />
Is possible.Thank you again for your answer
Yes I kinda have this working now, but I want to make it so that people can see the "Items Attributes" when clicking on the "Details" button, like in this example:
View attachment 81768
XML:<attribute key="description" value="Spell: Bear Claw. This spells targets a single enemy in front on you. It does initial damage calculated by this formula: (player:getLevel() / 5) + (skill * attack * 0.08) + 17, and bleed damage calculated by this formula: (creature:getLevel() / 3) + (skill * 0.4) + 8." />
This will give the player information to make a choice of which item they want to "craft", so they can make a decision based on good information.
for i = 1, #config.system[lastChoice].items[choice.id].reqItems do
local reqItems = config.system[lastChoice].items[choice.id].reqItems[i].item
local reqItemsCount = config.system[lastChoice].items[choice.id].reqItems[i].count
local reqItemsOnPlayer = self:getItemCount(reqItems)
details = details .. "\n- " .. capAll(getItemName(reqItems) .. " { " .. reqItemsOnPlayer .. "/" .. reqItemsCount .. " }")
end
local itemId = config.system[lastChoice].items[choice.id].itemID
local itemType = ItemType(itemId)
if itemType then
local attributes = {
"Attack",
}
for _, attributeName in ipairs(attributes) do
local attributeValue = itemType:getAttack()
local attributeValue2 = itemType:getDefense()
local attributeValue3 = itemType:getAbilities()
local skills = attributeValue3.skills
if attributeValue or attributeValue2 or attributeValue3 then
details = details .. "\n- Attack: " .. attributeValue
details = details .. "\n- Defense" .. attributeValue2
for i = 1, 5 do
local skillValue = skills[i]
details = details .. "\n- Abilities" .. skillValue
end
end
end
end
Thank you SO much my friend. I will test this <3Is possible.
But inside of the modal windows and not outside, near the picture.
You need get all the values in order to show for example the correct abilities with correct name.
Since in order to get Item Attributes you need use: ItemType, then here you can get the Attack, Defense, Abilities, HitChance, etc.
Abilities means, Skill, absorb.... And here is that you need create a for loop for each ability in order to show it, but also add the correct name for each one ( here i leave it to you the code how i have done this, don't have time to finish it ).
View attachment 81793
So here it shows that grand Sanguine Crossbow has 10 attack ( true in my case ), then abilities 4 for example is the Skill Dist, as other ones are sword/club...
After this code:
Lua:for i = 1, #config.system[lastChoice].items[choice.id].reqItems do local reqItems = config.system[lastChoice].items[choice.id].reqItems[i].item local reqItemsCount = config.system[lastChoice].items[choice.id].reqItems[i].count local reqItemsOnPlayer = self:getItemCount(reqItems) details = details .. "\n- " .. capAll(getItemName(reqItems) .. " { " .. reqItemsOnPlayer .. "/" .. reqItemsCount .. " }") end
add this one ( that show item description ):
Code:local itemId = config.system[lastChoice].items[choice.id].itemID local itemType = ItemType(itemId) if itemType then local attributes = { "Attack", } for _, attributeName in ipairs(attributes) do local attributeValue = itemType:getAttack() local attributeValue2 = itemType:getDefense() local attributeValue3 = itemType:getAbilities() local skills = attributeValue3.skills if attributeValue or attributeValue2 or attributeValue3 then details = details .. "\n- Attack: " .. attributeValue details = details .. "\n- Defense" .. attributeValue2 for i = 1, 5 do local skillValue = skills[i] details = details .. "\n- Abilities" .. skillValue end end end end
the local attributes, leave it with the Attack ,
AttributeValue, first one is getAttack , for weapons
AttributeValue2, in order to getDefense,
AttributeValue3, is Abilities, but here we called only about Skills since, abilities has much more information, such as absorb, Mana, Health, Stats, Special Skills (crit..), etc.
Hi there my friend. First off, thank you for putting time into helping meIs possible.
But inside of the modal windows and not outside, near the picture.
You need get all the values in order to show for example the correct abilities with correct name.
Since in order to get Item Attributes you need use: ItemType, then here you can get the Attack, Defense, Abilities, HitChance, etc.
Abilities means, Skill, absorb.... And here is that you need create a for loop for each ability in order to show it, but also add the correct name for each one ( here i leave it to you the code how i have done this, don't have time to finish it ).
View attachment 81793
So here it shows that grand Sanguine Crossbow has 10 attack ( true in my case ), then abilities 4 for example is the Skill Dist, as other ones are sword/club...
After this code:
Lua:for i = 1, #config.system[lastChoice].items[choice.id].reqItems do local reqItems = config.system[lastChoice].items[choice.id].reqItems[i].item local reqItemsCount = config.system[lastChoice].items[choice.id].reqItems[i].count local reqItemsOnPlayer = self:getItemCount(reqItems) details = details .. "\n- " .. capAll(getItemName(reqItems) .. " { " .. reqItemsOnPlayer .. "/" .. reqItemsCount .. " }") end
add this one ( that show item description ):
Code:local itemId = config.system[lastChoice].items[choice.id].itemID local itemType = ItemType(itemId) if itemType then local attributes = { "Attack", } for _, attributeName in ipairs(attributes) do local attributeValue = itemType:getAttack() local attributeValue2 = itemType:getDefense() local attributeValue3 = itemType:getAbilities() local skills = attributeValue3.skills if attributeValue or attributeValue2 or attributeValue3 then details = details .. "\n- Attack: " .. attributeValue details = details .. "\n- Defense" .. attributeValue2 for i = 1, 5 do local skillValue = skills[i] details = details .. "\n- Abilities" .. skillValue end end end end
the local attributes, leave it with the Attack ,
AttributeValue, first one is getAttack , for weapons
AttributeValue2, in order to getDefense,
AttributeValue3, is Abilities, but here we called only about Skills since, abilities has much more information, such as absorb, Mana, Health, Stats, Special Skills (crit..), etc.
<item id="27090" name="spellbook 1">
<attribute key="weight" value="320" />
<attribute key="description" value="Death Touch: This spell touches a single target with the range of 1. Freezes enemy and add death damage to target" />
<attribute key="showcount" value="0" />
</item>
<attribute key="description" value="Death Touch: This spell touches a single target with the range of 1. Freezes enemy and add death damage to target" />
Hi there my friend. First off, thank you for putting time into helping me
Second, Not sure if i made it clear, but what I want is for the item Description to show aswell.
Example:
XML:<item id="27090" name="spellbook 1"> <attribute key="weight" value="320" /> <attribute key="description" value="Death Touch: This spell touches a single target with the range of 1. Freezes enemy and add death damage to target" /> <attribute key="showcount" value="0" /> </item>
This needs to show inside the Details window:
XML:<attribute key="description" value="Death Touch: This spell touches a single target with the range of 1. Freezes enemy and add death damage to target" />
Is this possible?
int LuaScriptInterface::luaItemTypeGetDescription(lua_State* L)
{
// itemType:getDescription()
const ItemType* itemType = getUserdata<const ItemType>(L, 1);
if (itemType) {
pushString(L, itemType->description);
} else {
lua_pushnil(L);
}
return 1;
}
local itemId = config.system[lastChoice].items[choice.id].itemID
local itemType = ItemType(itemId)
if itemType then
local attributeValue = itemType:getDescription()
if attributeValue then
details = details .."\n- Description:" .. attributeValue
end
end