Vindicator209 Posted October 27, 2006 Share Posted October 27, 2006 myuh, Ive got a "Monster Maker" for a game of mine, and I want the user's to be able to "save" their monster, now, how would I go about writing a WHOLE region of my scipt to a text file? [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
spyrorocks Posted October 27, 2006 Share Posted October 27, 2006 filewrite("script.txt", fileread(@scriptfullpath)) that should get you started out. Only works for un compiled code. Or i would suggest using the INI functions. Look in the helpfile. [center] My Projects: Online AutoIt Compiler - AutoForum - AutoGuestbook - AutoIt Web-based Auto Installer - Pure AutoIt Zipping Functions - ConfuseGen - MindReader - P2PChat[/center] Link to comment Share on other sites More sharing options...
cppman Posted October 27, 2006 Share Posted October 27, 2006 (edited) Maybe these functions can help you: Func _FileWriteRegion($inFile, $nStartLine, $nEndLine, $outFile) if (not FileExists($inFile)) Then Return -1 $hFile = FileOpen($inFile, 0) $hOutFile = FileOpen($outFile, 1) For $i = $nStartLine to $nEndLine FileWriteLine($hOutFile, FileReadLine($hFile, $i)) Next FileCLose($hFile) FileClose($hOutFile) EndFunc Func _FileReadRegion($inFile, $nStartLine, $nEndLine) if (not FileExists($inFile)) Then Return -1 Local $sStr = "" $hFile = FileOpen($inFile, 0) For $i = $nStartLine to $nEndLine $sStr &= FileReadLine($hFile, $i) & @CRLF Next Return $sStr FileClose($hFile) EndFunc if your trying to save a game... you might want to write stuff like this to an INI like spyro said: [Monster1] Lives=1 Score=100 Level=25 and then reading it, and loading the game to that specific part. Edited October 27, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 27, 2006 Moderators Share Posted October 27, 2006 Maybe these functions can help you: Func _FileWriteRegion($inFile, $nStartLine, $nEndLine, $outFile) if (not FileExists($inFile)) Then Return -1 $hFile = FileOpen($inFile, 0) $hOutFile = FileOpen($outFile, 1) For $i = $nStartLine to $nEndLine FileWriteLine($hOutFile, FileReadLine($hFile, $i)) Next EndFunc Func _FileReadRegion($inFile, $nStartLine, $nEndLine) if (not FileExists($inFile)) Then Return -1 Local $sStr = "" $hFile = FileOpen($inFile, 0) For $i = $nStartLine to $nEndLine $sStr &= FileReadLine($hFile, $i) & @CRLF Next Return $sStr EndFunc if your trying to save a game... you might want to write stuff like this to an INI like spyro said: [Monster1] Lives=1 Score=100 Level=25 and then reading it, and loading the game to that specific part. You never closed any of those files Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cppman Posted October 27, 2006 Share Posted October 27, 2006 You never closed any of those files lmao! That was'nt part of the deal!! Miva OS Project Link to comment Share on other sites More sharing options...
Vindicator209 Posted October 27, 2006 Author Share Posted October 27, 2006 not even going to pretend I knew any of that' [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now