//******************************* // // Library SQL Configuration // //******************************* // Requires Dantom.DB library ( http://www.byond.com/developer/Dantom/DB ) /* The Library ------------ A place for the crew to go, relax, and enjoy a good book. Aspiring authors can even self publish and, if they're lucky convince the on-staff Librarian to submit it to the Archives to be chronicled in history forever - some say even persisting through alternate dimensions. Written by TLE for /tg/station 13 Feel free to use this as you like. Some credit would be cool. Check us out at http://nanotrasen.com/ if you're so inclined. */ // CONTAINS: // Objects: // - bookcase // - book // - barcode scanner // Machinery: // - library computer // - visitor's computer // - book binder // - book scanner // Datum: // - borrowbook // Ideas for the future // --------------------- // - Visitor's computer should be able to search the current in-round library inventory (that the Librarian has stocked and checked in) // -- Give computer other features like an Instant Messenger application, or the ability to edit, save, and print documents. // - Admin interface directly tied to the Archive DB. Right now there's no way to delete uploaded books in-game. // -- If this gets implemented, allow Librarians to "tag" or "suggest" books to be deleted. The DB ID of the tagged books gets saved to a text file (or another table in the DB maybe?). // The admin interface would automatically take these IDs and SELECT them all from the DB to be displayed along with a Delete link to drop the row from the table. // - When the game sets up and the round begins, have it automatically pick random books from the DB to populate the library with. Even if the Librarian is a useless fuck there are at least a few books around. // - Allow books to be "hollowed out" like the Chaplain's Bible, allowing you to store one pocket-sized item inside. // - Make books/book cases burn when exposed to flame. // - Make book binder hackable. // - Books shouldn't print straight from the library computer. Make it synch with a machine like the book binder to print instead. This should consume some sort of resource. // Run all strings to be used in an SQL query through this proc first to properly escape out injection attempts. /proc/sanitizeSQL(var/t as text) var/sanitized_text = dd_replacetext(t, "'", "\\'") sanitized_text = dd_replacetext(sanitized_text, "\"", "\\\"") return sanitized_text /obj/structure/bookcase name = "bookcase" icon = 'library.dmi' icon_state = "bookcase" anchored = 1 density = 1 opacity = 1 var/category New() spawn(2) // allow library comp to exist var/list/books = book_mgr.getall() var/list/catbooks = new() // see if we have a library computer var/obj/machinery/librarycomp/comp if(istype(loc.loc, /area)) comp = locate() in loc.loc // get books in category for(var/datum/archived_book/B in books) if(!category || (category != B.category)) continue; catbooks += B if(catbooks.len <= 3) // if 3 or less books, fill shelf with that for(var/datum/archived_book/AB in catbooks) var/obj/item/weapon/book/B = new(src) B.name = "[AB.title]" B.title = AB.title B.author = AB.author B.dat = AB.dat B.gen_pages() B.icon_state = "book[rand(1,7)]" B.ssbn = AB.id B.author_real = AB.author_real B.author_key = AB.author_key B.photos = AB.photos // add to inventory if(comp) comp.inventory += B else // otherwise, pick 3 random books for(var/i = 1 to 3) var/datum/archived_book/AB = pick(catbooks) var/obj/item/weapon/book/B = new(src) B.name = "[AB.title]" B.title = AB.title B.author = AB.author B.dat = AB.dat B.gen_pages() B.icon_state = "book[rand(1,7)]" B.ssbn = AB.id B.author_real = AB.author_real B.author_key = AB.author_key B.photos = AB.photos // add to inventory if(comp) comp.inventory += B attackby(obj/O as obj, mob/user as mob) if(istype(O, /obj/item/weapon/book)) user.drop_item() O.loc = src else if(istype(O, /obj/item/weapon/pen)) var/newname = copytext(sanitize(input("What would you like to title this bookshelf?") as text|null),1,MAX_MESSAGE_LEN) if(!newname) return else setname(sanitize(newname)) else ..() attack_hand(var/mob/user as mob) var/list/books = list() for(var/obj/item/weapon/book/b in src.contents) books.Add(b) if(books.len) var/obj/item/weapon/book/choice = input("Which book would you like to remove from the shelf?") as null|anything in books if(choice) choice.loc = src.loc else return else user << "None of these books pique your interest in the slightest." proc setname(var/t as text) if(t) src.name = "bookcase ([t])" ex_act(severity) switch(severity) if(1.0) for(var/obj/item/weapon/book/b in src.contents) del(b) del(src) return if(2.0) for(var/obj/item/weapon/book/b in src.contents) if (prob(50)) b.loc = (get_turf(src)) else del(b) del(src) return if(3.0) if (prob(50)) for(var/obj/item/weapon/book/b in src.contents) b.loc = (get_turf(src)) del(src) return else return /obj/structure/bookcase/manuals/medical name = "Medical Manuals bookcase" New() ..() new /obj/item/weapon/book/manual/medical_cloning(src) /obj/structure/bookcase/manuals/engineering name = "Engineering Manuals bookcase" New() ..() new /obj/item/weapon/book/manual/engineering_construction(src) new /obj/item/weapon/book/manual/engineering_particle_accelerator(src) new /obj/item/weapon/book/manual/engineering_hacking(src) new /obj/item/weapon/book/manual/engineering_guide(src) new /obj/item/weapon/book/manual/engineering_singularity_safety(src) new /obj/item/weapon/book/manual/robotics_cyborgs(src) /obj/structure/bookcase/manuals/research_and_development name = "R&D Manuals bookcase" New() ..() new /obj/item/weapon/book/manual/research_and_development(src) /obj/item/weapon/book name = "book" icon = 'library.dmi' icon_state ="book" throw_speed = 1 throw_range = 5 w_class = 1.0 flags = FPRINT | TABLEPASS var dat // Actual page content due_date = 0 // Game time in 1/10th seconds author // Who wrote the thing, can be changed by pen or PC. It is not automatically assigned unique = 0 // 0 - Normal book, 1 - Should not be treated as normal book, unable to be copied, unable to be modified title // The real name of the book. author_real // author's real_name author_key // author's byond key ssbn // the ssbn, if a downloaded book list/pages = new() // individual pages as a list of text cur_page = 1 // current page being read list/icon/photos // in-game photos used proc/navbar() return "
