• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

RevScripts Modal to open a list of items within another list of items.

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
554
Solutions
1
Reaction score
61
Location
Lo Mochis, Sinaloa
Hi!, I want to create my own crafting system, but I don't understand the modalwindow, for example, that when clicking on any item, in this case an anvil, a modal window opens, with a list of options like "leather equipment", "steel equipment", "gold equipment", etc... and when you choose one, it will open another list with the parts of the equipment you want to craft.
 
Hi!, I want to create my own crafting system, but I don't understand the modalwindow, for example, that when clicking on any item, in this case an anvil, a modal window opens, with a list of options like "leather equipment", "steel equipment", "gold equipment", etc... and when you choose one, it will open another list with the parts of the equipment you want to craft.
What tfs version are you using?
 
An example that you can do:

Actions: (onUse anvil, or another item of your choice)

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local modalWindow = ModalWindow(1, "Crafting", "Select the material:")

    modalWindow:addChoice(1, "Steel")
    modalWindow:addChoice(2, "Bronze")
    modalWindow:addChoice(3, "Leather")
    modalWindow:addChoice(4, "Iron")

    modalWindow:addButton(1, "Select")
    modalWindow:setDefaultEnterButton(1)
    modalWindow:addButton(2, "Cancel")
    modalWindow:setDefaultEscapeButton(2)
        
    modalWindow:sendToPlayer(player)
    
    return false
end

In creaturescripts
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    if modalWindowId ~= 1 or buttonId == 2 then
        return false
    end

    if choiceId == 1 then -- steel
        if buttonId == 1 then
            local modalSteel = ModalWindow(2, "Crafting Steel", "Select the equipment:")
            modalSteel:addChoice(1, "Steel Helmet")
            modalSteel:addChoice(2, "Steel Armor")
            modalSteel:addChoice(3, "Steel Legs")
            modalSteel:addChoice(4, "Steel Boots")
            
            modalSteel:addButton(1, "Select")
            modalSteel:setDefaultEnterButton(1)
            modalSteel:addButton(2, "Cancel")
            modalSteel:setDefaultEscapeButton(2)
            
            modalSteel:sendToPlayer(player)
        end
        
    elseif choiceId == 2 then -- bronze
        if buttonId == 1 then
            local modalBronze = ModalWindow(3, "Crafting Bronze", "Select the equipment:")
            modalBronze:addChoice(1, "Bronze Helmet")
            modalBronze:addChoice(2, "Bronze Armor")
            modalBronze:addChoice(3, "Bronze Legs")
            modalBronze:addChoice(4, "Bronze Boots")
            
            modalBronze:addButton(1, "Select")
            modalBronze:setDefaultEnterButton(1)
            modalBronze:addButton(2, "Cancel")
            modalBronze:setDefaultEscapeButton(2)
            
            modalBronze:sendToPlayer(player)
        end
            
    elseif choiceId == 3 then -- leather
        if buttonId == 1 then
            local modalLeather = ModalWindow(4, "Crafting Leather", "Select the equipment:")
            modalLeather:addChoice(1, "Leather Helmet")
            modalLeather:addChoice(2, "Leather Armor")
            modalLeather:addChoice(3, "Leather Legs")
            modalLeather:addChoice(4, "Leather Boots")
            
            modalLeather:addButton(1, "Select")
            modalLeather:setDefaultEnterButton(1)
            modalLeather:addButton(2, "Cancel")
            modalLeather:setDefaultEscapeButton(2)
            
            modalLeather:sendToPlayer(player)
        end
            
    elseif choiceId == 4 then -- iron
        if buttonId == 1 then
            local modalIron = ModalWindow(5, "Crafting Iron", "Select the equipment:")
            modalIron:addChoice(1, "Iron Helmet")
            modalIron:addChoice(2, "Iron Armor")
            modalIron:addChoice(3, "Iron Legs")
            modalIron:addChoice(4, "Iron Boots")
            
            modalIron:addButton(1, "Select")
            modalIron:setDefaultEnterButton(1)
            modalIron:addButton(2, "Cancel")
            modalIron:setDefaultEscapeButton(2)
            
            modalIron:sendToPlayer(player)
        end
    end
    
    return true
end

And then create a modal creaturescript for each material equipments.
 
Back
Top