forums

TNT Basic Forums > Programming Q&A
Strings, variables
< Last Thread     Next Thread >
Author
Thread        Post A Reply

06-30-2008 15:39

Posted by:
Gandolf

Find more posts by Gandolf

Hey, I'm new to tnt, and starting to get used to it, but I ran into a problem.

How do you put a string variable and a int variable together?

Like "String rotate=rotate+int rotation"


Also, If you Draw Text 100,100,STR(rotate), how do you get that text to delete and rewrite in the same spot?


-Gandolf

06-30-2008 20:48

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

if i remember correctly, you can use 'as string'

e.g.
int mynumber = 5
string mystring = "lives: "
string s = mystring + as string(mynumber)

To erase the previous text, just draw over it (depending on what is behind... e.g. redraw the background)

07-01-2008 04:03

Posted by:
Gandolf

Find more posts by Gandolf

Wait, what do you mean by:

To erase the previous text, just draw over it (depending on what is behind... e.g. redraw the background)

When I Also, If you Draw Text 100,100,"Hello". How do you get rid of it?


-Gandolf

07-01-2008 05:00

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

Hi G.

Let's assume I have a Black Canvas and I want to draw some white text and erase it. Here is what I do:

Set pen colour white===== sets the pen for 'Hello' to white

Draw text 100,100,"Hello"====== draws the text in white


======= now to 'erase' the word 'Hello'

Set pen colour Black

Draw text 100,100,"Hello"====== draws the text in Black

or

Paint Canvas======erases the whole canvas to black

make sense now?


cheers

barry


07-01-2008 15:09

Posted by:
Gandolf

Find more posts by Gandolf

Ah, Thanks. I understand now.


But, I have another question. Does Tnt have a Nthfield command? Or possible a list of all the string commands?


-Gandolf

07-02-2008 00:17

Posted by:
Gandolf

Find more posts by Gandolf

You guys do know what Nthfield is?

If you don't, here is an example:

NTHFIELD$(source, separator, fieldNumber)
Returns the field value from the source that precedes the fieldNumber occurrence of the separator in the source.


Ex:
string var="cow;moose;chicken"
print NTHFIELD$(var, ";", 2)


And it will print moose.


-Gandolf

07-02-2008 09:51

Posted by:
HarryCaray

Location:
Orlando, Fl

Find more posts by HarryCaray

That command was basically for "fake" arrays in SC, but TNT actually has arrays so a command like that really isn't needed.

str array[3]
array[0]="cow"
array[1]="moose"
array[2]="chicken"
print array[1]

07-02-2008 13:08

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

But if you want the exact thing you described, gandalf, unfortunately you're gonna have to do it yourself with a for loop and Get Char function.

TNTbasic has too few string commands.:/

07-02-2008 13:43

Posted by:
Gandolf

Find more posts by Gandolf

Thanks, now I can make that v6 tiles system, unless...

Has anyone made a good rpg tile system in tnt? One that is simple, has blocks, portals, and is easy to install?


-Gandolf

07-02-2008 14:11

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

swagIt made one i think ;)

07-02-2008 14:16

Posted by:
Gandolf

Find more posts by Gandolf

Thanks, I will look for it, unless swat would like to post it.


-Gandolf

07-02-2008 14:33

Posted by:
Gandolf

Find more posts by Gandolf

Sorry, swagIt*. This forum doesn't have a edit command. :P


-Gandolf

07-02-2008 17:31

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

Ha Ha - I've been called waaaay worse!

Here is the a link to the rpg game I made:

http://www.macupdate.com/info.php/id/25212/dinky-dungeon

07-02-2008 17:43

Posted by:
Gandolf

Find more posts by Gandolf

Wow! 21,000 downloads!

I'm downloading it right now.

So, do you give each tile a number in a array. Like if tile 1 of coulomb 1 is 1 then it is a block or if it is a zero, it is a empty?

Just wondering about the tile system.



-Gandolf

07-02-2008 18:01

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

TNT has a feature to 'get' the id of a tile so basically when I built the map I made all my 'passable' tiles 1 to 20 and the non-passable stuff 21-40.
The doors I treated differently. I had a tile for 'closed' doors and one for 'open' doors. When a character bumps a 'closed' door and opens it I get TNT to swap the closed door tile with the open door tile.

You can ask what tile your sprite is about to collide/overlap with and determine actions from there. One nice thing about TNT is the built-in map editor.

cheers

barry

07-02-2008 18:37

Posted by:
Gandolf

Find more posts by Gandolf

Thanks. I will have to check the map editor out.

I'm used to making the whole tile system from scratch.
So, this will be a great improvment. :)


Thanks,
-Gandolf

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.