Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: obon7 on November 22, 2011, 07:28:04 pm

Title: nooboish prgrammer
Post by: obon7 on November 22, 2011, 07:28:04 pm
I'm cyrrently designing a text based RPG that includes the basic things you would expect to find in an RPG however I cant figure out how to create a menu or something else that works like an invetory such as using a potion takes you to a different menu asking if you wan't to use it so any ideas on how to make an inventory that you can add and take items form would be helpful.THX :banghead:
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 07:41:17 pm
Do you mean having a variable menu? If you could give me an example, that would be great. Also, welcome to omnimaga. You should introduce yourself (http://www.omnimaga.org/index.php?board=10.0).
Title: Re: nooboish prgrammer
Post by: saintrunner on November 22, 2011, 08:25:48 pm
Menu("title","Firstvariable",A,"second",B,"etc.",C)
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 09:08:13 pm
I know how to do that the problem is in my game i want i to make so that if in a menu i have one option that is for inventory i would want it too be able to store the objects you find while searching a forest or something. I can't really do that because storing and altering objects in a menu is difficult. So any other functions or any other ideas would help. *. :w00t:
Title: Re: nooboish prgrammer
Post by: saintrunner on November 22, 2011, 09:09:48 pm
like save it as a appvars? or am I still thinking axe! :P lol make a text rpg in axe, and I could help you a lot more, lol
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 09:11:23 pm
Sorry, I am still having trouble understanding what you want. If you could write out an example, that would be helpful to me, allowing me to help you :)
Title: Re: nooboish prgrammer
Post by: epic7 on November 22, 2011, 09:13:46 pm
Save them after you quit the game or just during the game?
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 09:24:14 pm
I know how to do that the problem is in my game i want i to make so that if in a menu i have one option that is for inventory i would want it too be able to store the objects you find while searching a forest or something. I can't really do that because storing and altering objects in a menu is difficult. So any other functions or any other ideas would help. *. :w00t:

Use a list... first create a guide for yourself (aka something like potions, apples, feathers, etc), then use a list to keep track of the items.
You can use a list by doing:
Code: [Select]
{0,4,5}->L1By using the guide, you have: 0 potions, 4 apples, and 5 feathers
Then you can access the list by using:
Code: [Select]
L1(1)^ That will return zero, as the first element in the list, the potions, are zero.
Also, think of each element of a list as a variable, aka L1(1) can be thought of as A, so you can use code like 1->L1(1)  or even   L1(1)+1->L1(1)

Using this, you can make a menu, and read from the list to help make it easier/ display amounts of items. :)
Hope this helped! :D
Title: Re: nooboish prgrammer
Post by: saintrunner on November 22, 2011, 09:28:10 pm
so is the '1' in L1(1) referring to the first number in the list a.k.a the 0?
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 09:29:00 pm
so is the '1' in L1(1) referring to the first number in the list a.k.a the 0?
Yes.
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 09:29:19 pm
so is the '1' in L1(1) referring to the first number in the list a.k.a the 0?
Yes
Title: Re: nooboish prgrammer
Post by: saintrunner on November 22, 2011, 09:29:37 pm
OH COOL! that is so helpful!

is that the same in axe?
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 09:31:25 pm
No. In axe, when you use a static pointer, or saferam area, the offset is the bytes. The concept is the same though, reading numbers from data.
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 09:31:28 pm
I've tried making entire games without using any variables, just one list.  It was slower than if I used variables, but it worked, and all of those important numbers from A to Z and theta were safe! ;D

And in Axe, you cannot make lists, but more of an array format.  You store  multiple bytes in a row to a point in memory, and then using that same memory location + the offset, as mrm said, you can access the individual bytes you stored
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 09:33:10 pm
so pretty much I want a way that all the items in the game that you find or buy (all decisions in the game are made by navigating a single menu ) are stored in a form that you can access from the menu to lead to another menu type of setting and then be able to view/use the items that are in your "inventory".
The menu looks a bit like this
:"options","fight",D,"search",E,"Explore",f,"shop",g,"sleep",H,"inventory",I,"exit",1
basically all of these lead to different parts in the program (Lbl's etc.) and eventually lead back to the beginning menu. There is also title screen and obviously this isn't the whole program because I only put the part that I have trouble with. I will upload the rest of my code in hopefully less than a week. :banghead:
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 09:37:52 pm
thanks but then how do you make it so it specifically says 0 potions and choosing that off the menu will work like other functions in a menu. Also once a list is created can you alter it by for example you use a potion or you find a potion. THX guys I just joined and am getting all of these replies makes me like the omnimaga community.

edit: in response to chattahippie
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 09:40:21 pm
Code: [Select]
:Lbl M
:"for main menu
:Menu("Options","Rest",1,"Fight"'
:Lbl 1
:...Stuff
:Goto M
:Lbl 2
:Menu("Fight","Use Sword",3,"Use Bow",4,"Back",M
:Lbl 3
:...stuff
:Goto M
:Lbl 4
:...stuff
:Goto M
Like this?
Title: Re: nooboish prgrammer
Post by: saintrunner on November 22, 2011, 09:40:53 pm
there are ways, like I said, I could do all this in like 1 hour in axe lol :)
and just so you know you should double post within 6 hours, just use the modify button! :)
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 09:47:24 pm
I guess it may not be possible but I envision more like in the menu that I have posted you could simply choose inventory and that would take you too a different screen that shows all the items you have found or bought and be able to use for example a health potion or something.
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 09:47:24 pm
Okay, here is the code for a simple menu:

Code: [Select]
"Set up variables
{0,4,5->L1
2->Y
"Y will be used for the cursor
0->G
"G will be for key presses
Output(1,1,"INVENTORY
Output(2,2,"Potions
Output(3,2,"Apples
Output(4,2,"Feathers
Output(2,10,L1(1
Output(3,10,L1(2
Output(4,10,L1(3
While G=/=23
"23 is the code for [mode]
getKey->G
If Ans =/=0
Then
Output(Y,1,"_"
"Where _ is space
Y+(G=34)(Y=/=4)-(G=25)(Y=/=2)->Y
Output(Y,1,">
"Then for jumping to other code
If (G=105) and (Y=2)
Goto PO
" jump to potion code or code potions here
If (G=105) and (Y=3)
Goto AP
"apple code jump or here
"repeat for Feathers"
End
End
Try that, should work okay
Tell me if you have questions, or if it doesn't work ;D
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 09:49:06 pm
If you want something like this:
(http://clrhome.tk/resources/homer/?t=Potions%3A9%0D%0A1%3AUse+potion%0D%0A2%3ABuy+potion%0D%0A4%3AOther+stuff%0D%0A5%3AExit)
Where it shows how many potions you have, tell me.
You can use a custom menu, or a manipulated OS one
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 09:51:31 pm
Okay, here is the code for a simple menu:

Code: [Select]
"Set up variables
{0,4,5->L1
2->Y
"Y will be used for the cursor
0->G
"G will be for key presses
Output(1,1,"INVENTORY
Output(2,2,"Potions
Output(3,2,"Apples
Output(4,2,"Feathers
Output(2,10,L1(1
Output(3,10,L1(2
Output(4,10,L1(3
While G=/=23
"23 is the code for [mode]
getKey->G
If Ans =/=0
Then
Output(Y,1,"_"
"Where _ is space
Y+(G=34)(Y=/=4)-(G=25)(Y=/=2)->Y
Output(Y,1,">
"Then for jumping to other code
If (G=105) and (Y=2)
Goto PO
" jump to potion code or code potions here
If (G=105) and (Y=3)
Goto AP
"apple code jump or here
"repeat for Feathers"
End
End
Try that, should work okay
Tell me if you have questions, or if it doesn't work ;D

That might work although I don't think that if you ran out of health potions they would  disappear , also you might want to use disp instead of output ; unless that is on purpose.
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 09:53:02 pm
also I don't have much experience with using getkey .............. hehehe like I said I'm kind of  a noob.
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 09:55:09 pm
You could use Disp for the first 4 Outputs, just be sure to put a space in front of the items. The final three must be Output commands
And no, the potions would not disappear if you had zero; you would have to check in the code to see if you had potions before you used them
For example,
Where I said If (G=105) and (Y=2)
You should change to If (G=105) and (Y=2) and (L1(1)>0)
This will check to see if there are any potions left, and will run the code following it only if all of the conditions are met
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 10:01:44 pm
so i am just wondering if the getkey stuff is necessary because wiht a normal menu you could just use the arrow keys numpad and enter button. Questions: does it specifically say how many potions there are on the menu and does every item availble in the game need to be already existing in the menu and if so will it show how many you have so( not yet fouund items will display a 0 next to the name)
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 10:03:19 pm
output allows you to display something at a certain point
for example:
:output(1,1,"hi"

will make it appear at point 1,1 on the screen, or the upper left corner!

AND DON'T DOUBLE POST!

and read this  http://www.ticalc.org/programming/columns/83plus-bas/cherny/
Yeah i looked there but It didn't help that much also another person said to double post so........
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 10:08:35 pm
output allows you to display something at a certain point
for example:
:output(1,1,"hi"

will make it appear at point 1,1 on the screen, or the upper left corner!

AND DON'T DOUBLE POST!

and read this  http://www.ticalc.org/programming/columns/83plus-bas/cherny/
Yeah i looked there but It didn't help that much also another person said to double post so........
Here are the official rules
Quote
4: The only time double-posting is allowed (posting two messages in a row in the same topic) is either if there has been 6 hours since your last post, 3 hours if your thread has been bumped out of the New Posts page, 1 hour if it's a project update or immediately if you need to upload more than 10 file attachments at once. Otherwise, update the last post using the "EDIT" button. It will be marked as unread for all members (altough it won't bump the thread).

EDIT:  Yes, if you want the numbers to be displayed, I suggest using all the getKey stuff.  It will look much nicer than the default menu, and is more customizable
And the zero is expected. With that code, it is what it is supposed to do
Title: Re: nooboish prgrammer
Post by: mrmprog on November 22, 2011, 10:08:56 pm
Err, You really shouldn't double post. And saintrunner, no need to "yell" at a newer member. When you joined, you were by no means perfect, but look at you now, a productive member of the community :)
Title: Re: nooboish prgrammer
Post by: saintrunner on November 22, 2011, 10:09:57 pm
Getkey's are easier (in my opinion) in axe. and the reason you need it in chatta's example is because he made it self modified. in other words, it looks the same as the menu( function but it is written out so it can be adjusted

And yeah your right, I don't meen to yell, I'm just bad at explaining, so I'm really yelling at myself... sorry :P
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 11:08:19 pm
quick question how do you alter a list so that its size can be increased and display the new item and not have to hav ea preset name for each slot.
Title: Re: nooboish prgrammer
Post by: jnesselr on November 22, 2011, 11:09:40 pm
I don't entirely understand the question, but you can write one past the length of the list in TI-BASIC, and it will add another element for you.  Does that help?
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 11:14:08 pm
If you want something like this:
(http://clrhome.tk/resources/homer/?t=Potions%3A9%0D%0A1%3AUse+potion%0D%0A2%3ABuy+potion%0D%0A4%3AOther+stuff%0D%0A5%3AExit)
Where it shows how many potions you have, tell me.
You can use a custom menu, or a manipulated OS one
yeah that actaully looks really good was the potions menu accessed through a menu that took it to its own specific menu and sorry if by menu I actually mean and/or list
If you want something like this:
(http://clrhome.tk/resources/homer/?t=Potions%3A9%0D%0A1%3AUse+potion%0D%0A2%3ABuy+potion%0D%0A4%3AOther+stuff%0D%0A5%3AExit)
Where it shows how many potions you have, tell me.
You can use a custom menu, or a manipulated OS one
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 11:14:54 pm
yeah that actaully looks really good was the potions menu accessed through a menu that took it to its own specific menu and sorry if by menu I actually mean and/or list
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 11:15:57 pm
It would be a lot harder than just having them preset, but something like
Code: [Select]
1->L
"L is length of list
1->length(L1
Then, code a menu like I showed, but include something like
Code: [Select]
If length(L1)=1
Output(2,2,"Potions
If length(L1)=2
Then
Output(2,2,"Potions
Output(3,2,"Apples
End
And instead of checking y against constants (Y+(G=34)(Y=/=4)), you should check against the length of the list
Make sure Y starts at 2 (2->Y)
Code: [Select]
Y-(G=25)(Y=/=2)+(G=34)(Y=/=(length(L1)+1)->YThe +1 on the length is due to Y starting at 2 instead of 1
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 11:19:32 pm
what I am saying is that I don't want to have It preset I just want it to increase and add size and objects to the list/menu
Title: Re: nooboish prgrammer
Post by: obon7 on November 22, 2011, 11:23:31 pm
I don't entirely understand the question, but you can write one past the length of the list in TI-BASIC, and it will add another element for you.  Does that help?
sorry I get that alot to clarify I want to make a menu/list that changes as you find, lose, or use items. Yeah it is pretty difficult in TI Basic
Title: Re: nooboish prgrammer
Post by: chattahippie on November 22, 2011, 11:26:56 pm
Yeah, that should work... as a new item is introduced to the game, just increase the size of length(L1) and make sure you have EVERY item built into the game so that when the length increases, it knows which item to add to the menu.
For instance, at the beginning, maybe the character can only use potions
Code: [Select]
1->length(L1
2->Y
0->G
Output(1,1,"Inventory
If length(L1)
Output(2,2,"Potions
If length(L1)>1
Output(3,2,"Apples
"Then the menu code I already posted, the basic menu one, just modified to use the Y+()()-()()->Y line I posted above
Then, to add apples to the menu, all you have to do is
Code: [Select]
2->length(L1or for all three items, store 3 to the length.

Then to remove items from the menu, if you had all three items, but didn't want feathers anymore, just use 2->length(L1) and the feathers are gone
Title: Re: nooboish prgrammer
Post by: obon7 on November 23, 2011, 06:06:05 pm
Yeah, that should work... as a new item is introduced to the game, just increase the size of length(L1) and make sure you have EVERY item built into the game so that when the length increases, it knows which item to add to the menu.
For instance, at the beginning, maybe the character can only use potions
Code: [Select]
1->length(L1
2->Y
0->G
Output(1,1,"Inventory
If length(L1)
Output(2,2,"Potions
If length(L1)>1
Output(3,2,"Apples
"Then the menu code I already posted, the basic menu one, just modified to use the Y+()()-()()->Y line I posted above
Then, to add apples to the menu, all you have to do is
Code: [Select]
2->length(L1or for all three items, store 3 to the length.

Then to remove items from the menu, if you had all three items, but didn't want feathers anymore, just use 2->length(L1) and the feathers are gone
So I kind of have some more questions, So in order to attain a certain item do you have to increase the length of the list to the exact size that that item is speicified to or will it automatically in the newly availble spot put the item there, also what is the command/operation to display a list.
Title: Re: nooboish prgrammer
Post by: aeTIos on November 23, 2011, 06:08:47 pm
To display a list, you have to write your own routine.
Title: Re: nooboish prgrammer
Post by: obon7 on November 23, 2011, 06:56:50 pm
To display a list, you have to write your own routine.
I dont understand
Title: Re: nooboish prgrammer
Post by: aeTIos on November 23, 2011, 07:01:34 pm
Okay, here is a sample routine (which is basically a program)
Code: [Select]
{1,2,1,1,2}->L1
for(A,1,length(L1)) ;;or any other list
If L1(A) = 1
Then
Output(A,0,"Blargh")
End
repeat for all other possible conditions
End
Does this make things more clear?
Also, have you already introduced yourself?

Title: Re: nooboish prgrammer
Post by: chattahippie on November 23, 2011, 07:31:32 pm
You have to have a predefined order of items that your list is arranged by (ex: Potions, then apples, then feathers for simplicities sake) then you change the length of the list to the exact new item, like I previously said.
And if you want to have Potions and feathers, but no apples, it would be much harder to code, and would probably be a lot slower
Good luck! :D
Title: Re: nooboish prgrammer
Post by: obon7 on November 23, 2011, 09:44:14 pm
oh well maybe if I  learn axe you guys could help me more
Title: Re: nooboish prgrammer
Post by: saintrunner on November 23, 2011, 09:46:35 pm
DO IT! Axe is faster anyways, so there is a lot more enjoyment! Easy to learn too! I learned it in like 2 days after I learned BASIC (and I barely understood BASIC!)
Title: Re: nooboish prgrammer
Post by: chattahippie on November 23, 2011, 10:04:54 pm
oh well maybe if I  learn axe you guys could help me more
I think that Basic is more suited for RPGs and games that need large amounts of easily accessible memory and variables, and not necessarily speed, but Axe is all about speed, good for arcade games and similar things.
Title: Re: nooboish prgrammer
Post by: saintrunner on November 23, 2011, 10:12:47 pm
I totally agree^^
Title: Re: nooboish prgrammer
Post by: obon7 on November 23, 2011, 10:47:02 pm
oh well maybe if I  learn axe you guys could help me more
I think that Basic is more suited for RPGs and games that need large amounts of easily accessible memory and variables, and not necessarily speed, but Axe is all about speed, good for arcade games and similar things.
IDK I just read the manual/tutorial for axe and alot of the questions I have were answered so now all I need to do is put it on my calculator and I shouldn't have to bother you guys any more, one last thing how do you put axe on a calculator
Title: Re: nooboish prgrammer
Post by: saintrunner on November 23, 2011, 10:48:41 pm
http://www.ticalc.org/archives/files/fileinfo/428/42813.html

download it then upload it through ticonnect
Title: Re: nooboish prgrammer
Post by: aeTIos on November 23, 2011, 10:58:53 pm
You should actually use TiLP since it's better than Ticonnect.
Title: Re: nooboish prgrammer
Post by: saintrunner on November 24, 2011, 01:50:38 pm
It actually is....But Ticonnect (i think) is easier to understand, atleast for me. just use what your most comfortable! :)
Title: Re: nooboish prgrammer
Post by: obon7 on November 24, 2011, 02:12:54 pm
thx guys Ill start posting the updates t my game in the projects forum if anyone wnats to help I have some coding things you guys could do for me.
Title: Re: nooboish prgrammer
Post by: saintrunner on November 24, 2011, 02:14:17 pm
sure thing! (be careful how many people you let help though, lol, you'll be spending more time in the credits then the actual code! :) )