[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2010-01-24T00:21:53-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/3210 2010-01-24T00:21:53-05:00 2010-01-24T00:21:53-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20366#p20366 <![CDATA[Inventory in a simple text adventure.]]> Statistics: Posted by BigBadKing — Sun Jan 24, 2010 12:21 am


]]>
2010-01-23T19:35:34-05:00 2010-01-23T19:35:34-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20365#p20365 <![CDATA[Inventory in a simple text adventure.]]>
GOTO a C forum if that's what you know! Your a BIG MOUTH in my books!

Do it right or be quiet please.......

Statistics: Posted by burger2227 — Sat Jan 23, 2010 7:35 pm


]]>
2010-01-23T07:41:29-05:00 2010-01-23T07:41:29-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20364#p20364 <![CDATA[Inventory in a simple text adventure.]]> by the way, i should start ignoring you!

Statistics: Posted by BigBadKing — Sat Jan 23, 2010 7:41 am


]]>
2010-01-23T05:59:47-05:00 2010-01-23T05:59:47-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20363#p20363 <![CDATA[Inventory in a simple text adventure.]]>
If you program like your examples here, you didn't learn much!

Statistics: Posted by burger2227 — Sat Jan 23, 2010 5:59 am


]]>
2010-01-23T03:52:25-05:00 2010-01-23T03:52:25-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20362#p20362 <![CDATA[Inventory in a simple text adventure.]]>
first off, you are right we are not equal. since my ten years experience
is NOTHING against your WhatSoEver experience of programming.

second off, i never force anybody to do anything.

third off, leave everybody in this board in peace. if you really want
to start arguing about something which has no sense at all. then do
that in the General Discussion one.

fourth off, instead of bothering other people's suggestions. make your
own suggestion.

Statistics: Posted by BigBadKing — Sat Jan 23, 2010 3:52 am


]]>
2010-01-23T01:01:44-05:00 2010-01-23T01:01:44-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20361#p20361 <![CDATA[Inventory in a simple text adventure.]]>
When you have been programming a lot more, perhaps we can discuss optimization of code. Until then, do what YOU want. Don't force it down other peoples throats!

I spend a LOT of time helping people here and I DON'T need THAT kind of help!!!!

Statistics: Posted by burger2227 — Sat Jan 23, 2010 1:01 am


]]>
2010-01-23T00:30:35-05:00 2010-01-23T00:30:35-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20360#p20360 <![CDATA[Inventory in a simple text adventure.]]> from scratch and build up every little details you may have skipped.
by the way, whats your problem cheese-burger?

Statistics: Posted by BigBadKing — Sat Jan 23, 2010 12:30 am


]]>
2010-01-22T15:34:58-05:00 2010-01-22T15:34:58-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20359#p20359 <![CDATA[Inventory in a simple text adventure.]]>
Do you see where the 20 is. Type DO there instead.

Code:

Type LOOP UNTIL INKEY$ = CHR$(27) ' where the GOTO line is
To exit press the [Esc] key

Shame on you KING. :( A forever loop that requires Ctrl-Brk?

Don't show people how to code worser! Next you'll be telling him to use LET........mercy

Statistics: Posted by burger2227 — Fri Jan 22, 2010 3:34 pm


]]>
2010-01-22T15:21:08-05:00 2010-01-22T15:21:08-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20358#p20358 <![CDATA[Inventory in a simple text adventure.]]>
1) type your text, copy it, and then post the message. if the
message is deleted, just edit your existing message or make
a new one with the text you copied

2) type your text in notepad or any other text editor, copy the text
and paste it then post your message.

Statistics: Posted by BigBadKing — Fri Jan 22, 2010 3:21 pm


]]>
2010-01-22T15:18:09-05:00 2010-01-22T15:18:09-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20357#p20357 <![CDATA[Inventory in a simple text adventure.]]>

Code:

 declare sub ShowBackpack declare sub TakeItem(NameOfItem$) dim shared items dim shared Inventory$(100) 20  input c$  c$ = ucase$(c$)             ' make the command case-insensitive  if c$ = "TAKE CAMERA" then   TakeItem("Camera")  end if  if c$ = "BACKPACK" then   ShowBackpack  end if goto 20 sub ShowBackpack  for i = 1 to items   print Inventory$(i)  next i end sub sub TakeItem(NameOfItem$)  for i = 1 to Items  if NameOfItem$ = Inventory$(i) then GotIt = 1: exit for  next i  if GotIt = 1 then print "You already have it!" end sub

Statistics: Posted by BigBadKing — Fri Jan 22, 2010 3:18 pm


]]>
2010-01-22T15:13:02-05:00 2010-01-22T15:13:02-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20356#p20356 <![CDATA[Inventory in a simple text adventure.]]> it works like this:

[code]
goto Label:

Label:
print "Label"
[/code]

gosub works like this:

[code]
gosub Label:
print "Back"

Label:
print "Label"
return
[/code]

run the second code, GOSUB doesnt mean to head into
a SUB command. while it goes into a label, and does everything
descriped in that label until it reaches the RETURN command.
on which it returns back to where the GOSUB was last time used.
okay, now for the SUB command. look at the following program:

[code]
declare sub ShowBackPack
if c$ = "BACKPACK" then call ShowBackPack()

sub ShowBackPack
for i = 1 to items
print Inventory$(i)
next i
end sub
[/code]

put this after the TAKE CAMERA program. it prints nothing!
to make it print something, replace the existing ITEMS and
INVENTORY$ with:

[code]
dim shared Inventory$(100)
dim shared items
[/code]

run your program and it prints "Camera" if you got the camera.
hope it helps. if it doesnt, ask me any question!

Statistics: Posted by BigBadKing — Fri Jan 22, 2010 3:13 pm


]]>
2010-01-22T10:22:55-05:00 2010-01-22T10:22:55-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20355#p20355 <![CDATA[Inventory in a simple text adventure.]]>
So, I'll try to remember everything I said.

First of all, you explained this to me very well. I found a tut last night that makes use of a similar concept, but the guy didn't take the time to explain why it works, which is something that is absolutely necessary for me. I CRAVE to know why and how things work.

So, here's the piece of code from the other guys tut:
10 Rem *** Main Loop ***
print LocationDescription$(PlayerLocation)
Print : Print "Enter Command: ";
Input PlayerInput$
If (PlayerInput$ = "i") or (PlayerInput$ = "I") then gosub 1000 'Take Inventory
Goto 10

1000 Rem *** Take Inventory ***
Print "You are carrying the following items:"
ItemsCarried = 0
for i = 1 to MaxItemNumber
if ItemLocation(i) = 0 then ItemsCarried = ItemsCarried + 1: Print ItemName$(i)
Next i
If ItemsCarried = 0 then print "Nothing."
Return
As you can see, he makes use of a subroutine. This is so that the user can type "BACKPACK" at any point in the game, and he will be directed to the BACKPACK sub, which will return him to the point in the game where he was at when he exits the BACKPACK. I attempted to use this code, but it didn't exactly work as planned. Here's a piece of code from my game:
INPUT " INPUT: ", l$
IF l$ = "TAKE A SHOWER" THEN GOTO 21
IF l$ = "HELP" THEN GOTO 22
IF l$ = "TURN ON LIGHT" THEN GOTO 24
IF l$ = "BACKPACK" THEN GOSUB Backpack
IF l$ <> "TURN ON LIGHT" OR l$ <> "BACKPACK" OR l$ <> "TAKE A SHOWER" OR l$ <> "HELP" THEN GOTO 23
END
So, if the user types one of the three available commands (TAKE A SHOWER, HELP, and TURN ON LIGHT) then he is taken to their corresponding pages. If he typed anything other than those three commands, then he was taken to a page which said, in so many words, that the command was not one of the available actions. This worked fine until I added the BACKPACK parts. For some reason, when the user types BACKPACK, it refuses to GOSUB: it takes the user to the "Command not available" message. It's not recognizing BACKPACK as one of the available commands. Here is the corresponding SUB.
SUB Backpack
1000 CLS
PRINT " Your Backpack:"
PRINT " _______________________"
ItemsCarried = 0
FOR i = 1 TO MaxItemNumber
IF ItemLocation(i) = 0 THEN ItemsCarried = ItemsCarried + 1: PRINT ItemName$(i)
NEXT i
IF ItemsCarried = 0 THEN PRINT "Nothing."
RETURN

END SUB
So what's the major malfunction here? At first I thought it was because the SUB is all the way at the end of all the code. But, from my understanding of how SUBs work, this shouldn't matter. I'd like to make use of a SUB because I don't want to have to write a new inventory code for every scene, but I'd also like to make use of your inventory code, as it's much cleaner than this guy's inventory code.

Statistics: Posted by JBender23 — Fri Jan 22, 2010 10:22 am


]]>
2010-01-22T01:23:20-05:00 2010-01-22T01:23:20-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20354#p20354 <![CDATA[Inventory in a simple text adventure.]]>
DO
LOOP UNTIL INKEY$ <> ""

Statistics: Posted by burger2227 — Fri Jan 22, 2010 1:23 am


]]>
2010-01-22T00:55:49-05:00 2010-01-22T00:55:49-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20353#p20353 <![CDATA[Inventory in a simple text adventure.]]> the inventory formula i use:

[code]
dim Inventory$(100) ' declare an array of 100 elements
[/code]

arrays are a long-list of variables, the dollar sign means this is a
String Array. now:

[code]
Items = 0
[/code]

this one sets the Variable items to zero, since the main character
didnt get anything. now lets imagine your character wants to take
a camera by typing "TAKE CAMERA". the following code while add
that item to this inventory:

[code]
if c$ = "TAKE CAMERA" then
Items = Items + 1 ' add one item
Inventory$(Items) = "Camera" ' remove the camera
end if
[/code]

now, whenever you type TAKE CAMERA. you get a camera, to
avoid this. type:

[code]
if c$ = "TAKE CAMERA" then
GotIt = 0
for i = 1 to Items
if Inventory$(i) = "Camera" then GotIt = 1: exit for
next i
if GotIt = 0 then Items = Items + 1: Inventory$(Items) = "Camera"
if GotIt = 1 then print " You already have it!"
end if
[/code]

you already know the first command, the third command starts
going until it reaches a NEXT command and it starts at the third
line until the condition in the FOR command becomes true.
the fourth line, checks if you have the Camera. if you have, then
it sets the Variable GotIt to one and EXITs the FOR loop. the
sixth line checks if you dont have the Camera, if you dont. then
it picks it up. if you have, it prints you already do have it. and
now to show the Inventory when your player types BackPack:

[code]
if c$ = "BACKPACK" then
for i = 1 to items
print Inventory$(i)
next i
end if
[/code]

phew. and thats it! if you have any questions, then tell me.

Statistics: Posted by BigBadKing — Fri Jan 22, 2010 12:55 am


]]>
2010-01-22T09:48:07-05:00 2010-01-21T22:24:51-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=20352#p20352 <![CDATA[Inventory in a simple text adventure.]]>
'\\\\UNTITLED TEXT ADVENTURE////
'This will be some sort of text adventure involving a day in the life of a
'Fountain-Fort Carson High School Student

PRINT
PRINT
PRINT " ____________
PRINT " |____ ____| _______ __ __ ___ _______ ______
PRINT " | | \ | || \ | || \ | || \ 's
PRINT " _ | | B || ____|| \ || D || ____|| RR |
PRINT " | | | | / | |_ | |\ || D || |_ | __/
PRINT " | |__| | \ | _} |__| |__||____/ | _} | \ \
PRINT " |_______| B || |_____________________| |____ | | \ \
PRINT " (c)2009|_____ / |________________________________||__| \__\
PRINT " _
PRINT " / \
PRINT " / /_\ \
PRINT " / _____ \
PRINT " /___/ \___\
PRINT " _________ _________
PRINT " |___ ___| |___ ___|
PRINT " | | | |
PRINT " | | | |
PRINT " |_| ROJAN |_| ALE
PRINT
PRINT
PRINT " FRESHMAN YEAR



PRINT
PRINT
INPUT " Press any button to play. " , a$
IF a$ = "" THEN GOTO 10

10 CLS
PRINT
PRINT
COLOR 15
PRINT
PRINT " It still seems as though you were just getting out of school"
PRINT " yesterday, but summer has already faded away. You feel as "
PRINT " though you wasted the time that was given to you. Now you are"
PRINT " starting at a new school: Fountain-Fort Carson High. "
PRINT
PRINT " As the car approaches the school, you feel the sensation of"
PRINT " encroaching doom. What could you possibly do to avoid starting"
PRINT " high school so soon? Maybe you could jump off a cliff and break"
PRINT " your leg. No, you're parents would still make you go. Perhaps"
PRINT " you could gouge out your own eyeballs?"
PRINT
PRINT " It's the day of freshman registration, and your mom sits next"
PRINT " to you, filling out some sort of medical form. She says you must"
PRINT " sign your name at the bottom."
COLOR 7
PRINT
PRINT
INPUT " (NAME): " , nm$
IF nm$ = "" THEN GOTO 10

15 CLS
COLOR 15
PRINT
PRINT
PRINT " After finishing the forms, you have your picture taken for your"
PRINT " School I.D. You talk to a few friends from the middle school, but "
PRINT " everyone seems too nervous to hold much of a conversation. You"
PRINT " get your I.D., and then you have to wait in the library to get your"
PRINT " laptop. After everything is finally taken care of, you return home"
PRINT " for your final week of vacation.
PRINT
COLOR 11
PRINT " ONE WEEK LATER..."
PRINT
PRINT
PRINT
COLOR 12
PRINT " BUZZ! BUZZ! BUZZ! BUZZ! BUZZ! BUZZ! BUZZ!
PRINT
PRINT
PRINT
COLOR 7
PRINT
INPUT " INPUT: " , c$
PRINT
PRINT " For help, type "HELP"

IF c$ = "HELP" THEN GOTO 16
IF c$ = "TURN OFF ALARM" THEN GOTO 20
16 PRINT
PRINT " Try turning off the alarm "type commands in ALL CAPS"
PRINT



20 CLS
PRINT


Anyway, as you can see, I'm working with minimal knowledge. I'm not looking for too much....honestly I could complete this if I could just get the inventory figured out.

I want to implement a very simple inventory system. By typing "BACKPACK" at any point in the game, I want the user to be taken to a simple list of the items he/she has obtained. The user will be able to obtain these items (which will be necessary to complete other parts of the game) by "PICK UP"ing them.

For example, the user could find a spoon early in the game, then later on an NPC will need a spoon so that other events can be triggered.

So I already know how to make a screen with a list, but how could I have the computer automatically add certain words to the list when the user "PICK UP"s them?

Then, how could I have the computer check to see whether or not there is a specific item in the list so that the user can "GIVE TO" this item to trigger another event?

I was brainstorming, and I was thinking you could have it assing the string variable a certain numeric value, then check for that numeric value when it is needed.

But I don't know. Any suggestions?

EDIT: The message board got rid of all the spaces that spaced out the ASCII art and all of the paragraph formatting.

Statistics: Posted by JBender23 — Thu Jan 21, 2010 10:24 pm


]]>