Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by AndrewAMD. 12/05/23 10:56
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 622 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple door interaction problems #218007
07/25/08 20:37
07/25/08 20:37
Joined: Jul 2008
Posts: 3
K
kaasjongen Offline OP
Guest
kaasjongen  Offline OP
Guest
K

Joined: Jul 2008
Posts: 3
Hello,

I've wrote a simple script for a rotating door as the template script door01.wdl doesn't seem to work.

the door rotates fine but a as soon as I want to add interaction using c_scan function troubles arise. I've tried nearly everything and read every single post on doors on these forums and
did dozens of tutorials on it but they all won't work.

So now I've got this totaly stripped down script just to spot errors but after days of puzzling I'm quite stuck.

Code:
function operate() // scan nearby doors or switches for operating them
{
   c_scan(camera.x,camera.pan,vector(800,800,1500),SCAN_ENTS);
}

function scan_event() 
{
if (event_type == EVENT_SCAN) 
  {
	my.skill3 = 1;  // sets door movement flag to the move state
  }
}

action rotating_door() // action for rotating door
{

    my.emask |= ENABLE_SCAN; 
    my.ENABLE_SCAN = ON; 
    my.event = scan_event;
	
	while(my.skill3==1) {
  		my.pan+=3;
  		wait(1);
	}
}


in the main function I placed :

Code:
on_ctrl = operate;


According to all I've read this should work...but it doesn't.

when I include the line :
my.emask |= ENABLE_SCAN;
it errors :

"parameter unknown emask parameter"

when I delete the line I can press the crtl key like crazy but nothing happens.
Can anyone help me out with this becoming frustrating battle for a simple door ?

Thanks in advance.

Last edited by kaasjongen; 07/25/08 21:05.
Re: Simple door interaction problems [Re: kaasjongen] #218193
07/27/08 02:20
07/27/08 02:20
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
The reason you are getting this error is because you are mixing both scripting languages together > c-script and lite-c.

my.emask |= ENABLE_SCAN; is lite-c
my.ENABLE_SCAN = ON; is c-script

You should decided which language you are going to write the game in as they cannot be used together (normally). I advise lite-c, its has more features than c-script.

Then do the workshops from the downloads page. Make sure you save your script file as .c if you are using lite-c and .wdl if you are using c-script.

Here is a go at converting your code. NOTE : i haven't tested this...

C-script>
Code:


function operate() // scan nearby doors or switches for operating them
{
   c_scan(camera.x,camera.pan,vector(800,800,1500),SCAN_ENTS);
}

function scan_event() 
{
if (event_type == EVENT_SCAN) 
  {
	my.skill3 = 1;  // sets door movement flag to the move state
	return;
  }
}

action rotating_door() // action for rotating door
{

    my.ENABLE_SCAN = ON; 
    my.event = scan_event;
	
	while(my.skill3==1) {
  		my.pan+=3;
  		wait(1);
	}
}

function main()
{
	on_ctrl=operate;
	
}

Lite-C>

Code:

#include <acknex.h>
#include <default.c>

function operate() // scan nearby doors or switches for operating them
{
   c_scan(camera.x,camera.pan,vector(800,800,1500),SCAN_ENTS);
}

function scan_event() 
{
if (event_type == EVENT_SCAN) 
  {
	my.skill3 = 1;  // sets door movement flag to the move state
	return;
  }
}

action rotating_door() // action for rotating door
{

    my.emask |= ENABLE_SCAN; 
    my.event = scan_event;
	
	while(my.skill3==1) {
  		my.pan+=3;
  		wait(1);
	}
}

function main()
{
	on_ctrl=operate;
	
}


That should work, but the most important thing is that you decide upon which language to use and stick to it.

Last edited by DJBMASTER; 07/27/08 02:20.
Re: Simple door interaction problems [Re: DJBMASTER] #218262
07/27/08 14:17
07/27/08 14:17
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
there is a huge problem in this whole thing, and that is this part:

Code:
my.emask |= ENABLE_SCAN; 
    my.event = scan_event;
	
	while(my.skill3==1) {
  		my.pan+=3;
  		wait(1);
	}


the engine is not going to wait until skill3 is 1, the engine sets the events for the door, then IMMEDIATELY checks if skill3 equals 1 and as it doesn't, it skips the while-loop and ends the action. What you need to do, is to do another kind of loop, or a second loop that sets the action to a wait state as long as skill3 is not 1:

Different loop example:
Code:
my.emask |= ENABLE_SCAN; 
my.event = scan_event;
	
while(me)
{
   if(my.skill3==1)
   {
      my.pan+=3;
   }
   wait(1);
}


or the (worse) alternative, the complimentary loop:
Code:
my.emask |= ENABLE_SCAN; 
my.event = scan_event;

while(my.skill3 != 1){ wait(1); }

while(my.skill3==1) 
{
   my.pan+=3;
   wait(1);
}


hope I could help


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku

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