Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / changing text

Author
Message
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 11th Apr 2009 19:55 Edited at: 11th Apr 2009 20:17
i'm makeing a text game as my 3rd project and i was wondering if for example at the biggining of the game you have a fight with a boy.
if i wanted to make a text
text x,y, "so you (won fight)(lost fight)"
how would i make ut where it puts "so you won the fight" if you won
with one line of code instead of makeing two IF statements.
(and if you lost "so you did'nt do so well")

also(lol, i've edited this post 4 times)how do you keep info on somthing even if you turn the game off like varables or highscores

im new at this
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 11th Apr 2009 20:17


I'm sure that there's a shorter way, but this is the easiest.

That's what they WANT you to think...
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 11th Apr 2009 20:39
store the win/lose text in a array then do it like this

Text x,y,text$(Win)

so then win is either 0 or 1 and so it would show different text depending on the winning status.

as for retaining data.
use a file like this:

Open to write 1,"MyData.txt"

that CREATES a new file it cannot exist when youcall this.

then write all your data and close the file.
when you load it back up use

Open to read 1,"Mydata.txt"

this opens a file to read You cannot write to a file like this.

then when you need to close again you delete that file open to write again and write all the data from the old file (and any new data) and close the file

if your file is just for highscores you can use load array and save array they are easier for that.

so you dim a array like so:

dim scores$(9)

then you load the lines of a file into that array

Load array "MyFile.txt",Scores$(9)

the place number for thearray does not matter it just has to haVe a value. this will load lines 1 through 10(don't forget about scores$(0) lol) of that file into the array. then of cource you have to use val() and stuff to get the actuall values of the string.

then you save it with save array

Save array "MyFile.txt",Scores(10)

once again the number for the array doesn't matter.

hope that helps

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 11th Apr 2009 20:46 Edited at: 11th Apr 2009 21:14
thanks @Quirky and @Caleb that will help alot.

@Caleb,
looks a little complicated but i'll see if i can do it.if i have any Q's on the retaining data thing i'll leave a post on here

do you have to use data like
data 4,68,6,
data 6,9,5,8
(i don't understand data yet)

i need the retain data for varibles

how do i store that x=100 and beable to cange it whenever
and when i turn it on again it loads x

im new at this
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 11th Apr 2009 23:24 Edited at: 12th Apr 2009 00:03
alright, i got ot figured out.

im going to use arrays for the data storing.

im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Apr 2009 05:03 Edited at: 12th Apr 2009 05:06
When i say "Data" i don't mean the data command. i mean data in general like any information you need to save.

For your "X" question.

Well when you use Open to write then you can use write string and just use the Str$() function to save it as a string. the only reason i use strings is because then if you save everything asstrings if you open up your file in notepad you can read all your values.

you can optionaly save it with write float but i like string so i can see what i'm doing.

then when you game loads just Read the string again and set x = Val(string$) and your going to need to know how your saving your stuff like in what order. because to get all the stuff back it reads it all in order so at the beginning when you use read string it reads the first line then next time the second and so on....

so if you save lets say a variable called y first then X and you wanted to load them you would have to do this



if you read x first then y then you variables would be flopped.

But to do this at the end of the program you HAVE to save x lol


heres a example. run it. input some stuff then close it. run it again and it will show you what you inputed last time.



hope that helps.

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 12th Apr 2009 07:06
thanks i've been trying to figure out what the open to write stuff was and now i know.for my text adventure game i decided to use arrays to retain info.When im finished i'll post the game here i think your like it.

im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Apr 2009 22:46
Sweet! Ya the file commands confused me for a long time but once you get it it's like "Oh ya thats how it works" lol.


I look forward to seeing how it goes!

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 14th Apr 2009 02:37
How would you turn this into a minigame where you have 1 min to
figure out what the random number is and you have to enter a number
1-99 then press enter and if right then goto win


im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 14th Apr 2009 07:33
not sure what you mean? that is essentially it. you just need the input command (or make your own) and get a little indention in there.


Oh wait

Quote: " solve$=entry$"


do you mean "Entry$()" if so then that captures all the input from the keyboard. so if you use it it will be a string containing every character hit on the keyboard from start to end. to clear it use Clear entry buffer. that is the basics of your own input function. although you must be careful using it.it still trys to print returnkey and backspace and stuff which spits out those boxes.

heres a ruff example of a input function. if thats what you need. if not then you've got it anyway lol



New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 14th Apr 2009 23:07
I was makeing a game where you have to guess the random number 1-99.

And you have to do it before the time runs out.Thats why i needed to do it with entry$.But i think that will help.Thanks

im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 15th Apr 2009 00:51
Anytime.


OffTopic:

Nice Signature lol

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 17th Apr 2009 02:51 Edited at: 17th Apr 2009 06:50
here's where im at ,i know i did'nt spell some things right,im not very close to being done but i've got the main stuff if you got any coments please leave them(good or bad).I've done most of my story on the boy.This just to show you where im at i've got so much to go i did'nt exspect so much text.o ya its a NO MEDIA game. yaaaaa!



im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 17th Apr 2009 05:31
Error at line 208


The Label Q doesn't exist lol

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 18th Apr 2009 02:12
Sorry,
I made a last min change and I forgot to check it

So do you like,do you think i should add anything or change anything?

im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 18th Apr 2009 05:41
Havn't tried it yet. it gave that error. can i take that line out or something?

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 18th Apr 2009 05:46 Edited at: 18th Apr 2009 05:49
ya, just erase it.

it's not finished just play as boy

im new at this
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 18th Apr 2009 07:29
Looks good!

Suggestions:

Some Spelling Mistakes ("Biskits" for one should be "Biscuits")

One or 2 text displays went off the screen

A little more description on what the controls are for each screen. like some were input and some were just pressing arrow keys.

Position the input commands. there are at 0,0 right now.

Maybe consider some mouse input for each screen if you want.

New Site! Check it out \/
Roland Conrad Szigeti
16
Years of Service
User Offline
Joined: 12th Apr 2009
Location: Melbourne
Posted: 18th Apr 2009 11:02
interesting text game

Login to post a reply

Server time is: 2025-06-08 05:37:22
Your offset time is: 2025-06-08 05:37:22