AnthonyJean 2020-04-12 04:11
I’m getting a too many tokens error. Anyone help with this? Thanks...
was8bit 2020-04-12 05:13
You need to economize your code... you do not have unlimited size to work with....
was8bit 2020-04-12 05:16
IF MG=1 THEN MONN$="BLACK ORC"
IF MG=2 THEN MONN$="HOBGOBLIN"
IF MG=3 THEN MONN$="GIANT WASP"
IF MG=4 THEN MONN$="BLOODY TOAD"
IF MG=5 THEN MONN$="POISON OOZE"
IF MG=6 THEN MONN$="GREY SNAKE"
IF MG=7 THEN MONN$="TIMBERWOLF"
IF MG=8 THEN MONN$="GIANT RAT"
IF MG=9 THEN MONN$="RED GOBLIN"
IF MG=10 THEN MONN$="GREEN SLIME"
IF MG=11 THEN MONN$="BLUE SLIME"
IF MG=12 THEN MONN$="PIT VIPER"
IF MG=13 THEN MONN$="GIANT ROACH"
IF MG=14 THEN MONN$="WHITE WIZARD"
IF MG=15 THEN MONN$="RABID DOG"
IF MG=16 THEN MONN$="WILD BOAR"
IF MG=17 THEN MONN$="HUNGRY LION"
IF MG=18 THEN MONN$="ZOMBIE QUEEN"
IF MG=19 THEN MONN$="DEMON HOUND"
IF MG=20 THEN MONN$="EVIL WYVERN"
IF MG=21 THEN MONN$="SNEAK THIEF"
IF MG=22 THEN MONN$="ICE GIANT"
IF MG=23 THEN MONN$="VIKING LORD"
IF MG=24 THEN MONN$="EVIL SPIRIT"
IF MG=25 THEN MONN$="DEMON SPAWN"
IF MG=26 THEN MONN$="RING WRAITH"
IF MG=27 THEN MONN$="MINOTAUR"
IF MG=28 THEN MONN$="GOLD DRAGON"
IF MG=29 THEN MONN$="DARK ELF"
IF MG=30 THEN MONN$="RED HELLBAT"
IF MG=31 THEN MONN$="ANGRY TROLL"
IF MG=32 THEN MONN$="ANGRY DWARF"
IF MG=33 THEN MONN$="WOOD TROLL"
IF MG=34 THEN MONN$="DARK WIZARD"
IF MG=35 THEN MONN$="WOOD ELF"
IF MG=36 THEN MONN$="DOPPLEGANGER"
IF MG=37 THEN MONN$="DARK ANGEL"
Could be simplified with
FOR I=1 TO 37
DATA "BLACK ORC","HOBGOBLIN"
DATA "DOPPLEGANGER","DARK ANGLE"
Then simply use MONN$=MONSTER$(MG)
was8bit 2020-04-12 05:19
IF OI$="Y"THEN SOUNDPLAY=1
IF OI$="Y"THEN SOUND SOURCE ROM(15)
IF OI$="Y"THEN MUSIC 8
IF OI$="Y"THEN SOUND SOURCE ROM(14)
IF OI$="Y"THEN GOTO HARDWAREGO
Can be simplified with
IF OI$="Y" THEN
SOUND SOURCE ROM(15)
SOUND SOURCE ROM(14)
was8bit 2020-04-12 05:23
PRINT " YOU HIT THE"
PRINT " ";MONN$
Can be simplified with
TEXT 4,2,"YOU HIT THE"
was8bit 2020-04-12 05:27 (Edited)
You need to STANDARDIZE things like
PRINT " ACTIONS:"
PRINT " (L)OOK (T)ALK"
PRINT " (U)SE (R)EAD"
PRINT " (N)ORTH (W)EST"
PRINT " (I)NVENTORY"
PRINT " (Q)UIT"
Make them more standardized, and use SUB so you can reuse the commands...this would eliminate a ton of repeated code...
was8bit 2020-04-12 05:45
You also could use an array like
And maybe use a coded system that defines each room.. as
Which means can go North,South,East,West,Up,Down, Monster, Item
Would mean, can go north or south, has monster 12 and item 6
was8bit 2020-04-12 05:46
Coded arrays would remove all the code typed in for EACH room, and would rather use a loop that handled ANY room based on the room settings...
was8bit 2020-04-12 05:50
Alternatively, if you prefer your style of coding, you will need to break down your game into smaller "chapters" and restrict each chapter to fit lowres without getting the token error...
You can use in-game passwords to restrict players from playing one chapter until they complete the previous chapter :)
Timo 2020-04-12 13:57
Yes, a NX program is limited to 16384 tokens. A token is something like a word in a program. For example the line...
PRINT "NEXT LEVEL:",LEVEL+1
...are 6 tokens:
- keyword PRINT
- string "NEXT LEVEL"
- the variable LEVEL
- the + sign
- the number 1
The app should show the numbers of tokens of a program, but this is still missing, sorry.
AnthonyJean 2020-05-13 20:57
Derp! Sometimes my brain doesn’t see the nose in front of my face! Thanks for the gentle reminder to code properly. I didn’t even stop to think of obvious things like dimensional arrays and data statements. Please slap me in the future.
Thanks for the help!
was8bit 2020-05-14 02:32
AnthonyJean 2020-05-17 01:19
Gave it a rewrite. Looking for more suggestions to improve code. A lot smaller now.
was8bit 2020-05-17 04:50
... will give it a look over later, as i am over my head in work now :/
was8bit 2020-05-22 11:50
Ok, one thought...
Where you use ...
IF GOEAST$="Y" THEN GOTO ROOM14
IF GOWEST$="Y" THEN GOTO ROOM17
IF GOSOUTH$="Y" THEN GOTO ROOM16
IF KP$="I" OR KP$="H" THEN GOTO ROOM15
Really should figure out a system for using arrays.. so lets say your map is size 9x9, then
Would let you put up to 9 things in a room...
If item2 is a key, then you just put a key in there...
When player goes to,room 14 and picks up the key, then use
To remove the key
With carefull planning you should use 1 main DO LOOP, AND USE INDEXES TO HELP NAVIGATE..
References room 14 ... so maybe
Use arrays to build,text like
For I=1 to 9
If ITEMS(RX,RY,I)=2 then print "A key"
IF GOEAST$="Y" THEN
... This is really something you would want to start fresh, keeping this version as a reference, and just copy your image data ... would require careful planning and such but would WAY reduce tokens, and allow more flexibility and expansion :)
AnthonyJean 2020-05-30 02:09
Great advice! Thanks!
was8bit 2020-05-30 05:07 (Edited)
Glad to be helpful :)
Deciding how to organize your code can be the hardest part of programming, there is always more than one way to get the results you want...
Sometimes i will look at something i wrote awhile ago, and cannot immediately figure out what i was doing... and unless i really want it (like to remix it or borrow something from it) i just leave it alone... sometimes i come up with really creative code ;)