Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 More RPG Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
azndragon




PostPosted: Thu Jan 23, 2003 11:03 am   Post subject: More RPG Help

Well, I was just wondering if setting up multiple rooms using modules would be effective. I know that procedures would be impossible to do, because they procedures have to be in a certain order, which could not happen. For example, if I load room 13, and then move to room 14, the procedure for room 14 will be above room 13. However, once I get to room 14, and want to move back to room 13, the procedure for room 13 would have to be above room 14, so it would be an impossible arrangement. So if modules aren't the solution, is there anything else I can do? Thanks.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jan 23, 2003 5:18 pm   Post subject: (No subject)

hardcoding anything is generally bad practice... unless you want to hide some information, but then there's encription...

Anyway, the solution would be to load dynamic rooms from the file and basically generate the room as you walk into it.

Upon exiting a room, a variable is read from the "door" part of the room that tells which file contains information about the next room. That file is then loaded and text information read such as size, location of objects, doors, etc. Those values are loaded into variables used to store active room in the program and suddenly you appear in a brand new room Very Happy

Dan wrote a tutorial on how to read/write from a file in the tutorial section if you need help with that.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
azndragon




PostPosted: Thu Jan 23, 2003 6:03 pm   Post subject: (No subject)

I'm having some trouble following what you are saying. Can you give me a basic example of what my code should look like?
Tony




PostPosted: Thu Jan 23, 2003 7:54 pm   Post subject: (No subject)

hmm... well lets see how your organize your room procedures?

Try to put all the variable values in the textfile and then load it up... if you're having trouble, post one of your procedures and I'll try to help you.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
azndragon




PostPosted: Fri Jan 24, 2003 2:29 pm   Post subject: (No subject)

Well, if I tell Turing to load a certain file with Turing commands in them, will they run properly? Like for example, I make a file called "test". I open it up, and type in put "hi" in it, close it and save. If I go into Turing and get it to read the file, will it actually follow the instructions?
Tony




PostPosted: Fri Jan 24, 2003 6:05 pm   Post subject: (No subject)

no... thats what include does. And when compiled, it will paste the code into the place of the include (I think you can crash the program if you make a loop out of includes).

What you need to do is load the variables. Such as if you know that the text you want to display is the first line of the file, then you do something like
code:

get : fileNum, text:*
put text


ofcourse you need to properly open the file first, read tutorial for more info Wink

Basically the file only contains text information. You need to write some code that can read that information and make sence of it. Such as if you don't know what the varaible is suppost to do, you can put additional "help" word that your program will ID

code:

get : fileNum, helpword
if helpword = "put" then
     get : fileNum, text:*
     put text
end if


in this example, the program reads first word on the line and if it happens to be a command such as "put", it will put the text that follows on that line.

I suppose to can write your own vertual compiler in turing to actually run the code. You're going to have a hard time accessing variables though.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
azndragon




PostPosted: Fri Jan 24, 2003 7:27 pm   Post subject: (No subject)

Ah okay, thanks, but I just figured out my own way, while I was gone Very Happy . So now, I have a way for it to move in between rooms, and I already have 5 rooms set up. As soon as I finish 25 of them, I might wanna post it here.
Vicous




PostPosted: Mon Mar 03, 2003 12:21 am   Post subject: include?

can you give more of an example of how include works?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Mar 03, 2003 12:25 am   Post subject: (No subject)

include basically copy/pastes the code from the file into your program. This works much like C/C++ header files where you save functions in an outside file and include all the content of it with a single line.

In theory, if you have couple of files including eachother in a circle, it should crash your program as it will become infinantly long (remember, it includes the code, not referecing it. You should use functions for that)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: