Author |
Message |
d2bb
|
Posted: Tue Apr 17, 2007 10:11 am Post subject: Detection And opening files. |
|
|
well first i'd just like to know what cmd to use to open a file (Open a game file, so it runs)
Second Question:
Im just making a simple bot, that mimics a users. (Bot can do exact same stuff as human, like: Heal, Attack, So on..)
For example:
If your player has 100 life, and ud like the bot to heal you if you lose health, how would i detect that the life has decreased.
(my explonation may be sketchy) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Tue Apr 17, 2007 2:48 pm Post subject: RE:Detection And opening files. |
|
|
What type of file do you mean? If you mean a text file that you can open and extract information from, then you'll need to look into File I/O in the Turing Walkthrough. If you mean files such as .exes, then look into Sys.Exec()
To detect if life decreases you'll need some sort of variable to keep track of max life, as well as current life. |
|
|
|
|
![](images/spacer.gif) |
Carey
![](http://mirkon.sneezepower.com/images/multilockon.gif)
|
Posted: Wed Apr 18, 2007 8:47 am Post subject: Re: Detection And opening files. |
|
|
Turing: | function translate (dir : string) : string %converts all "/"s to "\"s
var path := ""
for i : 1 .. length (dir ) %used for counting substrings
if index (dir (i ), "/") = 0 then %if the substring is not "/"
path + = dir (i ) % add the current letter to the string
else %if the substring is "/"
path + = "\\" %add a "\" the the string
end if
end for
result path %return the path
end translate
procedure runFile (path : string)
if not Sys.Exec (path ) then %if the path has spaces this won't work
if not Sys.Exec ("C:/WINDOWS/explorer.exe " + translate (path )) then %use explorer to open the file
end if
end if
end runFile
runFile ("notepad.exe") %has to be full path unless the file is in the current dir or is in the windows dir(notepad.exe)
|
That should work for opening any file. If you use a path with spaces the file will open with explorer and will sometimes give the option to save or open the file. This is because it opens the files that it doesnt know what to do with with IE. |
|
|
|
|
![](images/spacer.gif) |
Daetyrnis
![](http://compsci.ca/v3/uploads/user_avatars/1306331031460b0611859a8.png)
|
Posted: Wed Apr 18, 2007 3:33 pm Post subject: Re: Detection And opening files. |
|
|
Rather than...
Turing: | if index (dir (i ), "/") = 0 then |
...wouldn't...
Turing: | if dir (i) ~= "/" then |
...be more efficient? |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: Wed Apr 18, 2007 6:30 pm Post subject: RE:Detection And opening files. |
|
|
That is true Daetyrnis.
Carey, you should consider making the translate function recursive to reduce its size and possibly increase the efficiency. |
|
|
|
|
![](images/spacer.gif) |
d2bb
|
Posted: Tue May 08, 2007 2:27 pm Post subject: RE:Detection And opening files. |
|
|
yea, what if there is spaces in the dir. lol.
ill play around with this code for a while try 2 c if i can figure out what u wrote
thx for help ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Carey
![](http://mirkon.sneezepower.com/images/multilockon.gif)
|
Posted: Wed May 09, 2007 8:47 am Post subject: Re: Detection And opening files. |
|
|
How would i make the translate funtion recursive and how would it make it more efficiant? wouldnt you still have to add all the letters to another string that returns? |
|
|
|
|
![](images/spacer.gif) |
|