• 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!

[TFS 1.2] Simple Crafting System.

MyksaND

Just DO ITTT!
Joined
Mar 5, 2020
Messages
9
Reaction score
0
[Error - CreatureEvent::configureEvent] Invalid type for creature event: ModalWindowHelper
[Warning - BaseEvents::loadFromXml] Failed to configure event
i follow all help me plx :/ (i installing modal window)
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
532
[Error - CreatureEvent::configureEvent] Invalid type for creature event: ModalWindowHelper
[Warning - BaseEvents::loadFromXml] Failed to configure event
i follow all help me plx :/ (i installing modal window)


You have not installed the Modal Window Helper correctly..

Double check what you have done. I believe in you!
 

MyksaND

Just DO ITTT!
Joined
Mar 5, 2020
Messages
9
Reaction score
0
This is a Modalwindow with modalwindowhelper

Modalwindow.lua

Lua:
if not modalWindows then
    modalWindows = {
        modalWindowConstructor = ModalWindow,
        nextFreeId = 500,

        windows = {}
    }
end

local MT = {}
MT.__index = MT

function ModalWindow(...)
    local args = {...}
    if type(args[1]) == 'table' then
        local self = setmetatable(args[1], MT)
        local id = modalWindows.nextFreeId    
        self.id = id
        self.buttons = {}
        self.choices = {}
        self.players = {}
        self.created = false

        modalWindows.nextFreeId = id + 1
        table.insert(modalWindows.windows, self)
        return self
    end

    return modalWindows.modalWindowConstructor(...)
end

function MT:setDefaultCallback(callback)
    self.defaultCallback = callback
end

function MT:addButton(text, callback)
    local button = {text = tostring(text), callback = callback}
    table.insert(self.buttons, button)
    return button
end

function MT:addButtons(...)
    for _, text in ipairs({...}) do
        table.insert(self.buttons, {text = tostring(text)})
    end
end

function MT:addChoice(text)
    local choice = {text = tostring(text)}
    table.insert(self.choices, choice)
    return choice
end

function MT:addChoices(...)
    for _, text in ipairs({...}) do
        table.insert(self.choices, {text = tostring(text)})
    end
end

function MT:setDefaultEnterButton(text)
    self.defaultEnterButton = text
end

function MT:setDefaultEscapeButton(text)
    self.defaultEscapeButton = text
end

function MT:setTitle(title)
    self.title = tostring(title)
end

function MT:setMessage(message)
    self.message = tostring(message)
end

local buttonOrder = {
    [4] = {3, 4, 2, 1},
    [3] = {2, 3, 1},
    [2] = {1, 2},
    [1] = {1}
}
function MT:create()
    local modalWindow = modalWindows.modalWindowConstructor(self.id, self.title, self.message)
    local order = buttonOrder[math.min(#self.buttons, 4)]

    if order then
        for _, i in ipairs(order) do
            local button = self.buttons[i]
            modalWindow:addButton(i, button.text)
            button.id = i

            if button.text == self.defaultEnterButton then
                modalWindow:setDefaultEnterButton(i)
            elseif button.text == self.defaultEscapeButton then
                modalWindow:setDefaultEscapeButton(i)
            end
        end
    end

    for _, choice in ipairs(self.choices) do
        modalWindow:addChoice(_, choice.text)
        choice.id = _
    end

    self.modalWindow = modalWindow
end

function MT:sendToPlayer(player)
    if not self.modalWindow then
        self:create()
    end

    player:registerEvent('ModalWindowHelper')
    self.players[player:getId()] = true
    return self.modalWindow:sendToPlayer(player)
end


in lib/lib.lua
Code:
dofile('data/lib/modalwindow.lua')


creaturscripts/scripts/moldalwindowhelper.lua

Lua:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    local modalWindow
    for _, window in ipairs(modalWindows.windows) do
        if window.id == modalWindowId then
            modalWindow = window
            break
        end
    end

    if not modalWindow then
        return true
    end

    local playerId = player:getId()
    if not modalWindow.players[playerId] then
        return true
    end
    modalWindow.players[playerId] = nil

    local choice = modalWindow.choices[choiceId]

    for _, button in ipairs(modalWindow.buttons) do
        if button.id == buttonId then
            local callback = button.callback or modalWindow.defaultCallback
            if callback then
                callback(button, choice)
                break
            end
        end
    end

    return true
end

register in creaturescripts .xml

Lua:
    <event type="modalwindow" name="modalwindowhelper" script="modalwindowhelper.lua" />

i think this is all from modalwindow :/ i check 100x times xD but maybe can be for a problem of compilate? idk bro i want this script is very nice... T_T
Post automatically merged:

ok well i read for others not work with 8.6 aff thx for respond before! ;)
 
Last edited:

MopdaAll

New Member
Joined
May 29, 2020
Messages
26
Reaction score
1
How do you put options of how many items you want to be crafted of a specific itemid? like 2, 5, 10, 25, 50.
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
532
Do you mean craft multiple of the same item?

Like i want to craft this item 5 times rather than clicking 5 times?
 

Morineau

pig benis
Joined
Jul 19, 2009
Messages
37
Reaction score
2
Can you help me fix this error?

Lua Script Error: [Action Interface]
data/actions/scripts/crafting.lua:eek:nUse
data/actions/scripts/crafting.lua:256: attempt to call method 'sendMainCraftWindow' (a nil value)
stack traceback:
[C]: in function 'sendMainCraftWindow'
data/actions/scripts/crafting.lua:256: in function <data/actions/scripts/crafting.lua:255>

Thanks!
 

Guerra

New Member
Joined
May 1, 2018
Messages
57
Reaction score
2
Location
Natal/RN - Brasil
forgive me for reliving this topic, the system is just great i would like to ask for help in two things.

1º - how to modify the script so that the craft item had the name of the person who made it in the description?
2º - I would like to add a chance of a percentage failure in craft attempts, thus making the system more fun.

thank you so much for any help !!
 

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
217
Solutions
3
Reaction score
20
Location
Hell
forgive me for reliving this topic, the system is just great i would like to ask for help in two things.

1º - how to modify the script so that the craft item had the name of the person who made it in the description?
2º - I would like to add a chance of a percentage failure in craft attempts, thus making the system more fun.

thank you so much for any help !!
I was thinking on adding something like this Adding New Skills tfs1.3, I mean adding Crafting as skill. Then set Crafting level as limit to be able to create such item. This skill could be used also for a system that increases your Crafting tries whenever you retreive crafting items with any tool, like adding a new action function to the shovel. This is just and idea I'm having, if I achieve something I will be sharing here!
 

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
217
Solutions
3
Reaction score
20
Location
Hell
Is it possible to make it look like this?
Sin título.png
1. Adding an amount slider to craft more than 1 item and also spending the required items * n?
2. Showing the description on the side or below the crafting window?
 

devzan14

Member
Joined
Feb 3, 2015
Messages
63
Reaction score
5
I searched through thread and i see other people have this error as well, but i don't see a solution.

Clicking "Details" doesnt work. Console log:

1615661862547.png

Tried to capitalize all words (as well categories as items to craft), nothing changed.
 

namco

Alienbutserious
Joined
Sep 5, 2010
Messages
149
Solutions
2
Reaction score
39
I searched through thread and i see other people have this error as well, but i don't see a solution.

Clicking "Details" doesnt work. Console log:

View attachment 56227

Tried to capitalize all words (as well categories as items to craft), nothing changed.

I'm using TFS 1.3 and I've got the same problem, but I solved it simply. Check it out:

data/lib/crafting.lua

line 55
change:
Lua:
details = details.."\n- "..capAll(getItemName(reqItems).." ["..reqItemsOnPlayer.."/"..reqItemsCount.."]")

to:
Lua:
details = details.."\n- "..getItemName(reqItems).." ["..reqItemsOnPlayer.."/"..reqItemsCount.."]"
 

devzan14

Member
Joined
Feb 3, 2015
Messages
63
Reaction score
5
I'm using TFS 1.3 and I've got the same problem, but I solved it simply. Check it out:

data/lib/crafting.lua

line 55
change:
Lua:
details = details.."\n- "..capAll(getItemName(reqItems).." ["..reqItemsOnPlayer.."/"..reqItemsCount.."]")

to:
Lua:
details = details.."\n- "..getItemName(reqItems).." ["..reqItemsOnPlayer.."/"..reqItemsCount.."]"

Mate you're the best! Thanks!
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
532
Top