![]() | |
| | #1 |
![]() Join Date: Sep 2006 Location: Your Mom
Posts: 2,241
![]() | [System] String Compare System 0.2
Code: Version Change Log - String Compare System 0.2 -Changed real variable from global to local. -Took out test messages. -Added case-converter. -Fixed a critical bug that had been undone in a crash prior to release. -Uploaded test map. -Changed name to "String Compare System" -Optimized some. -Adjusted large string balance. 0.1 Initial Release
Code: function CompareStrings takes string xs, string xs2 returns real
local integer xi = 0
local integer xi2 = 0
local integer xi3 = 0
local integer xi4 = 0
local integer xi5 = 0
local integer a = 0
local integer b = 0
local real xr = 0
set xs = StringCase( xs, false)
set xs2 = StringCase( xs2, false)
if ( StringLength(xs) <= StringLength(xs2) ) then
set xi5 = StringLength(xs)
else
set xi5 = StringLength(xs2)
endif
set xi = ( ( xi5 / 6 ) + 0 )
if ( xi == 0 ) then
set xi = 1
else
endif
if ( xi == 1 ) then
else
if ( xi == 2 ) then
set xs = ( "xxx" + ( xs + "xxx" ) )
set xs2 = ( "xxx" + ( xs2 + "xxx" ) )
else
if ( xi == 3 ) then
set xs = ( "xxxxx" + ( xs + "xxxx" ) )
set xs2 = ( "xxxxx" + ( xs2 + "xxxx" ) )
else
if ( xi == 4 ) then
set xs = ( "xxxxxx" + ( xs + "xxxxxx" ) )
set xs2 = ( "xxxxxx" + ( xs2 + "xxxxxx" ) )
else
if ( xi == 5 ) then
set xs = ( "xxxxxxxx" + ( xs + "xxxxxxx" ) )
set xs2 = ( "xxxxxxxx" + ( xs2 + "xxxxxxx" ) )
else
if ( xi == 6 ) then
set xs = ( "xxxxxxxxx" + ( xs + "xxxxxxxxx" ) )
set xs2 = ( "xxxxxxxxx" + ( xs2 + "xxxxxxxxx" ) )
else
set xs = ( "xxxxxxxxxxx" + ( xs + "xxxxxxxxxxx" ) )
set xs2 = ( "xxxxxxxxxxx" + ( xs2 + "xxxxxxxxxxx" ) )
endif
endif
endif
endif
endif
endif
set xi5 = ( xi5 + ( ( xi - 1 ) * 2 ) )
set xi4 = ( ( xi5 - xi ) + 1 )
set a = 1
loop
exitwhen a > xi4
set b = 1
loop
exitwhen b > xi4
if ( SubStringBJ(xs, a, ( a + ( xi ) )) == SubStringBJ(xs2, b, ( b + ( xi ) )) ) then
set xi2 = ( xi2 + 1 )
exitwhen true
else
endif
set b = b + 1
endloop
set xi3 = ( xi3 + 1 )
set a = a + 1
endloop
set xr = ( ( I2R(xi2) / I2R(xi3) ) * 100.00 )
return xr
endfunction USE For JASS users. Code: set RealVariable = CompareStrings( "bob", "frank") Code: Use of Compare Strings
Events
Player - Player 1 (Red) types a chat message containing -compare as An exact match
Conditions
Actions
Set StringVariable = bob
Set AnotherStringVariable = frank
Custom script: set udg_RealVariable = CompareStrings( udg_StringVariable, udg_AnotherStringVariable)
Game - Display to (All players) for 30.00 seconds the text: (Bob and Frank match up + ((String(RealVariable)) + %)) "Tonight I go downtown." and "Today I go downtown." Compared = 63.64% "Mr.Apples" and "MrApples" Compared = 75% "You all totally rock" and "You all completely suck" Compared = 45.455% "WarCraft" and "StarCraft" Compared = 75% "Dick Cheney" and "Anti-Christ" Compared = 9.09% ![]() "Apple" and "Orange", "Cow" and "Duck" Compared = 0% For Support Reply here. Suggestions, bug, etc. |
| | |
| | #2 |
![]() Join Date: Dec 2006
Posts: 2,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: [Function] String Comparison MrApples, when did you start to get so advanced with systems? But yes it is a real crown impresser. Unfortunately I have this thing about using things that I don't know how they work. I know it sounds dumb but it's the only way to actually make me learn something. |
| | |
| | #3 |
![]() Join Date: Sep 2006 Location: Your Mom
Posts: 2,241
![]() | Re: [Function] String Comparison All my recent works have been close or more complex to this. Their just not done yet. Ultimate Footmen, Risk Engine, Diplomacy System v2, Xplode Generator, PoLlama Pack, Battle XP System, Apple's Save/Load. All planned upcoming releases. Why don't you go by the 'Someone else already did it, so why waste my time rule' instead . Its really not that complex though. |
| | |
| | #4 |
![]() Join Date: Dec 2006
Posts: 2,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Re: [Function] String Comparison Oh trust me. When I see something that I don't understand, I can research and try to learn it. Mapping, like my real life, I have no idea what I want to do in it. I don't know if I want to be a trigger, object manager, skinner, terrainer, modeler, ect. But anyway. To get a better understanding. It would compare and tell you the percentage, so that even if you were to spell a person's name wrong. But if it's close it would still work? |
| | |
| | #5 |
![]() Join Date: Sep 2006 Location: Your Mom
Posts: 2,241
![]() | Re: [System] String Compare System 0.2 0.1 Wasn't working right, as it crashed last night and I rushed to upload it :roll:. However, I just uploaded 0.2, which should work great. Even has a demo map. |
| | |
| | #6 |
![]() Join Date: Apr 2007
Posts: 2,434
![]() ![]() ![]() | Re: [System] String Compare System 0.2 Wtf is an Xplode generator? does it blow things up? lol |
| | |
| | #7 |
![]() Join Date: Sep 2006 Location: Your Mom
Posts: 2,241
![]() | Re: [System] String Compare System 0.2 Yeah ![]() Its a system that generates explosions, like a little physics engine. For example, CreateExplosiononLoc( loc, power, height, special). Power is how strong, height controls the angle affected are thrown in, and special covers stuff like burning, debris, nuclear. Its like Pre-Alpha at the moment, i'm busy with other stuff. |
| | |
![]() |
| Tags |
| None |
| Thread Tools | |
| Rate This Thread | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [System] Item Stacking System | Mr. Zero | Spells and Systems | 1 | 12-01-2007 05:28 PM |
| [System] Leaver & Kick System | CaptainSnake | Recycling Bin | 6 | 05-14-2007 07:07 PM |