Files
Paradise/code/modules/library/computers/checkout.dm
SabreML 678435d50a Blood Cult 2: Electric Boogaloo (#14516)
* DMI files

* Progress

* we compiling

* innate cult action, various progress

* Reorganise runes, fix cult dagger action and admin cultist

* Cult tooltips, dagger icons

* Add mirror shield, return runes back to OG circles

* Cult structure lights, pylon update

* bola update, progress..

* cleaning rune fix, girder/structures anchor

* speed up cult walls

* Convert rune update, tweaks

* Add teleport portals

* fix runtimes

* cult objs start

* move current cult objs to backup

* Rework cult objectives, add narsie/singulo interactions

* spacing, admin log and message

* reviewstuff

* refactor cult conceal/reveal

* add a bit of range to reveal

* blood magic tweaks, hallway not in summon areas

* implement structure concealment, offer uncuff

* add parry sound, fix cult airlock reveal appearance

* Update remaining runes

* fix pylon blood restaure, up blood magic cost

* review tweaks and progress

* fix compilation

* fix offering rune bug

* Draw blood rune action refactor

* moar tweaks

* fixes, holy water blood magic clean, icons

* Add cultist hardsuit, tweaks

* reduce needed pylons for cult ghost, cult shield

* spirit realm fixes

* fix dark spirit

* Add blood rites

* exotic blood handling

* spacing, add adminbus dagger, bal. rune health cost

* woops

missed a var

* fix blood rite healing

* emp spell cult immunity

* fix exploit and narsie references

* new rune sprites

* color defines

* SEND_SOUNDS, cult summon areas

* fix soap, barrier, and add CC location on narsie

* cult structure fix

* functional ascendance, undo cult spacesuit changes

* woops

* whetstone qdel, tweaks

* fix empty area selection bug

* cult ascendance numbers

* add cult blade sprite, add sacrificing head/brains

* review stuff

* fix runtime and twisted cons target

* review stuff

* code clarity

* remove unnecessary cultist checks

* Add support for wizard cultists

* cleanip

* fix concealed glass airlocks

* update objs

* remove talisman ref

* fix status procs

* clarifications, remove unnecessary var

* deconflicting

* deconflicting LF

* oops

* readd new icons

* more conflcit stuff

* readd drill and jaws icons

* review stuff

* silence on conversion

* Readd compact sniper icons

* Remove ambiguity

* 2 sacrifices required

* check antag panel improvements, bug fixes

* limits narsie cult ghost cheese

* CC message

* trailing newlines

* Shade/construct update

* bug fixes

* balance bloodboil, update CC message

* add a newline to something i didnt touch

idk ask travis bout it

* remove metastation extra null rod and shard

* fix teleport runes list, update icon

* remove tg cultist icon

* update cult actions with new tome

* Remove mirror shield throw, spell constructs

Add in sacrificing any brain with a mind.

* Fix more conflicts

* Fix double return

* Add descriptions to cult recipes, fix icons

* fix shuttle curse exploit

* Update wall rune, cult shields, runed recipe width

* implement flagellant sprites, misc changes

* Fix conversion rune

* Add cult blood barrage healing

* Trailing line

* fix whitespace

* Remove can_speak check on invoke

* Deconflict pt. 2

* Bugfixes the 1st

Fixes bugs 2 and 4 in the 'Known Issues' section

* cult.dm tweaks

Oh boy, even more commits!

* Fixes blood halberds swapping directions on wield

* Tweaks and stylin'

Changed a few span classes around and added a 'Remaining Charges' display to the Blood Rite spell

* Ritual tweaks (And some other stuff)

Fixes:
Altar stray pixel,
Using 'Twisted Construction' on a cult door,
Rune drawing checks,
probably more idk

* Rune tweaks & fixes

Fixes:
Wraith glowing not turning off while jaunted,
A MASSIVE oversight by me with playsound(),

probably also some other stuff but I've been staring at this file for a week and I've forgot most of what I did.

* Testmerge fixes the 1st

Fixes:
Ascendent is now Ascendant,
The Cultist greeting is now in the correct order,
IPCs now draw oil coloured runes,
No longer able to sacrifice a body multiple times,
Sacrificing a brain or head now gives a soul shard,
Converting an IPC or someone with robotic limbs now heals them correctly,
Probably more.

* Mirror Shield balancing

Being hit by a projectile above a damage threshold (10) now increases the chances of the mirror shield shattering, by 3% per damage point.

This may seem pretty low, but an Energy Gun would have a 30% chance of breaking the shield per hit. (Assuming I did this right, anyway.)

* Insect repairs and more

Changes:

Makes the shuttle curse lines a define,
Comments out the changing construct names,
Made flagellant robes block hair,
Added documentation to the mirror shield (See said documentation for details),
Made the cooldown examine text for cult structures display minutes and seconds,
Removed the ability to sacrifice the same body multiple times,
Cleaned up the soulstone code (and hopefully didn't break anything),

Probably still missed something, oh well!

* Rune opacity and Stun timing

Changes:

Halved all the values of the 'Stun' spell, since it was presumably an oversight. (20 second stun to 10)
The 'mouse_opacity' for runes has been set to 'opaque', this means that clicking on any spot on the tile will select it. (Less fiddly)
The '(REMOVE SPELL)' choice when choosing spells now only shows if there's any spells to remove.
Dunking someones head in the lava forge now only works if they have a head.

Also fixed a whole bunch of typos/gramatical errors.

* Blood Boil, Blood Barrage and EMP Sprites!

Changes:

Overhauled the 'Blood Boil' rune (See documentation)
Added in-hand sprites and red sparks for 'Blood bolt barrage'.
The nar'sie rune now removes all runes around it to prevent clipping.
Fixed runtime when examining the 'Arcane Barrage' spell.

Added new sprites for the EMP spell, courtesy of @kugamo!

Co-Authored-By: Kugamo <thekugamo@gmail.com>

* A few more tweaks

Changes:

Halved the percentages of 'Rise' (Glowing eyes) and 'Ascend' (Halos) to 10% and 20% respectively.
Hopefully fixed shield walls being passable while active.
Changed "Nar-sie" to "Nar'sie" in a few places.

* TM 2 fixes

Changes:

Teleport runes now only show the user when the animation has finished.
Cult shields are now invisible to ghosts when disabled.
Crayon runes now use the new rune sprites.
Construct night vision now actually works.
You can no longer soulstone yourself.
The death message for cult structures is now bigger.
Cult objectives are now displayed at roundstart.
Tweaked the icons for artificer spells.
Tweaked some cult related 'Tip of the round's.
Summoned cult ghosts no longer show in the 'Check Antagonists' panel when dead. (Hopefully)

* Cult members and Deconversion

Changes:

Using the 'Study the Veil' ability now shows how many members the cult has.
Holy water now unequips all cult clothing on deconversion. (Flagellant robe, blindfold, etc.)
Nar'Sie no longer warns admins that it doesn't have a containment field.
Fixed Zealot's Blindfolds not temporarily blinding any non-cultists who touch them.
The 'Summon Cultist' rune description now explains that restrained cultists cannot be summoned.
Fixed Travis (Probably)

* Cult Rise/Ascend balancing V1

The values here will almost certainly need some tweaking, but I feel like it's better than it was before; and certainly more customisable.

* Possibly maybe hopefully (one of) the last commits

Changes:

The cult halo no longer vanishes on relogging.
It's now possible to drag things on to runes again.

* A few minor fixes, and a major one

Changes:

Resetting your action button positions no longer completely breaks blood spells.
The downside to this fix is that Blood spells can no longer be moved around, so sorry sorry about that.

Fixes: #14393
Fixes: #13855

* New weapon sprites!

Adds fancy new sprites for all cult daggers and swords, courtesy of @McRamon!

They will need adjustments for Vox and Kidan at some point, and the Skrell inhand can look a bit odd at times, but those are also problems for every other weapon in the game so that can be fixed later.

Co-Authored-By: McRamon <31545294+McRamon@users.noreply.github.com>

* TM 3 fixes

Changes:

Fixed action button related bugs, including making them movable again! (probably caused a bunch more but eh),
Slightly tweaked threshold for ascendance,
Blood Rites now cleans up slime blood,
The Deconversion message is now bigger,
Flagellant robes now take 5% more damage (Lasers do 30 damage rather than 29),
Teleport runes can no longer be erased while a portal effect is open,
Teleport rune portals now always show the Z-Level if they're not in station space,
Teleporting another player no longer makes you temporarily invisible,
Attempting to summon a restrained cultist now gives said cultist a warning message,
Fixed a runtime when placing a soulstone in a construct,
Cultists now show on the Orbit menu if you have AntagHUD enabled,
Fixed a few typos

Co-authored-by: datlo <quentinkoyote@gmail.com>
Co-authored-by: Kugamo <thekugamo@gmail.com>
Co-authored-by: McRamon <31545294+McRamon@users.noreply.github.com>
2020-11-06 20:41:41 -05:00

468 lines
17 KiB
Plaintext

/*
* Library Computer
*/
/obj/machinery/computer/library/checkout
name = "Check-In/Out Computer"
icon = 'icons/obj/library.dmi'
icon_state = "computer"
anchored = 1
density = 1
var/arcanecheckout = 0
//var/screenstate = 0 // 0 - Main Menu, 1 - Inventory, 2 - Checked Out, 3 - Check Out a Book
var/buffer_book
var/buffer_mob
var/upload_category = "Fiction"
var/list/checkouts = list()
var/list/inventory = list()
var/checkoutperiod = 5 // In minutes
var/obj/machinery/libraryscanner/scanner // Book scanner that will be used when uploading books to the Archive
var/bibledelay = 0 // LOL NO SPAM (1 minute delay) -- Doohl
var/booklist
/obj/machinery/computer/library/checkout/attack_hand(var/mob/user as mob)
if(..())
return
interact(user)
/obj/machinery/computer/library/checkout/interact(var/mob/user)
if(interact_check(user))
return
var/dat = ""
switch(screenstate)
if(0)
// Main Menu
dat += {"<ol>
<li><A href='?src=[UID()];switchscreen=1'>View General Inventory</A></li>
<li><A href='?src=[UID()];switchscreen=2'>View Checked Out Inventory</A></li>
<li><A href='?src=[UID()];switchscreen=3'>Check out a Book</A></li>
<li><A href='?src=[UID()];switchscreen=4'>Connect to External Archive</A></li>
<li><A href='?src=[UID()];switchscreen=5'>Upload New Title to Archive</A></li>
<li><A href='?src=[UID()];switchscreen=6'>Print a Bible</A></li>
<li><A href='?src=[UID()];switchscreen=7'>Print a Manual</A></li>"}
if(src.emagged)
dat += "<li><A href='?src=[UID()];switchscreen=8'>Access the Forbidden Lore Vault</A></li>"
dat += "</ol>"
if(src.arcanecheckout)
new /obj/item/melee/cultblade/dagger(src.loc)
to_chat(user, "<span class='warning'>Your sanity barely endures the seconds spent in the vault's browsing window. The only thing to remind you of this when you stop browsing is a strange looking dagger sitting on the desk. You don't really remember where it came from.</span>")
user.visible_message("[user] stares at the blank screen for a few moments, [user.p_their()] expression frozen in fear. When [user.p_they()] finally awaken[user.p_s()] from it, [user.p_they()] look[user.p_s()] a lot older.", 2)
src.arcanecheckout = 0
if(1)
// Inventory
dat += "<h3>Inventory</h3>"
for(var/obj/item/book/b in inventory)
dat += "[b.name] <A href='?src=[UID()];delbook=\ref[b]'>(Delete)</A><BR>"
dat += "<A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"
if(2)
// Checked Out
dat += "<h3>Checked Out Books</h3><BR>"
for(var/datum/borrowbook/b in checkouts)
var/timetaken = world.time - b.getdate
//timetaken *= 10
timetaken /= 600
timetaken = round(timetaken)
var/timedue = b.duedate - world.time
//timedue *= 10
timedue /= 600
if(timedue <= 0)
timedue = "<font color=red><b>(OVERDUE)</b> [timedue]</font>"
else
timedue = round(timedue)
dat += {"\"[b.bookname]\", Checked out to: [b.mobname]<BR>--- Taken: [timetaken] minutes ago, Due: in [timedue] minutes<BR>
<A href='?src=[UID()];checkin=\ref[b]'>(Check In)</A><BR><BR>"}
dat += "<A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"
if(3)
// Check Out a Book
dat += {"<h3>Check Out a Book</h3><BR>
Book: [src.buffer_book]
<A href='?src=[UID()];editbook=1'>\[Edit\]</A><BR>
Recipient: [src.buffer_mob]
<A href='?src=[UID()];editmob=1'>\[Edit\]</A><BR>
Checkout Date : [world.time/600]<BR>
Due Date: [(world.time + checkoutperiod)/600]<BR>
(Checkout Period: [checkoutperiod] minutes) (<A href='?src=[UID()];increasetime=1'>+</A>/<A href='?src=[UID()];decreasetime=1'>-</A>)
<A href='?src=[UID()];checkout=1'>(Commit Entry)</A><BR>
<A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"}
if(4)
dat += "<h3>External Archive</h3>"
if(!GLOB.dbcon.IsConnected())
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"
else
num_results = src.get_num_results()
num_pages = CEILING(num_results/LIBRARY_BOOKS_PER_PAGE, 1)
dat += {"<ul>
<li><A href='?src=[UID()];id=-1'>(Order book by SS<sup>13</sup>BN)</A></li>
</ul>"}
var/pagelist = get_pagelist()
dat += {"<h2>Search Settings</h2><br />
<A href='?src=[UID()];settitle=1'>Filter by Title: [query.title]</A><br />
<A href='?src=[UID()];setcategory=1'>Filter by Category: [query.category]</A><br />
<A href='?src=[UID()];setauthor=1'>Filter by Author: [query.author]</A><br />
<A href='?src=[UID()];search=1'>\[Start Search\]</A><br />"}
dat += pagelist
dat += {"<form name='pagenum' action='?src=[UID()]' method='get'>
<input type='hidden' name='src' value='[UID()]'>
<input type='text' name='pagenum' value='[page_num]' maxlength="5" size="5">
<input type='submit' value='Jump To Page'>
</form>"}
dat += {"<table border=\"0\">
<tr>
<td>Author</td>
<td>Title</td>
<td>Category</td>
<td>Controls</td>
</tr>"}
for(var/datum/cachedbook/CB in get_page(page_num))
var/author = CB.author
var/controls = "<A href='?src=[UID()];id=[CB.id]'>\[Order\]</A>"
controls += {" <A href="?src=[UID()];flag=[CB.id]">\[Flag[CB.flagged ? "ged" : ""]\]</A>"}
if(check_rights(R_ADMIN, 0, user = user))
controls += " <A style='color:red' href='?src=[UID()];del=[CB.id]'>\[Delete\]</A>"
author += " (<A style='color:red' href='?src=[UID()];delbyckey=[ckey(CB.ckey)]'>[ckey(CB.ckey)])</A>)"
dat += {"<tr>
<td>[author]</td>
<td>[CB.title]</td>
<td>[CB.category]</td>
<td>[controls]</td>
</tr>"}
dat += "</table><br />[pagelist]"
dat += "<br /><A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"
if(5)
dat += "<h3>Upload a New Title</h3>"
if(!scanner)
for(var/obj/machinery/libraryscanner/S in range(9))
scanner = S
break
if(!scanner)
dat += "<FONT color=red>No scanner found within wireless network range.</FONT><BR>"
else if(!scanner.cache)
dat += "<FONT color=red>No data found in scanner memory.</FONT><BR>"
else
dat += {"<TT>Data marked for upload...</TT><BR>
<TT>Title: </TT>[scanner.cache.name]<BR>"}
if(!scanner.cache.author)
scanner.cache.author = "Anonymous"
dat += {"<TT>Author: </TT><A href='?src=[UID()];uploadauthor=1'>[scanner.cache.author]</A><BR>
<TT>Category: </TT><A href='?src=[UID()];uploadcategory=1'>[upload_category]</A><BR>
<A href='?src=[UID()];upload=1'>\[Upload\]</A><BR>"}
dat += "<A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"
if(7)
dat += "<H3>Print a Manual</H3>"
dat += "<table>"
var/list/forbidden = list(
/obj/item/book/manual/random
)
if(!emagged)
forbidden |= /obj/item/book/manual/nuclear
var/manualcount = 1
var/obj/item/book/manual/M = null
for(var/manual_type in subtypesof(/obj/item/book/manual))
if(!(manual_type in forbidden))
M = new manual_type()
dat += "<tr><td><A href='?src=[UID()];manual=[manualcount]'>[M.title]</A></td></tr>"
QDEL_NULL(M)
manualcount++
dat += "</table>"
dat += "<BR><A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"
if(8)
dat += {"<h3>Accessing Forbidden Lore Vault v 1.3</h3>
Are you absolutely sure you want to proceed? EldritchArtifacts Inc. takes no responsibilities for loss of sanity resulting from this action.<p>
<A href='?src=[UID()];arccheckout=1'>Yes.</A><BR>
<A href='?src=[UID()];switchscreen=0'>No.</A><BR>"}
var/datum/browser/B = new /datum/browser(user, "library", "Book Inventory Management")
B.set_content(dat)
B.open()
/obj/machinery/computer/library/checkout/emag_act(mob/user)
if(density && !emagged)
emagged = 1
to_chat(user, "<span class='notice'>You override the library computer's printing restrictions.</span>")
/obj/machinery/computer/library/checkout/attackby(obj/item/W as obj, mob/user as mob)
if(default_unfasten_wrench(user, W))
power_change()
return
if(istype(W, /obj/item/barcodescanner))
var/obj/item/barcodescanner/scanner = W
scanner.computer = src
to_chat(user, "[scanner]'s associated machine has been set to [src].")
audible_message("[src] lets out a low, short blip.", hearing_distance = 2)
return 1
else
return ..()
/obj/machinery/computer/library/checkout/Topic(href, href_list)
if(..())
usr << browse(null, "window=library")
onclose(usr, "library")
return 1
if(href_list["pagenum"])
if(!num_pages)
page_num = 1
else
var/pn = text2num(href_list["pagenum"])
if(!isnull(pn))
page_num = clamp(pn, 1, num_pages)
if(href_list["page"])
if(num_pages == 0)
page_num = 1
else
page_num = clamp(text2num(href_list["page"]), 1, num_pages)
if(href_list["settitle"])
var/newtitle = input("Enter a title to search for:") as text|null
if(newtitle)
query.title = sanitize(newtitle)
else
query.title = null
if(href_list["setcategory"])
var/newcategory = input("Choose a category to search for:") in (list("Any") + GLOB.library_section_names)
if(newcategory == "Any")
query.category = null
else if(newcategory)
query.category = sanitize(newcategory)
if(href_list["setauthor"])
var/newauthor = input("Enter an author to search for:") as text|null
if(newauthor)
query.author = sanitize(newauthor)
else
query.author = null
if(href_list["search"])
num_results = src.get_num_results()
num_pages = CEILING(num_results/LIBRARY_BOOKS_PER_PAGE, 1)
page_num = 1
screenstate = 4
if(href_list["del"])
if(!check_rights(R_ADMIN))
return
var/datum/cachedbook/target = getBookByID(href_list["del"]) // Sanitized in getBookByID
var/ans = alert(usr, "Are you sure you wish to delete \"[target.title]\", by [target.author]? This cannot be undone.", "Library System", "Yes", "No")
if(ans=="Yes")
var/DBQuery/query = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[target.id]")
var/response = query.Execute()
if(!response)
to_chat(usr, query.ErrorMsg())
return
log_admin("LIBRARY: [key_name(usr)] has deleted \"[target.title]\", by [target.author] ([target.ckey])!")
message_admins("[key_name_admin(usr)] has deleted \"[target.title]\", by [target.author] ([target.ckey])!")
src.updateUsrDialog()
return
if(href_list["delbyckey"])
if(!check_rights(R_ADMIN))
return
var/tckey = ckey(href_list["delbyckey"])
var/ans = alert(usr,"Are you sure you wish to delete all books by [tckey]? This cannot be undone.", "Library System", "Yes", "No")
if(ans=="Yes")
var/DBQuery/query = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE ckey='[sanitizeSQL(tckey)]'")
var/response = query.Execute()
if(!response)
to_chat(usr, query.ErrorMsg())
return
var/affected=query.RowsAffected()
if(affected==0)
to_chat(usr, "<span class='danger'>Unable to find any matching rows.</span>")
return
log_admin("LIBRARY: [key_name(usr)] has deleted [affected] books written by [tckey]!")
message_admins("[key_name_admin(usr)] has deleted [affected] books written by [tckey]!")
src.updateUsrDialog()
return
if(href_list["flag"])
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/id = href_list["flag"]
if(id)
var/datum/cachedbook/B = getBookByID(id)
if(B)
if((input(usr, "Are you sure you want to flag [B.title] as having inappropriate content?", "Flag Book #[B.id]") in list("Yes", "No")) == "Yes")
GLOB.library_catalog.flag_book_by_id(usr, id)
if(href_list["switchscreen"])
switch(href_list["switchscreen"])
if("0")
screenstate = 0
if("1")
screenstate = 1
if("2")
screenstate = 2
if("3")
screenstate = 3
if("4")
screenstate = 4
if("5")
screenstate = 5
if("6")
if(!bibledelay)
var/obj/item/storage/bible/B = new /obj/item/storage/bible(src.loc)
if(SSticker && ( SSticker.Bible_icon_state && SSticker.Bible_item_state) )
B.icon_state = SSticker.Bible_icon_state
B.item_state = SSticker.Bible_item_state
B.name = SSticker.Bible_name
B.deity_name = SSticker.Bible_deity_name
bibledelay = 1
spawn(60)
bibledelay = 0
else
visible_message("<b>[src]</b>'s monitor flashes, \"Bible printer currently unavailable, please wait a moment.\"")
if("7")
screenstate = 7
if("8")
screenstate = 8
if(href_list["arccheckout"])
if(src.emagged)
src.arcanecheckout = 1
src.screenstate = 0
if(href_list["increasetime"])
checkoutperiod += 1
if(href_list["decreasetime"])
checkoutperiod -= 1
if(checkoutperiod < 1)
checkoutperiod = 1
if(href_list["editbook"])
buffer_book = copytext(sanitize(input("Enter the book's title:") as text|null),1,MAX_MESSAGE_LEN)
if(href_list["editmob"])
buffer_mob = copytext(sanitize(input("Enter the recipient's name:") as text|null),1,MAX_NAME_LEN)
if(href_list["checkout"])
var/datum/borrowbook/b = new /datum/borrowbook
b.bookname = sanitize(buffer_book)
b.mobname = sanitize(buffer_mob)
b.getdate = world.time
b.duedate = world.time + (checkoutperiod * 600)
checkouts.Add(b)
if(href_list["checkin"])
var/datum/borrowbook/b = locate(href_list["checkin"])
checkouts.Remove(b)
if(href_list["delbook"])
var/obj/item/book/b = locate(href_list["delbook"])
inventory.Remove(b)
if(href_list["uploadauthor"])
var/newauthor = copytext(sanitize(input("Enter the author's name: ") as text|null),1,MAX_MESSAGE_LEN)
if(newauthor && scanner)
scanner.cache.author = newauthor
if(href_list["uploadcategory"])
var/newcategory = input("Choose a category: ") in list("Fiction", "Non-Fiction", "Adult", "Reference", "Religion")
if(newcategory)
upload_category = newcategory
if(href_list["upload"])
if(scanner)
if(scanner.cache)
var/choice = input("Are you certain you wish to upload this title to the Archive?") in list("Confirm", "Abort")
if(choice == "Confirm")
establish_db_connection()
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
else
var/sqltitle = sanitizeSQL(scanner.cache.name)
var/sqlauthor = sanitizeSQL(scanner.cache.author)
var/sqlcontent = sanitizeSQL(scanner.cache.dat)
var/sqlcategory = sanitizeSQL(upload_category)
var/DBQuery/query = GLOB.dbcon.NewQuery("INSERT INTO [format_table_name("library")] (author, title, content, category, ckey, flagged) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[ckey(usr.key)]', 0)")
var/response = query.Execute()
if(!response)
to_chat(usr, query.ErrorMsg())
else
log_admin("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] characters in length")
message_admins("[key_name_admin(usr)] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] characters in length")
if(href_list["id"])
if(href_list["id"]=="-1")
href_list["id"] = input("Enter your order:") as null|num
if(!href_list["id"])
return
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/datum/cachedbook/newbook = getBookByID(href_list["id"]) // Sanitized in getBookByID
if(!newbook)
alert("No book found")
return
if((newbook.forbidden == 2 && !emagged) || newbook.forbidden == 1)
alert("This book is forbidden and cannot be printed.")
return
if(bibledelay)
visible_message("<b>[src]</b>'s monitor flashes, \"Printer unavailable. Please allow a short time before attempting to print.\"")
else
bibledelay = 1
spawn(60)
bibledelay = 0
make_external_book(newbook)
if(href_list["manual"])
if(!href_list["manual"]) return
var/bookid = href_list["manual"]
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/datum/cachedbook/newbook = getBookByID("M[bookid]")
if(!newbook)
alert("No book found")
return
if((newbook.forbidden == 2 && !emagged) || newbook.forbidden == 1)
alert("This book is forbidden and cannot be printed.")
return
if(bibledelay)
for(var/mob/V in hearers(src))
V.show_message("<b>[src]</b>'s monitor flashes, \"Printer unavailable. Please allow a short time before attempting to print.\"")
else
bibledelay = 1
spawn(60)
bibledelay = 0
make_external_book(newbook)
src.add_fingerprint(usr)
src.updateUsrDialog()
return
/*
* Library Scanner
*/
/obj/machinery/computer/library/checkout/proc/make_external_book(var/datum/cachedbook/newbook)
if(!newbook || !newbook.id)
return
var/obj/item/book/B = new newbook.path(loc)
if(!newbook.programmatic)
B.name = "Book: [newbook.title]"
B.title = newbook.title
B.author = newbook.author
B.dat = newbook.content
B.icon_state = "book[rand(1,16)]"
B.has_drm = TRUE
visible_message("[src]'s printer hums as it produces a completely bound book. How did it do that?")