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

Virtual Library - TFS 1.3

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,558
Solutions
386
Reaction score
3,682
Idea from here.

Gives a book reward, without a physical item.
Use a talkaction to read the books.

Set ActionID (45001, 45002, 45003) onto a bookcase in remere's.
Use bookcase to gain a storage value.
Use talkaction /readfromlibrary bookTitle to receive the book in a pop-up.

virtualLibrary.gif

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()
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,379
Solutions
7
Reaction score
536
Ah this is pretty cool can think of a couple of uses for it..

Would be nicer if it was modal windows lol that command is probs going to get lengthy xD
 

oen432

Legendary OT User
Joined
Oct 3, 2014
Messages
1,404
Solutions
47
Reaction score
1,495
Location
Poland
GitHub
Oen44
Change
Lua:
if virtualLibrary[i][3]:lower() == param:lower() then
To
Lua:
if virtualLibrary[i][3]:lower():find(param:lower()) then

!readfromlibrary king book 2 will work same as !readfromlibrary The King's Credence; Book 2
 
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,558
Solutions
386
Reaction score
3,682
Ah this is pretty cool can think of a couple of uses for it..

Would be nicer if it was modal windows lol that command is probs going to get lengthy xD
I keep forgetting they exist, since I have yet to use them.

I'll look into it. <3
 
Top