Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (Grant, TipmyPip, AndrewAMD), 12,724 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
var = var - problem #205792
05/08/08 21:11
05/08/08 21:11
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline OP
Senior Member
kasimir  Offline OP
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
Hello,
i try to lern lite_c, but i got a strange problem:
 Code:
function save_nodes()
{
	var i;
	var j;
	var k;

	var num_nodes;

	//get node positions
	while(i < 50)
	{
		you = ptr_for_handle(nodes[i]);
		if(you)
		{
			node_pos[j][0] = you.x;
			node_pos[j][1] = you.y;
			node_pos[j][2] = you.z;
			j += 1;
		}
		i += 1;
	}

	num_nodes = j;

"j" works fine - it saves the right value
but if i use "num_nodes = j;" num_nodes is something like 52228.000 (but not the j value)
is this a pointer problem?

Thx kasimir

Re: var = var - problem [Re: kasimir] #205833
05/09/08 00:34
05/09/08 00:34
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Try initialising the variables to 0 first. Probably not the fault but other things can go wrong now.

var i = 0;
var j = 0;
var k = 0;

var num_nodes = 0;

How did you check the value num_nodes? If you used printf("%i", num_nodes); then indeed you got an odd number. printf("%i", (int)num_nodes); should solve that.


Click and join the 3dgs irc community!
Room: #3dgs
Re: var = var - problem [Re: Joozey] #205851
05/09/08 06:26
05/09/08 06:26
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline OP
Senior Member
kasimir  Offline OP
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
thx if i just set "j" to zero it works fine!!!
i wrote a text-file... (file_var_write)

Re: var = var - problem [Re: kasimir] #205881
05/09/08 10:50
05/09/08 10:50
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I suggest try printf or draw_text (in a loop!) next time instead of file_var_write :P it's a nicer way to debug.

The reason why it does work fine now is because j was uninitialised, and never gets assigned a real value. However, you do raise this value by 1. Probably now it added one to the pointer value.

Last edited by Joozey; 05/09/08 10:51.

Click and join the 3dgs irc community!
Room: #3dgs
Re: var = var - problem [Re: Joozey] #205888
05/09/08 12:11
05/09/08 12:11
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline OP
Senior Member
kasimir  Offline OP
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
yes thanks, but i did include file_var_write before so it was just simply to use.

Re: var = var - problem [Re: kasimir] #205905
05/09/08 14:03
05/09/08 14:03
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Ait well do as you please \:D


Click and join the 3dgs irc community!
Room: #3dgs

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1