Mirage Source http://www.miragesource.net/forums/ |
|
acheiving urber speed question. http://www.miragesource.net/forums/viewtopic.php?f=201&t=1377 |
Page 1 of 20 |
Author: | genusis [ Sat Feb 17, 2007 3:42 pm ] |
Post subject: | acheiving urber speed question. |
Well I was doing the tutorial called Achieving urber speed, and I got to the point where i have to change the Load Classes sub. Code: Sub Load Classes() Dim FileName As String Dim i As Long Dim nFileNum As Integer nFileNum = FreeFile Open FileName For Binary As #nFileNum Call CheckClasses FileName = App.Path & "\data\classes.bin" Max_Classes = Val(GetVar(FileName, "INIT", "MaxClasses")) ReDim Class(0 To Max_Classes) As ClassRec Call ClearClasses For i = 0 To Max_Classes Class(i).Name = GetVar(FileName, "CLASS" & i, "Name") Class(i).Sprite = GetVar(FileName, "CLASS" & i, "Sprite") Class(i).STR = Val(GetVar(FileName, "CLASS" & i, "STR")) Class(i).DEF = Val(GetVar(FileName, "CLASS" & i, "DEF")) Class(i).SPEED = Val(GetVar(FileName, "CLASS" & i, "SPEED")) Class(i).MAGI = Val(GetVar(FileName, "CLASS" & i, "MAGI")) DoEvents Next i End Sub in the tutorial It says Code: Then instead of GetVar, replace it with the Get statement, Get #nFileNum, ,Max_Classes Replace all the other GetVar stuff with the Get stuff. Close the file at the end, Close #nFileNum The problem here is that The tutorial does not explain how to change the getvar stuff. It just says to change them with the Get #nFileNum, ,Max_Classes, which always throws an error. I did mine like this Code: Class(i).Name = [color=red]Get[/color] #nFileNum, ,Max_Classes how would you do this?
|
Author: | William [ Sat Feb 17, 2007 3:51 pm ] |
Post subject: | |
Should probably be: Code: Get #nFileNum, , Class(i).Name or Code: Get #nFileNum, , Class(i)
|
Author: | genusis [ Sat Feb 17, 2007 4:07 pm ] |
Post subject: | |
OK I think I got everything there ,but Code: Max_Classes = Val(GetVar(FileName, "INIT", "MaxClasses")) so far it looks like this for me. Code: Sub LoadClasses() Dim FileName As String Dim i As Long Dim nFileNum As Integer nFileNum = FreeFile Open FileName For Binary As #nFileNum Call CheckClasses FileName = App.Path & "\data\classes.bin" Max_Classes = Val(GetVar(FileName, "INIT", "MaxClasses")) ReDim Class(0 To Max_Classes) As ClassRec Call ClearClasses For i = 0 To Max_Classes Get #nFileNum, , Class(i).Name Get #nFileNum, , Class(i).Sprite Get #nFileNum, , Class(i).STR Get #nFileNum, , Class(i).DEF Get #nFileNum, , Class(i).SPEED Get #nFileNum, , Class(i).MAGI 'Class(i).Name = GetVar(FileName, "CLASS" & i, "Name") 'Class(i).Sprite = GetVar(FileName, "CLASS" & i, "Sprite") 'Class(i).STR = Val(GetVar(FileName, "CLASS" & i, "STR")) 'Class(i).DEF = Val(GetVar(FileName, "CLASS" & i, "DEF")) 'Class(i).SPEED = Val(GetVar(FileName, "CLASS" & i, "SPEED")) 'Class(i).MAGI = Val(GetVar(FileName, "CLASS" & i, "MAGI")) DoEvents Next i End Sub So how would I change Code: Max_Classes = Val(GetVar(FileName, "INIT", "MaxClasses"))
|
Author: | William [ Sat Feb 17, 2007 4:11 pm ] |
Post subject: | |
Code: Get #nFileNum, , Max_Classes
|
Author: | genusis [ Sat Feb 17, 2007 4:32 pm ] |
Post subject: | |
so like this Code: Max_Classes = Get #nFileNum, , Max_Classes or just Code: Get #nFileNum, , Max_Classes
|
Author: | William [ Sat Feb 17, 2007 4:41 pm ] |
Post subject: | |
Just Code: Get #nFileNum, , Max_Classes
|
Author: | Robin [ Sat Feb 17, 2007 4:42 pm ] |
Post subject: | |
Instead of getting and putting all that data, you could just do the type array in one go. |
Author: | William [ Sat Feb 17, 2007 4:46 pm ] |
Post subject: | |
Yeah, like this: Code: Get #nFileNum, , Class(i)
|
Author: | genusis [ Sat Feb 17, 2007 4:46 pm ] |
Post subject: | |
OK got that part well now I'm working on trying to convert my items to binary to. The only problem is Code: Sub SaveItem(ByVal ItemNum As Long) Dim FileName As String FileName = App.Path & "\data\items.bin" Get #nFileNum, , Item(i).Name Get #nFileNum, , Item(i).Pic Get #nFileNum, , Item(i).Type Get #nFileNum, , Item(i).Data1 Get #nFileNum, , Item(i).Data2 Get #nFileNum, , Item(i).Data3 Call PutVar(FileName, "ITEM" & ItemNum, "Name", Trim(Item(ItemNum).Name)) Call PutVar(FileName, "ITEM" & ItemNum, "Pic", Trim(Item(ItemNum).Pic)) Call PutVar(FileName, "ITEM" & ItemNum, "Type", Trim(Item(ItemNum).Type)) Call PutVar(FileName, "ITEM" & ItemNum, "Data1", Trim(Item(ItemNum).Data1)) Call PutVar(FileName, "ITEM" & ItemNum, "Data2", Trim(Item(ItemNum).Data2)) Call PutVar(FileName, "ITEM" & ItemNum, "Data3", Trim(Item(ItemNum).Data3)) End Sub And Code: Sub LoadItems() Dim FileName As String Dim i As Long Call CheckItems FileName = App.Path & "\data\items.bin" For i = 1 To MAX_ITEMS Get #nFileNum, , Item(i).Name Get #nFileNum, , Item(i).Pic Get #nFileNum, , Item(i).Type Get #nFileNum, , Item(i).Data1 Get #nFileNum, , Item(i).Data2 Get #nFileNum, , Item(i).Data3 'Item(i).Name = GetVar(FileName, "ITEM" & i, "Name") 'Item(i).Pic = Val(GetVar(FileName, "ITEM" & i, "Pic")) 'Item(i).Type = Val(GetVar(FileName, "ITEM" & i, "Type")) 'Item(i).Data1 = Val(GetVar(FileName, "ITEM" & i, "Data1")) 'Item(i).Data2 = Val(GetVar(FileName, "ITEM" & i, "Data2")) 'Item(i).Data3 = Val(GetVar(FileName, "ITEM" & i, "Data3")) DoEvents Next i End Sub use a different method. one uses Code: 'Item(i). And the other uses Code: "ITEM" & ItemNum how would i do this just give me an example for the Code: "ITEM" & ItemNum
|
Author: | funkynut [ Sat Feb 17, 2007 5:28 pm ] |
Post subject: | |
Reason their different is because ones loading and ones to save. You should be using Put instead of Get, and use ItemNum instead of i Code: put #nFileNum, , Item(itemnum).Pic And in both the example you've shown, you have forgotten to open the file Code: Open FileName For Binary As #nFileNum Oh, and you've forgotten to close it afterwards in every peice you've shown Code: Close #nFileNum And even if you got it to save load, I got a feeling it wont run right, in my mind when I run that, it loads everything fine, but when you save, you'll only save the last item[/code] |
Author: | Obsidian [ Sat Feb 17, 2007 7:25 pm ] |
Post subject: | |
The tutorial i recently posted in the 'Optimized Tutorials' Section, called Simple Binary (Single File) Saving... is the same tutorial you were looking at, but much more simplified and easy to use (and it gives you the same speed as the tutorial you're currently struggling with). |
Author: | genusis [ Sun Feb 18, 2007 2:45 pm ] |
Post subject: | |
thank you guys for your help. Oh and Open FileName For Binary As #nFileNum, and Close #nFileNum where not added becuase I didnt add them yet, but I didnt forget about them lol. Thank you. |
Author: | wanai [ Sun May 22, 2022 7:47 am ] |
Post subject: | Re: acheiving urber speed question. |
Teuf |
Author: | wanai [ Sun May 22, 2022 7:49 am ] |
Post subject: | Re: acheiving urber speed question. |
157.3 |
Author: | wanai [ Sun May 22, 2022 7:50 am ] |
Post subject: | Re: acheiving urber speed question. |
Repr |
Author: | wanai [ Sun May 22, 2022 7:51 am ] |
Post subject: | Re: acheiving urber speed question. |
CHAP |
Author: | wanai [ Sun May 22, 2022 7:52 am ] |
Post subject: | Re: acheiving urber speed question. |
Ever |
Author: | wanai [ Sun May 22, 2022 7:53 am ] |
Post subject: | Re: acheiving urber speed question. |
Nora |
Author: | wanai [ Sun May 22, 2022 7:54 am ] |
Post subject: | Re: acheiving urber speed question. |
Anto |
Author: | wanai [ Sun May 22, 2022 7:55 am ] |
Post subject: | Re: acheiving urber speed question. |
Jame |
Author: | wanai [ Sun May 22, 2022 7:56 am ] |
Post subject: | Re: acheiving urber speed question. |
Verl |
Author: | wanai [ Sun May 22, 2022 7:58 am ] |
Post subject: | Re: acheiving urber speed question. |
Guid |
Page 1 of 20 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |