|
 |   |  |  |
Submissions Submit JASS resources! If approved, they will be moved to their proper section. Please read me first. |
 |
|
11-17-2007, 07:02 PM
|
#1 (permalink)
|
User
Join Date: Nov 2007
Posts: 24
|
Save system that does not requires writing down codes
I have developed a system for RPG maps that generates color-coded text that can be read (from the screenshot) by a program, thus avoiding the need to write the code manually.
The JASS code, as well as the decoding program can be found here. This page contains more informations about the program and the script.
Anyways I post the JASS code here:
function CharCode takes string char returns integer local string charTable = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTIVWXYZ- " local integer currentIndex = 1 local integer endIndex = 64 loop exitwhen currentIndex > endIndex if SubStringBJ (charTable, currentIndex, currentIndex ) == char then return currentIndex - 1 endif set currentIndex = currentIndex + 1 endloop // This is invalid return -1 endfunctionfunction EncodeChar takes integer charCode returns string local integer base = 3 local string array colors local string result set colors [0 ] = "|c00ff0000I" // Red set colors [1 ] = "|c0000ff00I" // Green set colors [2 ] = "|c000000ffI" // Blue set result = colors [charCode - (charCode / base * base )] set charCode = charCode / base set result = colors [charCode - (charCode / base * base )] + result set charCode = charCode / base set result = colors [charCode - (charCode / base * base )] + result set charCode = charCode / base set result = colors [charCode ] + result return result endfunctionfunction EncodeString takes string text returns string local string result = "" local integer currentChar local integer currentIndex local integer endIndex set currentIndex = 1 set endIndex = StringLength (text ) loop exitwhen currentIndex > endIndex set currentChar = CharCode (SubStringBJ (text, currentIndex, currentIndex )) set result = result + EncodeChar (currentChar ) set currentIndex = currentIndex + 1 endloop return result endfunction
|
|
|
11-18-2007, 08:53 PM
|
#2 (permalink)
|
Model & Tutorial Moderator
Join Date: Nov 2006
Posts: 7,328
|
How does the program work?
|
|
|
11-19-2007, 10:46 AM
|
#3 (permalink)
|
User
Join Date: Nov 2007
Posts: 24
|
Each character in the save code is encoded with four colored 'I's. Each 'I' is either red, green or blue. The program looks at the screenshot and converts each group of four 'I's into the corresponding character, then copies the resulting text to the clipboard.
|
|
|
11-19-2007, 11:34 AM
|
#4 (permalink)
|
Model & Tutorial Moderator
Join Date: Nov 2006
Posts: 7,328
|
Sounds neat. Could you show an example?
|
|
|
11-19-2007, 07:17 PM
|
#5 (permalink)
|
User
Join Date: Nov 2007
Posts: 24
|
I have an example on the project's web page. Anyways, this is a screenshot of the code F34t-2dt5-3T2c-EurZ-ryTq-vg4n-v04S-q2eh-Hm4h-v, encoded with my method:

|
|
|
11-19-2007, 07:37 PM
|
#6 (permalink)
|
Model & Tutorial Moderator
Join Date: Nov 2006
Posts: 7,328
|
Sounds very complicated. Yet awesome.
|
|
|
11-20-2007, 01:10 AM
|
#7 (permalink)
|
User
Join Date: Nov 2007
Posts: 24
|
It may seem complicated, but it is really simple to add this to a map. And of course, I am willing to help anybody that is interested in this system 
|
|
|
11-20-2007, 09:48 PM
|
#8 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
I should have a chance to test this and review the code soon enough (blah, almost dinner right now), but it looks great! (But it would kind've suck for the average BNetter, so there are two sides to this. I suppose you could also include the classic method)
Hmm.. that would be a good system idea if you don't already have it. Have an option to display the 'real' code for people who don't have this program.
Also, just an idea, couldn't you encode the ASCII with a single color channel, and thus have 3 letters per I? (I haven't messed with too much color shiz in programming, but I don't see why not)
I suppose it would make the JASS longer (making the hex), but I see it as an advantage... (Well, maybe not SO much, since there's not any reading done by the user.. However, it would certainly be handy for long codes)
|
|
|
11-20-2007, 10:24 PM
|
#9 (permalink)
|
User
Join Date: Nov 2007
Posts: 24
|
You are right. I choose to use only three colors to minimize the chances to have decoding errors. If you look closely at a screenshot, especially at low resolution, like 640x480 or 800x600, you will notice that the letters are blended. That means that color of the letters is a mix between the text color and the background.
I could probably use more colors and still avoid such problems, but I prefer to err on the safe side. By the way, I think the current encoding is enough for any save code I have ever encountered.
|
|
|
11-21-2007, 01:30 AM
|
#10 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
Use SubString instead of SubStringBJ, with -1 on the start index; it's faster.
And the program crashes for me, and yes I have the right .NET framework (or at least the one you link to) (does it have to be taken in cinematic mode? I displayed mine with DisplayTextToPlayer)
|
|
|
11-21-2007, 01:44 AM
|
#11 (permalink)
|
User
Join Date: Nov 2007
Posts: 24
|
Thanks for the advice.
You need to display the text in cinematics mode because when you do that, the text always appears at the same position, which simplifies the program. I plan to add code to detect the position of the code, but right now it has to be done like that.
About the crash, what resolution is your screenshot? I only included support for 640x480, 800x600 and 1024x768 because my computer supports only these modes. If that is the problem, if you provide-me a screenshot at the resolution you use, I will update the configuration of the program to make it support it.
I can see I really need to add code that detects the code's location...
|
|
|
11-21-2007, 02:00 AM
|
#12 (permalink)
|
Jessi° ♥
Join Date: Aug 2007
Posts: 190
|
This sounds genius, but very impractical. it would be fairly good for a game that is already popular and to have it switch to this new system, but there are several flaws...
. If you accidently copy text or take another screenshot before decoding it, you lose all your progress...
. If you crash during alt-tabbing (which happens to a lot of people w/ wc3) its very possible for the screenshot to corrupt.
. 90% of B Net players are idiots. (~95% of all percentage statistics are made up on the spot). its very possible that they will be far too stupid to figure out how to work their Prnt Scrn button on their keyboard, much less paste it in a prog.
. Macs dont have the Prnt Scrn func, instead they have a different form of screenies. Or so Ive heard. Never used a mac myself, filthy little things.
__________________
Quote:
|
Originally Posted by Jen
Jessi if I was a lesbian, and you were older... oh baby ;]
|
|
|
|
11-21-2007, 02:34 AM
|
#13 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
Quote:
|
If you crash during alt-tabbing (which happens to a lot of people w/ wc3) its very possible for the screenshot to corrupt.
|
That would happen anyways.
Quote:
|
90% of B Net players are idiots. (~95% of all percentage statistics are made up on the spot). its very possible that they will be far too stupid to figure out how to work their Prnt Scrn button on their keyboard, much less paste it in a prog.
|
Which is why you would include both ways in a map.
Quote:
|
Macs dont have the Prnt Scrn func, instead they have a different form of screenies. Or so Ive heard. Never used a mac myself, filthy little things.
|
This is written for windows-only anyways.
Quote:
|
If you accidently copy text or take another screenshot before decoding it, you lose all your progress...
|
What?
Oh, and the attached screenshot crashes it.
http://www.hiveworkshop.com/forums/a...1&d=1195612470
|
|
|
11-21-2007, 02:47 AM
|
#14 (permalink)
|
Jessi° ♥
Join Date: Aug 2007
Posts: 190
|
Quote:
Originally Posted by PurplePoot
What?
|
Print Screen saves an image to the Clipboard. So does highlighting text and doing CTRL+C. You can only save one image/text selection in the clipboard at a time, so the old one is overwritten if you copy something.
|
|
|
11-21-2007, 08:43 AM
|
#15 (permalink)
|
Model & Tutorial Moderator
Join Date: Nov 2006
Posts: 7,328
|
Pressing PrntScrn in wc3 automatically saves it as a file in %Root\Warcraft III\Screenshots\. No pasting in MS Paint necessary!
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|