Posted: Wed Sep 12, 2007 7:06 pm Post subject: Need some help with basic coding
Hello, I am new to Compsci and new to Turing. I am in grade 10 and taking a course that is using turing.
Now I wanted to make a calculator and I was wondering how i can "call" on something for instance
I am finding it hard to explain.
Lets say someone enters in their level is 1. I want that levels amount to be subtracted from the total level and make it the "amountleft" variable.
The reason im having trouble is I want to do this on a large scale, (99 levels or so)
code:
var lvl1, lvl2, lvl3, lvl4 : int
var level : int
var total : int
var amountleft : int
I am having trouble explaining this. So if anyone is willing to help me, I can PM them the real code and see if you can help. The only reason why I didnt want to post it is because its quite long.
Heres my contact info if you can help
Clayton has done something useful, and wrote up some good material on Arrays. You should probably limit yourself just to the first part of that tutorial for now.
Posted: Wed Sep 12, 2007 7:58 pm Post subject: RE:Need some help with basic coding
I am confused.
Ok so I have the array. I still dont understand how to "connect" it to the levels
lets say someone enters level 2
then i want it to subtract
(amount of the level - total)
I read the tutorial, I just am not sure how or if it applies to what im trying to get at >_<
Clayton
Posted: Wed Sep 12, 2007 8:00 pm Post subject: RE:Need some help with basic coding
Alright, fair enough. Thanks
CodeMonkey2000
Posted: Wed Sep 12, 2007 8:09 pm Post subject: RE:Need some help with basic coding
Have an array of lvls, take the level that the user inputs and access that level with: lvl(level)
Sponsor Sponsor
aspire
Posted: Wed Sep 12, 2007 8:18 pm Post subject: RE:Need some help with basic coding
Alright. Well I am really lost. So I will just post the whole thing. I am making it for a game my brother plays. Just thought it would be some good experience to practice with turing
So lets say if someone enters 80 i want it to subtract "level 80's" amount from the total amount.
Here is the stuff I currently have.
code:
var array_1 : array 1..99 of int
var fletching : int
var levelsleft : int
var expleft: int
var alevel : int
var totalexp : int
var lvl1, lvl2 ,lvl3 ,lvl4 ,lvl5 ,lvl6 ,lvl7 ,lvl8 ,lvl9 ,lvl10 ,lvl11 ,lvl12 ,lvl13, lvl14 ,lvl15 ,lvl16
,lvl17 ,lvl18 ,lvl19 ,lvl20 ,lvl21 ,lvl22 ,lvl23 ,lvl24 ,lvl25 ,lvl26 ,lvl27 ,lvl28 ,lvl29 ,lvl30 ,lvl31
,lvl32 ,lvl33 ,lvl34 ,lvl35 ,lvl36 ,lvl37 ,lvl38 ,lvl39 ,lvl40 ,lvl41 ,lvl42 ,lvl43 ,lvl44 ,lvl45 ,lvl46
,lvl47 ,lvl48 ,lvl49 ,lvl50 ,lvl51 ,lvl52 ,lvl53 ,lvl54 ,lvl55 ,lvl56 ,lvl57 ,lvl58 ,lvl59 ,lvl60 ,lvl61
,lvl62 ,lvl63 ,lvl64 ,lvl65 ,lvl66 ,lvl67 ,lvl68 ,lvl69 ,lvl70 ,lvl71 ,lvl72 ,lvl73 ,lvl74 ,lvl75 ,lvl76
,lvl77 ,lvl78 ,lvl79 ,lvl80 ,lvl81 ,lvl82 ,lvl83 ,lvl84 ,lvl85 ,lvl86 ,lvl87 ,lvl88 ,lvl89 ,lvl90 ,lvl91
,lvl92 ,lvl93 ,lvl94 ,lvl95 ,lvl96 ,lvl97 ,lvl98 ,lvl99 : int
Posted: Thu Sep 13, 2007 6:31 am Post subject: RE:Need some help with basic coding
ahaha i recognise that code anywheere thats a runescape level calculator (dont worry ppl i quit a while ago just have friends who still play... and a cousin) anyways it doesnt quite seem like u got arrays down yet... instead of making 99 diffrent varibles for each level just make a
Turing:
var lvl:array1..99ofint
then to set them just put
Turing:
lvl(1):=0
lvl(2):=86
etc...
HeavenAgain
Posted: Thu Sep 13, 2007 11:19 am Post subject: RE:Need some help with basic coding
normally for assigning array variables, we like to use a loop, instead of typing all the array's name again
bad example would be, in this case:
lvl (1) := 0
lvl (2) := 86.... etc
if thats the case, then whats the point of using an array, it will be just the same to type up all the var lvl_1 blah blah blah.
so try to find the increasing value, and do it in one small loop (unless its too complicated...)
CodeMonkey2000
Posted: Thu Sep 13, 2007 11:58 am Post subject: RE:Need some help with basic coding
0_o
aspire, seriously re-read Clayton's array tutorial and LEARN from it.
aspire
Posted: Thu Sep 13, 2007 12:53 pm Post subject: RE:Need some help with basic coding
Uh, codemonkey. I did read it. I was half alseep though last night, so I think i probably didnt totally let the info seep in. I have only been doing turing for about 1 week in school, so yeah I admit it, I am slow.
I didnt want to agitate you or anything. But really, thanks for the current help everyone has given
Well, I was messing around with it at school. I didnt get very far but I did set the arrays properly, (I think)
Teacher told me I cant subtract arrays. I will be reading that tutorial over a few times when I get home too so, please bear with me.
code:
var lvl : array 1 .. 99 of int
var fun : int
var levelsleft : int
var expleft : int
var alevel : int
var TEXP : int