Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with "magnetfield-code" #347974
11/21/10 15:31
11/21/10 15:31
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
I`m working on a little "Magnet-Game". So I was trying out the Code from AUM74. It works fine except one error message.
Every time my player detected a magnet-entity the message
" invalid call in event got_scanned" appears.

Okay, then I was debbuging my Code. The error comes always after this line:
Code:
c_move (my, vector(6 * time_step, 6 * time_step, 6 * time_step), nullvector, GLIDE);


But why? And if i klick ok, the error-message disappears and i can play(the magnets working good). But why this message if it works fine after that??

Here the "magnet-code":

Code:
action player_move()
{ 
...//movement code

c_scan(my.x, my.pan, vector(360, 180, 200), IGNORE_ME); 
}

function got_scanned()

{

       my.event = NULL; // the entities will follow the magnet from now on

       VECTOR temp_pos;

       while (1)

       {

               if (vec_dist (player.x, my.x) > 100) // the object isn't close enough to the magnet?
               {

                       vec_set(temp_pos, player.x);

                       vec_sub(temp_pos, my.x);

                       vec_to_angle(my.pan, temp_pos);

                     

                       // the entity is oriented towards the magnet here

                       c_move (my, vector(6 * time_step, 6 * time_step, 6 * time_step), nullvector, GLIDE);   //AFTER THAT THE ERROR APPEARS     
               }

               wait (1);

       }

}

 

// the entities that have this action attached to them are sensitive to the magnet entity

action sensitive_ents()

{

       my.emask |= ENABLE_SCAN; // make this entity sensitive to scanning

       my.event = got_scanned;

}



thx for help!


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: problem with "magnetfield-code" [Re: Vyshess] #347988
11/21/10 16:45
11/21/10 16:45
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Insert "while(!player){wait(1);}" in the beginning of the action sensitive_ents to assure that the pointer "player" is already valid.

Re: problem with "magnetfield-code" [Re: Pappenheimer] #348027
11/21/10 22:15
11/21/10 22:15
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
nope, that doesn`t works. the error appears again...


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: problem with "magnetfield-code" [Re: Vyshess] #348047
11/22/10 07:30
11/22/10 07:30
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
This works great (TESTED):
Code:
function main()
{
	fps_max = 75;
	level_load("1.WMB");
	wait(3);
}

function got_scanned()
{
	my.event = NULL; // the entities will follow the magnet from now on
	VECTOR temp_pos;
	wait(1);
	while (1)
	{
		if (vec_dist (player.x, my.x) > 50) // the object isn't close enough to the magnet?
		{
			vec_set(temp_pos, player.x);
			vec_sub(temp_pos, my.x);
			vec_to_angle(my.pan, temp_pos);
			my.tilt = 0;
			// the entity is oriented towards the magnet here
			c_move (my, vector(3 * time_step, 0, 0), nullvector, GLIDE);        
		}
		wait (1);
	}
}

// the entities that have this action attached to them are sensitive to the magnet entity
action sensitive_ents()
{
	my.emask |= ENABLE_SCAN; // make this entity sensitive to scanning
	my.event = got_scanned;
}

action my_magnet() // attach this action to your entity
{
	player = my; // I'm the player
	while (1)
	{
		// move the player using the cursor keys
		c_move (my, vector(10 * (key_cuu - key_cud) * time_step, 6 * (key_cul - key_cur) * time_step, 0), nullvector, GLIDE);
		vec_set (camera.x, player.x); // use player's x and y for the camera as well
		camera.z += 500; // place the camera 500 quants above the player on the z axis
		camera.tilt = -90;
		// make the magnet active on a radius of up to 200 quants around it 
		c_scan(my.x, my.pan, vector(360, 180, 200), IGNORE_ME);                
		wait (1);
	}
}

And make sure that in WED player was created first! If you'll need I can upload the demo. Good luck.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: problem with "magnetfield-code" [Re: 3run] #348118
11/22/10 19:53
11/22/10 19:53
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
Thanks 3run (maybe you saved my day)!!
yeah, your code works good, but is it possible to make the player moving to the magnet-entity and not the magnet-Entity to the player??

I was given the Magnet-Entity the scan part, and the player got the event "got_scanned()".

I have problems with this part:

Code:
if (vec_dist (player.x, my.x) > 50) // the object isn't close enough to the magnet?
		{
			vec_set(temp_pos, player.x);
			vec_sub(temp_pos, my.x);
			vec_to_angle(my.pan, temp_pos);
			my.tilt = 0;
			// the entity is oriented towards the magnet here
			c_move (my, vector(3 * time_step, 0, 0), nullvector, GLIDE);        
		}



I know that i have to replace "player.x", but what can i use? i think "you.x" will create a crash. Maybe a pointer for the magnet-Entity?? But then i can only use one magnet in a level, can`t I ?


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: problem with "magnetfield-code" [Re: Vyshess] #348135
11/22/10 22:48
11/22/10 22:48
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I think it will be triky to make that. If two magnets will be on the same distance from the player and if they were be detected by him, what will he make then? I guess he will walk to the last one (which was created last). But try to play with it yourself, with YOU pointer and so on.
Any way, I'm too tired and sleepy today to think about this all. We'll see tomorrow.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: problem with "magnetfield-code" [Re: 3run] #348268
11/24/10 17:09
11/24/10 17:09
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
I got it!! It wasn`t so triky^^

Thanks for your Help!


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: problem with "magnetfield-code" [Re: Vyshess] #348277
11/24/10 18:17
11/24/10 18:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I'm happy to see that you've got it yourself laugh
Could you show as what you've done? laugh
And is there any way to show how it works? laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

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

Gamestudio download | chip programmers | 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