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

Lua Update script to TFS 1.3

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
291
Solutions
1
Reaction score
36
Hello guys, I found this script in another forum of tibia and I would like to update it to TFS 1.3 and also to not use as MOD, it can be actions, creaturescript, globalevent, anything but MOD.

Credits for the original script goes to: Dwarfer from tibiaking;

The script he made is for TFS 0.4 and uses MOD.
The script works like this:
  • Player uses bookshelf and receive a book.
  • If player uses command !book it will show all books the player received so far.
  • If player uses !book Name_of_the_book the book will appear to the player as a popup

[MOD]
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Book System" version="1.0" author="Dwarfer" contact="tibiaking.com" enabled="yes">
<config name="Book_func"><![CDATA[
books = {
[1] = {aid = 17710, title = "Criar cerveja", icon = 4839},
[2] = {aid = 17711, title = "Extended Vision", icon = 5898},
[3] = {aid = 17712, title = "Miners Journal", icon = 4874},
[4] = {aid = 17713, title = "Dwarfer, the legend", icon = 2322}
}

stories = {
[1] = {"Nenhum anão pode resistir a uma boa caneca de cerveja de Jimbin e essa magia um dia permitirá a você criar tal cerveja com alguns",
" ingredientes simples. Colete o cabelo de um troll, um cogumelo de qualquer tipo, um pequeno amontoado de alma do vale do mago louco um pouco",
" de água dos arredores do vale do mago louco e o silêncio antes do amanhecer. Coloque todos os ingredientes em um frasco de água do vale do mago",
" louco, tampe-o com uma rolha e ferva-o. Remova a rolha e ponha uma pequena amostra da poção em uma caneca e chacoalhe-a. Agora nós temos que",
" descobrir como introduzir o silêncio antes do amanhecer de uma maneira apropriada. Você deve então ter uma caneca cheia de cerveja se tudo",
" funcionar conforme calculado até aqui. Nós estimamos que uma poção deve ser uma semana de abastecimento de cerveja se você minimizar seu consumo",
" para 7 canecas por dia."
},

[2] = {"Most dwarves have a excellent eyesight even in dark enviroments but this spell will one day allow you to see nearly twice as far",
" as you currently do. What's needed is the fire of a fire element, the head of a ghoul,the essence of a red royal blossom, some",
" water from Blood Bay and the laugh of a mute sinner. Light a fire with the flame of the fire element. Pour the water from Blood",
" Bay into a cauldron and place it over the fire. Throw in the head of the ghoul and the essence of the red royal Blossom and mix",
" it untill a grey myst emerges.Take some of the potion and mix it with the laugh while cooling it. Now we only need to find out the",
" missing catalysts and the magic words to imbue it with energy."
},

[3] = {"We've dug that deep, that even we dwarves can hardly see. Fruzek told us stories of a monster making odd sounds from below the earth.",
" These frightening tales of the basilisk have halted our mining schedule, forcing us to double the guards protecting the miners."
},

[4] = {"Everybody knows the legend. The most powerful dwarf ever. His name? HOW COME DON'T YOU KNOW HIS NAME? (Orcs...) DWARFER, sure! Long live Dwarfer!"}
}

function setPlayerStorageTable(cid, storage, tab)
local tabstr = "&"
for i,x in pairs(tab) do
tabstr = tabstr .. i .. "," .. x .. ";"
end
setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end

function isInTable(cid, bookId)
for _,i in pairs(getPlayerStorageTable(cid, 17709))do
if tonumber(i) == tonumber(bookId) then
return true
end
end
return false
end

function addBookTable(cid, bookId)
local x = {}
for i = 1,#getPlayerStorageTable(cid, 17709) do
table.insert(x,getPlayerStorageTable(cid, 17709))
end
if x ~= 0 then
table.insert(x,tonumber(bookId))
setPlayerStorageTable(cid, 17709, x)
else
setPlayerStorageTable(cid, 17709, {bookId})
end
end

function getPlayerStorageTable(cid, storage)
local tabstr = getPlayerStorageValue(cid, storage)
local tab = {}
if type(tabstr) ~= "string" then
return {}
end
if tabstr:sub(1,1) ~= "&" then
return {}
end
local tabstr = tabstr:sub(2, #tabstr)
local a = string.explode(tabstr, ";")
for i,x in pairs(a) do
local b = string.explode(x, ",")
tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
end
return tab
end

function ShowLibrary(cid)
local str,n = "-- [My Library] --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 17709) do
n = n + 1
str = str..""..n.." - "..(getBookInfo(getPlayerStorageTable(cid, 17709)).title).."\n"
end
return doPlayerPopupFYI(cid, str)
end

function getBookInfo(param)
for i, v in pairs(books) do
if tonumber(param) == v.aid then
return {id = i, aid = param, title = v.title, icon = v.icon}
elseif tostring(param) == v.title then
return {id = i, aid = v.aid, title = tostring(param), icon = v.icon}
end
end
return {}
end

function hasAid(item)
for _, v in pairs(books) do
if item.actionid == v.aid then
return true
end
end
return false
end]]></config>

<action itemid="1718;1721" event="script"><![CDATA[
domodlib('Book_func')
if isInTable(cid, item.actionid) then
return doPlayerSendCancel(cid, "You have already know this book.")
end
if hasAid(item) then
addBookTable(cid, item.actionid)
doSendMagicEffect(fromPosition, 30)
doCreatureSay(cid, "You have found a mysterious book.", TALKTYPE_ORANGE_1)
end
]]></action>
<talkaction words="!book;/book" event="buffer"><![CDATA[
domodlib('Book_func')
local t = string.explode(string.lower(param), ",")
if not t[1] then
ShowLibrary(cid) return true
elseif tonumber(t[1]) then
doPlayerSendCancel(cid, "Enter !book Title to read.") return true
elseif tostring(t[1]) then
local b = getBookInfo(param)
if not isInTable(cid, b.aid) then
doPlayerSendCancel(cid, "There isn't this book in your personal library.") return true
end
doShowTextDialog(cid, b.icon, table.concat(stories[b.id])) return true
end
]]></talkaction>
</mod>
 
Solution
Still getting only book 1 after getting one diferente book.
Was a small typo
Lua:
local virtualLibrary = {
    -- {actionid&storage, itemidYouWantToShowInPicture, "Book title", "text inside"}
    {45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
    {45002, 1950, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
    {45003, 1950, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}


local action_virtualLibrary = Action()

function action_virtualLibrary.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local unknownBooks = {}
    for i = 1, #virtualLibrary do
        if player:getStorageValue(virtualLibrary[i][1]) < 1 then...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
yes, but I would like to make it other thing instead of MOD. My server doesn't have MOD
Just curious, does your server have data/scripts ?

That is the 1.3 revscripts folder, which is the new 'mod' folder, but in pure Lua, instead of xml

(since it's Lua and not xml, you can't put the 0.4 mod file in there and have it work, but it's easier to convert to revscripts instead of 3-5 smaller scripts in different directories.)
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
291
Solutions
1
Reaction score
36
yes, it does have it. What do you suggest?
Post automatically merged:

It does not need to be the same script as I mentioned, I just find it a nice idea of RPG for bookshelf gives books and those books will have some information for example about craft (system that my server has). Do you think it's easier to convert that script I gave as example or make a new one?
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
Just used your guidelines to script it from scratch. xP

  • Player uses bookshelf and receive a book.
  • If player uses command !book it will show all books the player received so far.
  • If player uses !book Name_of_the_book the book will appear to the player as a popup
Lua:
local virtualLibrary = {
    -- {actionid&storage, itemidYouWantToShowInPicture, "Book title", "text inside"}
    {45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
    {45002, 1950, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
    {45003, 1950, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}


local action_virtualLibrary = Action()

function action_virtualLibrary.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local actionId = item:getActionId()
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][1] == actionId then
            if player:getStorageValue(actionId) == 1 then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You've commited this book to your virtual library already.")
                return true
            end
            player:setStorageValue(actionId, 1)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You've found " .. virtualLibrary[i][3] .. ". This book is now available in your virtual library.")
            break
        end
    end    
    return true
end

for i = 1, #virtualLibrary do
    action_virtualLibrary:aid(virtualLibrary[i][1])
end
action_virtualLibrary:register()



local talkaction_virtualLibrary = TalkAction("/readfromlibrary", "!readfromlibrary")

function talkaction_virtualLibrary.onSay(player, words, param)
    if param == nil or param == "" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use /readfromlibrary list if you're unsure of the book title.")
        return false
    end
    local text = ""
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][3]:lower() == param:lower() then
            if player:getStorageValue(virtualLibrary[i][1]) < 1 then
                break
            end
            player:showTextDialog(virtualLibrary[i][2], virtualLibrary[i][3] .. "\n\n" .. virtualLibrary[i][4])
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing book: " .. virtualLibrary[i][3])
            return false
        end
        if param:lower() == "list" then
            if player:getStorageValue(virtualLibrary[i][1]) == 1 then
                if text ~= "" then
                    text = text .. "\n"
                end
                text = text .. virtualLibrary[i][3]
            end
        end
    end
    if param:lower() == "list" then
        if text == "" then
            text = "None."
        end
        player:showTextDialog(1950, "List of books in your virtual library:\n\n" .. text)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing virtual library list.")
        return false
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Unable to find " .. param .. " in your virtual library.")
    return false
end

talkaction_virtualLibrary:separator(" ")
talkaction_virtualLibrary:register()
 
Last edited:
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
291
Solutions
1
Reaction score
36
Just used your guidelines to script it from scratch. xP

  • Player uses bookshelf and receive a book.
  • If player uses command !book it will show all books the player received so far.
  • If player uses !book Name_of_the_book the book will appear to the player as a popup
Lua:
local virtualLibrary = {
    -- {actionid&storage, itemidYouWantToShowInPicture, "Book title", "text inside"}
    {45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
    {45002, 1950, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
    {45003, 1950, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}


local action_virtualLibrary = Action()

function action_virtualLibrary.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local actionId = item:getActionId()
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][1] == actionId then
            if player:getStorageValue(actionId) == 1 then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You've commited this book to your virtual library already.")
                return true
            end
            player:setStorageValue(actionId, 1)
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You've found " .. virtualLibrary[i][3] .. ". This book is now available in your virtual library.")
            break
        end
    end  
    return true
end

for i = 1, #virtualLibrary do
    action_virtualLibrary:aid(virtualLibrary[i][1])
end
action_virtualLibrary:register()



local talkaction_virtualLibrary = TalkAction("/readfromlibrary", "!readfromlibrary")

function talkaction_virtualLibrary.onSay(player, words, param)
    if param == nil or param == "" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use /readfromlibrary list if you're unsure of the book title.")
        return false
    end
    local text = ""
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][3]:lower() == param:lower() then
            if player:getStorageValue(virtualLibrary[i][1]) < 1 then
                break
            end
            player:showTextDialog(virtualLibrary[i][2], virtualLibrary[i][3] .. "\n\n" .. virtualLibrary[i][4])
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing book: " .. virtualLibrary[i][3])
            return false
        end
        if param:lower() == "list" then
            if player:getStorageValue(virtualLibrary[i][1]) == 1 then
                if text ~= "" then
                    text = text .. "\n"
                end
                text = text .. virtualLibrary[i][3]
            end
        end
    end
    if param:lower() == "list" then
        if text == "" then
            text = "None."
        end
        player:showTextDialog(1950, "List of books in your virtual library:\n\n" .. text)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing virtual library list.")
        return false
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Unable to find " .. param .. " in your virtual library.")
    return false
end

talkaction_virtualLibrary:separator(" ")
talkaction_virtualLibrary:register()
It works flawless, you're great.

Is it possible to add:
Player uses any bookshelf and receives random book?
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
It works flawless, you're great.

Is it possible to add:
Player uses any bookshelf and receives random book?
Use bookcase -> get random book
-> use same bookcase again -> get no book?

Or

Use bookcase -> get random book
Use bookcase -> get random book
Use bookcase -> get random book
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
The second option:

Use bookcase -> get random book
Lua:
local virtualLibrary = {
    -- {actionid&storage, itemidYouWantToShowInPicture, "Book title", "text inside"}
    {45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
    {45002, 1950, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
    {45003, 1950, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}


local action_virtualLibrary = Action()

function action_virtualLibrary.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local unknownBooks = {}
    for i = 1, #virtualLibrary do
        if player:getStorageValue(virtualLibrary[i][1]) < 1 then
            table.insert(unknownBooks, {i})
        end
    end
    if #unknownBooks < 1 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Your virtual library is complete. There is no more books available to learn.")
        return true
    end
    local randomBook = math.random(#unknownBooks)
    player:setStorageValue(virtualLibrary[randomBook][1], 1)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You've found " .. virtualLibrary[randomBook][3] .. ". This book is now available in your virtual library.")
    return true
end

action_virtualLibrary:aid(45000)
action_virtualLibrary:register()



local talkaction_virtualLibrary = TalkAction("/readfromlibrary", "!readfromlibrary")

function talkaction_virtualLibrary.onSay(player, words, param)
    if param == nil or param == "" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use /readfromlibrary list if you're unsure of the book title.")
        return false
    end
    local text = ""
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][3]:lower() == param:lower() then
            if player:getStorageValue(virtualLibrary[i][1]) < 1 then
                break
            end
            player:showTextDialog(virtualLibrary[i][2], virtualLibrary[i][3] .. "\n\n" .. virtualLibrary[i][4])
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing book: " .. virtualLibrary[i][3])
            return false
        end
        if param:lower() == "list" then
            if player:getStorageValue(virtualLibrary[i][1]) == 1 then
                if text ~= "" then
                    text = text .. "\n"
                end
                text = text .. virtualLibrary[i][3]
            end
        end
    end
    if param:lower() == "list" then
        if text == "" then
            text = "None."
        end
        player:showTextDialog(1950, "List of books in your virtual library:\n\n" .. text)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing virtual library list.")
        return false
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Unable to find " .. param .. " in your virtual library.")
    return false
end

talkaction_virtualLibrary:separator(" ")
talkaction_virtualLibrary:register()
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
291
Solutions
1
Reaction score
36
Lua:
local virtualLibrary = {
    -- {actionid&storage, itemidYouWantToShowInPicture, "Book title", "text inside"}
    {45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
    {45002, 1950, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
    {45003, 1950, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}


local action_virtualLibrary = Action()

function action_virtualLibrary.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local unknownBooks = {}
    for i = 1, #virtualLibrary do
        if player:getStorageValue(virtualLibrary[i][1]) < 1 then
            table.insert(unknownBooks, {i})
        end
    end
    if #unknownBooks < 1 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Your virtual library is complete. There is no more books available to learn.")
        return true
    end
    local randomBook = math.random(#unknownBooks)
    player:setStorageValue(virtualLibrary[randomBook][1], 1)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You've found " .. virtualLibrary[randomBook][3] .. ". This book is now available in your virtual library.")
    return true
end

action_virtualLibrary:aid(45000)
action_virtualLibrary:register()



local talkaction_virtualLibrary = TalkAction("/readfromlibrary", "!readfromlibrary")

function talkaction_virtualLibrary.onSay(player, words, param)
    if param == nil or param == "" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use /readfromlibrary list if you're unsure of the book title.")
        return false
    end
    local text = ""
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][3]:lower() == param:lower() then
            if player:getStorageValue(virtualLibrary[i][1]) < 1 then
                break
            end
            player:showTextDialog(virtualLibrary[i][2], virtualLibrary[i][3] .. "\n\n" .. virtualLibrary[i][4])
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing book: " .. virtualLibrary[i][3])
            return false
        end
        if param:lower() == "list" then
            if player:getStorageValue(virtualLibrary[i][1]) == 1 then
                if text ~= "" then
                    text = text .. "\n"
                end
                text = text .. virtualLibrary[i][3]
            end
        end
    end
    if param:lower() == "list" then
        if text == "" then
            text = "None."
        end
        player:showTextDialog(1950, "List of books in your virtual library:\n\n" .. text)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing virtual library list.")
        return false
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Unable to find " .. param .. " in your virtual library.")
    return false
end

talkaction_virtualLibrary:separator(" ")
talkaction_virtualLibrary:register()
But then, what action id do I put in the bookcase?
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
291
Solutions
1
Reaction score
36
For some reason, I get 1 different book and the rest is the first book:

16:05 You've found The King's Credence; Book 3. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
16:05 You've found The King's Credence; Book 1. This book is now available in your virtual library.
Should I increase storage value?
like this:
{45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
{45002, 1951, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
{45003, 1952, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
For some reason, I get 1 different book and the rest is the first book:


Should I increase storage value?
like this:
Each book has it's own storage value, so yes, increase it.

And to be clear, I mean the storage value, not the itemid (picture)
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
Still getting only book 1 after getting one diferente book.
Was a small typo
Lua:
local virtualLibrary = {
    -- {actionid&storage, itemidYouWantToShowInPicture, "Book title", "text inside"}
    {45001, 1950, "The King's Credence; Book 1", "The valiant king was a mage. The end."},
    {45002, 1950, "The King's Credence; Book 2", "The valiant king was a sorcerer. The end."},
    {45003, 1950, "The King's Credence; Book 3", "The valiant king was a warlock. The end."},
}


local action_virtualLibrary = Action()

function action_virtualLibrary.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local unknownBooks = {}
    for i = 1, #virtualLibrary do
        if player:getStorageValue(virtualLibrary[i][1]) < 1 then
            table.insert(unknownBooks, {i})
        end
    end
    if #unknownBooks < 1 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Your virtual library is complete. There is no more books available to learn.")
        return true
    end
    local randomBook = virtualLibrary[unknownBooks[math.random(#unknownBooks)][1]]
    player:setStorageValue(randomBook[1], 1)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You've found " .. randomBook[3] .. ". This book is now available in your virtual library.")
    return true
end

action_virtualLibrary:aid(45000)
action_virtualLibrary:register()



local talkaction_virtualLibrary = TalkAction("/readfromlibrary", "!readfromlibrary")

function talkaction_virtualLibrary.onSay(player, words, param)
    if param == nil or param == "" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use /readfromlibrary list if you're unsure of the book title.")
        return false
    end
    local text = ""
    for i = 1, #virtualLibrary do
        if virtualLibrary[i][3]:lower() == param:lower() then
            if player:getStorageValue(virtualLibrary[i][1]) < 1 then
                break
            end
            player:showTextDialog(virtualLibrary[i][2], virtualLibrary[i][3] .. "\n\n" .. virtualLibrary[i][4])
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing book: " .. virtualLibrary[i][3])
            return false
        end
        if param:lower() == "list" then
            if player:getStorageValue(virtualLibrary[i][1]) == 1 then
                if text ~= "" then
                    text = text .. "\n"
                end
                text = text .. virtualLibrary[i][3]
            end
        end
    end
    if param:lower() == "list" then
        if text == "" then
            text = "None."
        end
        player:showTextDialog(1950, "List of books in your virtual library:\n\n" .. text)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Accessing virtual library list.")
        return false
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Unable to find " .. param .. " in your virtual library.")
    return false
end

talkaction_virtualLibrary:separator(" ")
talkaction_virtualLibrary:register()
 
Solution
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
291
Solutions
1
Reaction score
36
@Xikini, is there a way to jump lines in the script? For example, I would like to put the "recipe" in the beginning of the next line. Or maybe increase the size of the modalwindow?

1612396009878.png
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,625
Solutions
397
Reaction score
3,735
\n
Lua:
"Description: It heals the user for 50 health points.\n\nRecipe:\n\n-> [1] Small Vial of blood\n->[5] Shrimp"
 
Top