Results 1 to 11 of 11

Thread: The Key to great games...

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    Unhappy The Key to great games...

    I have some code (below) from a tutorial. It's for an old fasioned INI file. I have been quite taken with it. In fact I have thought up a scripting technique for games!!

    The problem is to be honest I don't really understand it suffieciently to modify it.

    What I want to enclude is an additional key. So as opposed to Key/SubKey/Value I want MajorKey/MinorKey/SubKey/Value.

    Can this be done. I'm assumeing so. I just don't know how.


    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetPrivateProfileString Lib "kernel32" _
    4. Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
    5. ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, _
    6. ByVal nSize As Long, ByVal lpFileName As String) As Long
    7. Private Declare Function WritePrivateProfileString Lib "kernel32" _
    8. Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
    9. ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    10.  
    11. ' Functions
    12. Function GetFromINI(sSection As String, sKey As String, sDefault_
    13.                                         As String, sIniFile As String)
    14.     Dim sBuffer As String, lRet As Long
    15.     ' Fill String with 255 spaces
    16.     sBuffer = String$(255, 0)
    17.     ' Call DLL
    18.     lRet = GetPrivateProfileString(sSection, sKey, "", sBuffer, Len(sBuffer), sIniFile)
    19.     If lRet = 0 Then
    20.         ' DLL failed, save default
    21.         If sDefault <> "" Then AddToINI sSection, sKey, sDefault, sIniFile
    22.         GetFromINI = sDefault
    23.     Else
    24.         ' DLL successful
    25.         ' return string
    26.         GetFromINI = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1)
    27.     End If
    28. End Function
    29.  
    30. ' Returns True if successful. If section does not
    31. ' exist it creates it.
    32. Function AddToINI(sSection As String, sKey As String, sValue As_
    33.                                       String, sIniFile As String) As Boolean
    34.     Dim lRet As Long
    35.     ' Call DLL
    36.     lRet = WritePrivateProfileString(sSection, sKey, sValue, sIniFile)
    37.     AddToINI = (lRet)
    38. End Function

    What I intend to do is define a standard "level" that is all the same all over. House type #1. Street type #1, walls at X,Y,Z.., etc. and then program by exeption!

    What thinks you... ...wait no - how do i do it (add an extra Key-Level)?

    [edit]That's better not half mile wide now[/edit]
    Last edited by Matt_T_hat; Apr 8th, 2002 at 06:04 PM.
    ?
    'What's this bit for anyway?
    For Jono

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width