Support Forums
Reading a text doc? - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: Reading a text doc? (/showthread.php?tid=13682)

Pages: 1 2 3


Reading a text doc? - pers2981 - 11-12-2010

I am a giant noob, troll if you must

Hey so, Im making a simple rpg (turn based) game in vb... (please dont say IMPOSSIBLE or w.e). The combat system is going good but i got stuck on the exp system... right now im planing on using something like

( i know the code is fake/wrong )
PHP Code:
on monster death
     
if monsterlv "1" then "250" exp

     
if exp = < "250" then playerlv +1
       
else 

I am now asking how would i do this part

Code:
if monsterlv = "1" then + "250" exp

Without having to do this

Code:
if monsterlv = "1" then + "250" exp
if monsterlv = "2" then + "500" exp
if monsterlv = "3" then + "750" exp
etc

Could i save the exp level thingys into a text doc or .dll ? and read it ?


RE: Reading a text doc? - KoBE - 11-12-2010

would something like this work for you?

Code:
Select Case monsterlv
            Case "1"
                exp += 250
            Case "2"
                exp += 500
            Case "3"
                exp += 750
            Case Else
                MessageBox.Show("something went wrong")
        End Select



RE: Reading a text doc? - pers2981 - 11-12-2010

(11-12-2010, 10:08 AM)the_GENie Wrote: would something like this work for you?

Code:
Select Case monsterlv
            Case "1"
                exp += 250
            Case "2"
                exp += 500
            Case "3"
                exp += 750
            Case Else
                MessageBox.Show("something went wrong")
        End Select

Possible i have never used "case" before so i have no idea


RE: Reading a text doc? - thanasis2028 - 11-13-2010

Code:
exp+=250*monsterlv
so easy...


RE: Reading a text doc? - Xzotic - 11-13-2010

Yeah guys, but hes asking if he could write the data to a file, and yes you can. Not sure why you would want to though, I think it would be more trouble than its worth


RE: Reading a text doc? - pers2981 - 11-13-2010

(11-13-2010, 08:11 AM)Xzotic Wrote: Yeah guys, but hes asking if he could write the data to a file, and yes you can. Not sure why you would want to though, I think it would be more trouble than its worth
What i mean is i dont want to have to write code for every level my game is going to have up to 1000 levels so... I was wondering if i could just put somthing like this in a txt doc

1=250
2=500
etc (level and exp)

and make the program read it and do the work...


RE: Reading a text doc? - KoBE - 11-13-2010

(11-13-2010, 09:56 AM)pers2981 Wrote: What i mean is i dont want to have to write code for every level my game is going to have up to 1000 levels so... I was wondering if i could just put somthing like this in a txt doc

1=250
2=500
etc (level and exp)

and make the program read it and do the work...

if each level increments by 250 then you wont need to read from a text. just do what thanasis2028 said.

exp += 250 * monsterlv

which is the same thing as
exp = exp + 250 * monsterlv


RE: Reading a text doc? - pers2981 - 11-13-2010

No its not going up by 250 each time... i was just using that as an example


RE: Reading a text doc? - Xzotic - 11-13-2010

I really think that it would be easier in the end to just code it in the program itself. Put it in a function so all you have to do is call a function. Of course that would take more planning that just what i said. Might need to add a few more variables and statements, but overall I think it is a better method. You would still have to read it from the file everytime + have the information in the file.


RE: Reading a text doc? - pers2981 - 11-13-2010

(11-13-2010, 02:44 PM)Xzotic Wrote: I really think that it would be easier in the end to just code it in the program itself. Put it in a function so all you have to do is call a function. Of course that would take more planning that just what i said. Might need to add a few more variables and statements, but overall I think it is a better method. You would still have to read it from the file everytime + have the information in the file.
The thing is i have never used a function :L