RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 2.0] Online Book Code Generator

Felladrin

Sorceror
Introduction:

This is simple a HTML page with a JavaScript code which generates the code of a book for RunUO 2. It's useful to host the page on the site and give acess to staff members.

The idea can be used on automated websystem, e.g. making a form that the player fills and the staff receives, by e-mail, the code ready to use.

Test-Drive: Online Book Code Generator for RunUO


Features:

# Easily sets Book Title, Book Author, File Name and Cover Hue.
# Formats the contents of the book wisely, without wasting space. (Optional)
# Checks if the file name has special characters or accents.
# Allows to change the book cover, via ItemID. (New!)
# Limits the book content to 60,000 characters. (New!)
# Allows to compress the code, if you don't intend to edit later.
# Commented javascript code, intended to be easy to understand.


Usage:

Download the HTML file and open it with your web browser, for single and offline use. But to make it really useful, host it on a website and spread the link to the staff members.
After generating the .cs file, put it anywhere in scripts folder, restart the server and use the command in-game: [add cbook
It'll show all the custom books generated by this script (if you didn't change the 'CBook' prefix, of course).


Patchlog:

Version 1.1.0 (February 04, 2011) [Current Version]
Version 1.0.1 (December 10, 2010)
Version 1.0.0 (December 08, 2010) [First Version]


Alternatives:

Online Book Code Generator with Download Option (Version 1.1.0)


Related Custom Scripts:

Read Book From Text by Lokai.
Publisher by Lewism, updated by Liacs and Koluch.
[csbook by Daat99, updated by Magpie.


ToDo:

Make an alternative version using Irian's Pretty ReadBooks.


Some Notes:

If anyone release html pages based on this, here or on a new thread, let me know, so I can link here. Also, tell me if you find any bugs, I'll try to fix as soon as possible.

I hope it's useful to you. Ideas and suggestions are always welcome!

Felladrin.
 

Attachments

  • obcg1.PNG
    obcg1.PNG
    29 KB · Views: 198
  • obcg2.PNG
    obcg2.PNG
    32 KB · Views: 140
  • obcg3.PNG
    obcg3.PNG
    29.2 KB · Views: 129
  • obcg4.PNG
    obcg4.PNG
    70.9 KB · Views: 136
  • obcg5.PNG
    obcg5.PNG
    44.2 KB · Views: 134
  • bookcodegen.zip
    20.2 KB · Views: 104
  • OBCG1.1.JPG
    OBCG1.1.JPG
    38.1 KB · Views: 106
This is pretty badass, I've been looking for something like this. And, its entirely javascript for those with very simple hosting without php or asp.


few ideas (just suggestions, you don't even have to read them if you don't want):

cycle between the various book itemtypes (theres, blue, brown, tan and green I think, and the color is only part, they are different orientations/shapes as well)

allow for manually inserted linebreaks

scrolls for small documents/notes, maybe even have it automatically determine if it should be book or scroll based on character count

I'm sure theres a way to get it to save somehow
 

Felladrin

Sorceror
Thank you, Anti-Basic, for the comment and suggestions, they are very welcome.

cycle between the various book itemtypes (theres, blue, brown, tan and green I think, and the color is only part, they are different orientations/shapes as well)
I thought about that too, but I'd need, somehow, show images on the page, to show the difference between the shapes.
But thinking better, it wouldn't be necessary, as the hue isn't. The staff could see the shapes in-game before using the site.
The problem of the images is that they would need to be attached to the .zip, and also uploaded the the host, to garantee that they would be shown.
On the other hand, we could use imageshack.us, for example, to host, so there'd still be no need of extra files, though without garantee of showing the images.
What do you think?

allow for manually inserted linebreaks
Nice idea! Added to to-do list!

scrolls for small documents/notes, maybe even have it automatically determine if it should be book or scroll based on character count
Cool! It would be easy to do, but what gump would a scroll use in-game? But than the script should generate not only the book, but also the gump... hm, I'll think about that.
Or you say just change de itemID to be a scroll instead of a book? This would be pretty simple, but also wierd to open a scroll and see (the gump) like it was a book.

I'm sure theres a way to get it to save somehow
I've made a search to see if there was any way to save the file, using only javascript, but with no success. I'll keep looking. Please tell me if you find anything too.
 
Thank you, Anti-Basic, for the comment and suggestions, they are very welcome.


I thought about that too, but I'd need, somehow, show images on the page, to show the difference between the shapes.
But thinking better, it wouldn't be necessary, as the hue isn't. The staff could see the shapes in-game before using the site.
The problem of the images is that they would need to be attached to the .zip, and also uploaded the the host, to garantee that they would be shown.
On the other hand, we could use imageshack.us, for example, to host, so there'd still be no need of extra files, though without garantee of showing the images.
What do you think?

I was just thinking of having it randomly choose a booktype so that they don't all end of being hued bluebooks of the same orientation

I don't see the problem with havign the images in the zip, for if they want a specific type, just tell them to upload the entire contents of the zip.


Cool! It would be easy to do, but what gump would a scroll use in-game? But than the script should generate not only the book, but also the gump... hm, I'll think about that.
Or you say just change de itemID to be a scroll instead of a book? This would be pretty simple, but also wierd to open a scroll and see (the gump) like it was a book.
There's some scroll gumps already in, but I'll need to look through and see which one would be suitable

EDIT: Journal sized would be fine, too big and it kinda counter productive to be used for small notes


I've made a search to see if there was any way to save the file, using only javascript, but with no success. I'll keep looking. Please tell me if you find anything too.
Ya I've been looking since my other post, haven't found anything yet.
 

Felladrin

Sorceror
There's some scroll gumps already in, but I'll need to look through and see which one would be suitable
EDIT: Journal sized would be fine, too big and it kinda counter productive to be used for small notes
(...)
I was just thinking of having it randomly choose a booktype so that they don't all end of being hued bluebooks of the same orientation
Good, I agree the journal gump has a good size. But I think it requires another mechanism to generate a code based on a gump, instead of the book template.
My brother just gave-me an idea, after reading yours: To make the book shape to vary with the number of characters, instead of being random. So for small texts, a tiny book (like the tanbook), for medium a bigger one (like bluebook), for long ones a book like spellbook (which is large) and so on.
This way all the shapes could be used. Also this idea could replace the idea of making scrolls. (The scrolls could be made specifically by another script/page, similar to this one)

I don't see the problem with havign the images in the zip, for if they want a specific type, just tell them to upload the entire contents of the zip.
I agree.

We'll see the changes on next update. I don't know when I'll work on this again, but I presume the update comes before christimas.
 
Good, I agree the journal gump has a good size. But I think it requires another mechanism to generate a code based on a gump, instead of the book template.
My brother just gave-me an idea, after reading yours: To make the book shape to vary with the number of characters, instead of being random. So for small texts, a tiny book (like the tanbook), for medium a bigger one (like bluebook), for long ones a book like spellbook (which is large) and so on.

Yeah thats a good idea too. You could also allow the char count thresholds for the next sized books to be set by the end user.

Remember, you can have more than option as well. Random, By size, Specifically Chosen (specific would be good for matching sets of books)

If I'm not mistaken, theres a different spellbook-sized book art used for a quest that might be usable so as not to be confused with other spell/runebooks. I don't have access to either UO or RunUO atm, but later I'll check and see.

Anyway this is a great script, books have always been a huge part of Roleplaying in UO, but the problem has always been the tedium of converting them from text due to the variable width of the letters.
 

Felladrin

Sorceror
Yeah thats a good idea too. You could also allow the char count thresholds for the next sized books to be set by the end user.
Remember, you can have more than option as well. Random, By size, Specifically Chosen (specific would be good for matching sets of books)
I agree! Let's give several options to users. That's what everyone likes!
Thanks for following up the idea!
 

Felladrin

Sorceror
(Update) Version 1.0.1

Hi, I've just found a bug and couldn't sleep before posting a hotfix. Just added the line:
HTML:
content = content.replace(/\\/g,"\\\\"); //duplicates all backslashes to avoid errors on the generated code.
So the "\" won't be seen as a escape character by the compiler.
 

Felladrin

Sorceror
(Alternative) Online Book Code Generator with Download Option (Requires PHP hosting)

I didn't find any way to allow to download te code using only javascript, so here is an alternative version, using php. But I'll need your help, because I'm a newbie in php, ok? I don't know about the page security using php.

Note: The online example sites are already running with download option.

Instructions:

Upload the bookcodegen folder to your site.
Set the file permission of 'temp' folder to 757 or 777, to make it able to hold temporary files.
And it's ready! Access it through www.yoursite.com/bookcodegen

Note: No books are stored in 'temp' folder, they are deleted right after the download. If you want to keep the books, just remove the follwing line from download.php:
PHP:
unlink("./temp/$fname");
 

Attachments

  • bookcodegen-with-download-option.zip
    21.4 KB · Views: 36

David

Moderate
Fantastic! One of the best ideas I have seen in a while (I love books.) The web interface implementation is a great way to handle generating the code as well.

One note, in my brief testing, I used text that contained commas and semi-colons. The code generator moved any text after either on to the next line--but still within the quotes. I did not get a chance to compile the script to see if that was a real issue.

Well done! Keep it up.
David
 

Felladrin

Sorceror
Fantastic! One of the best ideas I have seen in a while (I love books.) The web interface implementation is a great way to handle generating the code as well.

One note, in my brief testing, I used text that contained commas and semi-colons. The code generator moved any text after either on to the next line--but still within the quotes. I did not get a chance to compile the script to see if that was a real issue.

Well done! Keep it up.
David
Thanks, David!

After your comment I noticed I've tested some texts with special characters to find errors, but didn't try to put a formated code instead of a simple text as book content. So I used the content of CurrentExpansion.cs and did the test to see the boom!

Results attached. It works! \o/

EDIT: Oops, I think I misunderstood your text. Just a second. *Redoing the tests*

EDIT2: Sorry, David. I did tests using commas and semicolons, but didn't see what you described. Maybe I didn't understand correctly. Can you post a screenshot when you're back? Thanks.
 

Attachments

  • t1.png
    t1.png
    23.9 KB · Views: 91
  • t2.png
    t2.png
    211.9 KB · Views: 92
  • t3.jpg
    t3.jpg
    65.6 KB · Views: 97
  • t4.jpg
    t4.jpg
    66.1 KB · Views: 101
  • t5.jpg
    t5.jpg
    63 KB · Views: 100

TheNorthStar

Sorceror
I get this when I try to open my book:
Code:
Compression buffer overflowed on packet 0x66 ('BookPageDetails') (lengt h=0)
Client: xxx.xxx.xxx.xxx: null buffer send, disconnecting...

I'm assuming my book is too long? maybe there should be a check for that?
 

TheNorthStar

Sorceror
I'm not really sure either, I just assume that's what's going on.
Maybe you could make it break the overflow into multiple books? "My awesome book - part1", etc.
 
if theres a limit its guessing its gonna be somethign like 65535 pages or soemthing. I doubt its characters, cuz thats actually not alot in terms of letters.

it could be soemthing else entirely though, that error doesn't give much information.
 

HellRazor

Knight
I think you're right. There is definately a page limit but I don't recall offhand what it was. Some big number like that one if I remember right.
 
well I knew for a fact that it wasn't 255 (made a book much longer than that with lokais tool), seemed the next logical step.

But this is just assuming thats what it was, how many pages was your book, Northstar?
 
Top