Mirage Source

Free ORPG making software.
It is currently Fri Mar 29, 2024 1:33 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 993 posts ]  Go to page 1, 2, 3, 4, 5 ... 40  Next
Author Message
PostPosted: Fri Jul 31, 2009 10:58 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Function which automatically checks the first letter of what's fed into it. Will see if it's correct to use 'An' or 'A'. Supports capitalisation and proper nouns. If the item, npc etc. has $ as the first character of it's name, it'll be read as a proper noun. Of course, you'll have to remove this when rendering item names and stuff on the map.

Code:
Public Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = NO) As String
Dim FirstLetter As String * 1
   
    FirstLetter = LCase$(Left$(Word, 1))
   
    If FirstLetter = "$" Then
      CheckGrammar = (Mid$(Word, 2, Len(Word) - 1))
      Exit Function
    End If
   
    If Caps Then CheckGrammar = "A " & Word Else CheckGrammar = "a " & Word
   
    If FirstLetter = "a" Or FirstLetter = "e" Or FirstLetter = "i" Or FirstLetter = "o" Or FirstLetter = "u" Then
        If Caps Then CheckGrammar = "An " & Word Else CheckGrammar = "an " & Word
    End If

End Function


Example:

Code:
msg = "You picked up " & CheckGrammar(Trim(Item(GetPlayerInvItemNum(index, n)).Name)) & "."

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Fri Jul 31, 2009 11:42 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
DFA wrote:
its fail
it wont work on words like hour and others


It's for nouns only you fucking retard.

<3

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Fri Jul 31, 2009 3:06 pm 
Offline
Knowledgeable
User avatar

Joined: Sun Nov 19, 2006 6:59 pm
Posts: 213
Just for the fun of it, since we're fixing grammar mistakes.

I before E except after C

Code:
    Dim Loc As Integer
   
    If InStr(1, Word, "ei") <> 0 Or InStr(1, Word, "ie") <> 0 Then
        For Loc = 2 To Len(Word)
            If Mid(Word, Loc, 2) = "ie" And Mid(Word, Loc - 1, 1) = "c" Then
                Word = Left(Word, Loc - 1) & "ei" & Right(Word, Len(Word) - Loc - 1)
            ElseIf Mid(Word, Loc, 2) = "ei" And Mid(Word, Loc - 1, 1) <> "c" Then
                Word = Left(Word, Loc - 1) & "ie" & Right(Word, Len(Word) - Loc - 1)
            End If
        Next Loc
    End If


(I know there are exceptions, but eh :P)


Btw Robin, hourglass is a noun, but it's one of the few exceptions that use an that doesn't start by a vowel. <3

_________________
Image


Top
 Profile  
 
PostPosted: Fri Jul 31, 2009 3:39 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
JokeofWeek wrote:
Btw Robin, hourglass is a noun, but it's one of the few exceptions that use an that doesn't start by a vowel. <3


Well, feel free to add in all the special words which you want to use as a custom check.

Personally, I have no need for an item called Hourglass ;D

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Fri Jul 31, 2009 11:50 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Pfft I already did this.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Fri Jul 31, 2009 11:50 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
GIAKEN wrote:
Pfft I already did this.


Holy fucking shit you're alive.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Fri Jul 31, 2009 11:58 pm 
Offline
Persistant Poster

Joined: Fri Jun 26, 2009 10:15 pm
Posts: 701
Google Talk: FAProductions
If it sounds like it starts with a vowel, it's possed to use an, not a. I used to know a LOT of those words, but I can't remember them anymore. Lol.

This is something that's been needed in MS for awhile. It seems like it's simple and would have no real change, but it makes a big difference imo.


Top
 Profile  
 
PostPosted: Sat Aug 01, 2009 12:01 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Robin wrote:
GIAKEN wrote:
Pfft I already did this.


Holy fucking shit you're alive.


I just moved out of my parents house.

Anyways, I did this check grammar thing in Elysium Diamond 3 a long ass time ago. Here's my function:

Code:
Public Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = NO) As String
Dim FirstLetter As String * 1
   
    FirstLetter = LCase$(Left$(Word, 1))
   
    If Caps Then CheckGrammar = "A" Else CheckGrammar = "a"
   
    If FirstLetter = "a" Or FirstLetter = "e" Or FirstLetter = "i" Or FirstLetter = "o" Or FirstLetter = "u" Then
        If Caps Then CheckGrammar = "An" Else CheckGrammar = "an"
    End If

End Function

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Sat Aug 01, 2009 12:03 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Oh haha I see what you did thar Robin. Anybody notice how much alike they are? :P

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Sat Aug 01, 2009 10:19 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
GIAKEN wrote:
Oh haha I see what you did thar Robin. Anybody notice how much alike they are? :P


Probably your code.

I just found it in Essence.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Sat Aug 01, 2009 12:06 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Here's a tiny improvement:

using "ass"
Quote:
%Faster 185.7| 71.4| 71.4| 64.3| 71.4| 64.3| 71.4| 64.3| 84.6| 71.4
Test1 40| 24| 24| 23| 24| 23| 24| 23| 24| 24
Test2 14| 14| 14| 14| 14| 14| 14| 14| 13| 14


using "test"
Quote:
%Faster 46.7| 46.7| 64.3| 53.3| 53.3| 33.3| 33.3| 33.3| 53.3| 33.3
Test1 22| 22| 23| 23| 23| 20| 20| 20| 23| 20
Test2 15| 15| 14| 15| 15| 15| 15| 15| 15| 15


Test1 was using the original code.

Test2 is:
Code:
Private Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = 0) As String
Dim FirstLetter As String * 1
   
    FirstLetter = LCase$(Left$(Word, 1))
   
    If FirstLetter = "$" Then
      CheckGrammar = (Mid$(Word, 2, Len(Word) - 1))
      Exit Function
    End If
   
    If FirstLetter Like "*[aeiou]*" Then
        If Caps Then CheckGrammar = "An " & Word Else CheckGrammar = "an " & Word
    Else
        If Caps Then CheckGrammar = "A " & Word Else CheckGrammar = "a " & Word
    End If

End Function


Top
 Profile  
 
PostPosted: Sat Aug 01, 2009 5:21 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Something less repetitive. Not sure if it's any faster. Also this function is made to be faster for words that need "An" because statements in an Else are always slower than statements in the actual If. I'm not sure which would come up more often (needing an An or just A), but to change it just add If Not FirstLetter and switched the statements around.

Code:
Private Function CheckGrammar(ByVal Word As String, Optional ByVal Caps As Byte = 0) As String
Dim FirstLetter As String * 1
   
    FirstLetter = LCase$(Left$(Word, 1))
   
    If FirstLetter = "$" Then
        CheckGrammar = (Mid$(Word, 2, Len(Word) - 1))
        Exit Function
    End If
   
    If FirstLetter Like "*[aeiou]*" Then
        If Caps Then CheckGrammar = "An " Else CheckGrammar = "an "
    Else
        If Caps Then CheckGrammar = "A " Else CheckGrammar = "a "
    End If
   
    CheckGrammar = CheckGrammar & Word

End Function

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Wed Dec 01, 2021 9:19 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:27 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Econ


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:28 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
115.9


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:29 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:30 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:31 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Thom


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:32 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Mohi


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:33 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Shop


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:35 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Gera


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:36 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Robe


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:37 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Vide


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:38 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
EyeT


Top
 Profile  
 
PostPosted: Fri Jan 07, 2022 10:39 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Fisk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 993 posts ]  Go to page 1, 2, 3, 4, 5 ... 40  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group