<commit_before>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.
]]
local transformation_dog = require("alchemy.teaching.transformation_dog")
local id_266_bookshelf = require("item.id_266_bookshelf")
local lookat = require("base.lookat")
local M = {}

-- UPDATE items SET itm_script = 'item.id_3110_scroll' WHERE itm_id = 3110;

function M.LookAtItem(User,Item)
    if Item:getData("bookId") ~= "" then
		local bookId = tonumber(Item:getData("bookId"))
		if bookId ~= nil then
			if id_266_bookshelf.books[bookId] ~= nil then
				lookat.SetSpecialName(Item, id_266_bookshelf.books[bookId].german, id_266_bookshelf.books[bookId].english)
			end
		end
	end
	return lookat.GenerateLookAt(User, Item, lookat.NONE)
end

function M.UseItem(User, SourceItem)
	if SourceItem:getData("teachDogTransformationPotion") == "true" then
		transformation_dog.UseSealedScroll(User, SourceItem)
		return
	end

	if SourceItem:getData("bookId") ~= "" then
		local bookId = tonumber(SourceItem:getData("bookId"))
		if bookId == nil then
			return
		end
		if id_266_bookshelf.books[bookId] ~= nil then
			User:sendBook(bookId)
		end
		return
	end

	-- teleport character on use
	local destCoordX = tonumber(SourceItem:getData("destinationCoordsX"))
	local destCoordY = tonumber(SourceItem:getData("destinationCoordsY"))
	local destCoordZ = tonumber(SourceItem:getData("destinationCoordsZ"))
	if destCoordX and destCoordY and destCoordZ then
		User:talk(Character.say,
			"#me ffnet eine Schriftrolle und verschwindet in einem hellen Leuchten.",
			"#me opens a scroll and disappears in a bright light.")
		world:gfx(31, User.pos)
		world:gfx(41, User.pos)
		User:warp(position(destCoordX, destCoordY, destCoordZ))
		world:gfx(41, User.pos)
		world:erase(SourceItem,1)
		return
	end
end

return M
<commit_msg>Adjust scroll script to new book list style<commit_after>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.
]]
local transformation_dog = require("alchemy.teaching.transformation_dog")
local id_266_bookshelf = require("item.id_266_bookshelf")
local lookat = require("base.lookat")
local M = {}

-- UPDATE items SET itm_script = 'item.id_3110_scroll' WHERE itm_id = 3110;

function M.LookAtItem(User,Item)
    if Item:getData("book")~="" then
		local book =tonumber( Item:getData("book"))
		if book ~= nil then
			if id_266_bookshelf.bookList[book] ~= nil then
				lookat.SetSpecialName(Item,id_266_bookshelf.bookList[book].german,id_266_bookshelf.bookList[book].english)
			end
		end
	end
	return lookat.GenerateLookAt(User, Item, 0)
end

function M.UseItem(User, SourceItem)
	if SourceItem:getData("teachDogTransformationPotion") == "true" then
		transformation_dog.UseSealedScroll(User, SourceItem)
		return
	end

	if SourceItem:getData("book")~="" then
		local book =tonumber( SourceItem:getData("book"))
		if book == nil then
			return
		end
		if id_266_bookshelf.bookList[book] ~= nil then
			User:sendBook(id_266_bookshelf.bookList[book].bookId)
		end
	end

	-- teleport character on use
	local destCoordX = tonumber(SourceItem:getData("destinationCoordsX"))
	local destCoordY = tonumber(SourceItem:getData("destinationCoordsY"))
	local destCoordZ = tonumber(SourceItem:getData("destinationCoordsZ"))
	if destCoordX and destCoordY and destCoordZ then
		User:talk(Character.say,
			"#me ffnet eine Schriftrolle und verschwindet in einem hellen Leuchten.",
			"#me opens a scroll and disappears in a bright light.")
		world:gfx(31, User.pos)
		world:gfx(41, User.pos)
		User:warp(position(destCoordX, destCoordY, destCoordZ))
		world:gfx(41, User.pos)
		world:erase(SourceItem,1)
		return
	end
end

return M

{'fraction_non_alphanumeric': 0.09174121073434574, 'fraction_numerical': 0.01497815685458706, 'mean_word_length': 5.195876288659794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5735580', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1521, 'n_words': 482}