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
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 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
Page 1 of 3 1 2 3
C-Script problem... #167829
11/16/07 22:16
11/16/07 22:16
Joined: Nov 2007
Posts: 18
J
JimmyJazz Offline OP
Newbie
JimmyJazz  Offline OP
Newbie
J

Joined: Nov 2007
Posts: 18
Hi all,

Just started with GStudio and I'm trying to code some basic movement / environment manipulation scripts. I know there are templates for this sort of thing but it's helping me learn the basics. Anyway, I've a door entity that is rotated using a EVENT_CLICK and the script works just fine - that is, unless it's used in conjunction with my player movement script!

The problem seems to be that the movement script takes exclusive control of any mouse / keyboard input and mouse clicks just don't seem to register at all.

Any help would be appreciated! Thanks in advance, Jim.

** DOOR SCRIPT **

// DoorFunctions.wdl

function manipulateDoor() {

if(event_type == EVENT_CLICK) {

my.pan += 45;
}
}

action doorControls {

my.ENABLE_CLICK = ON;
my.event = manipulateDoor;
}

** PLAYER CONTROL SCRIPTS **
// PlayerControls.wdl

// ** Global variables
var moveVector[3] = 0, 0, 0;

action playerControl {

player = me;

wait(1);

// ** Loop while player exists - check for keyboard / mouse input
while(player != null) {

// *************************************
// ** Control and update player movement

moveVector[0] = ((key_w - key_s) * 4 * time); // ** Sets "reldist" vector that sets the
// ** "direction" of the player's forward
// ** / reverse movement

moveVector[1] = ((key_a - key_d) * 2 * time); // ** Sets "reldist" vector that sets the
// ** "direction" of the players strafing
// ** movement

player.pan -= (mouse_force.x * 8 * time); // ** Pans the camera - controls x-rotation

// ** Tilts the camera while restricting the amount of tilt to + / - 75 degrees
var newTilt = 0;
var tempTilt = 0;
tempTilt = (mouse_force.y * 8 * time);

if((camera.tilt + tempTilt) > 75) {

newTilt = 75;

} else {

if((camera.tilt + tempTilt) < -75) {

newTilt = -75;

} else {

newTilt = (camera.tilt + tempTilt);
}
}

ent_move(moveVector, NULLVECTOR); // ** Moves the player

vec_set(camera.x, player.x); // ** Moves the camera
camera.pan = player.pan; // ** Rotates the camera
camera.tilt = newTilt; // ** Tilts the camera


if(key_space == 1) {

c_scan(camera.x, camera.pan, vector(10, 10, 200), SCAN_ENTS);
}

if(mouse_left == 1) {


}

wait(1);
}
}

Re: C-Script problem... [Re: JimmyJazz] #167830
11/16/07 22:39
11/16/07 22:39
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline
User
JazzDude  Offline
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Hey, Jim...

It would be easier to analyze your code if you would use the UBB CODE brackets when posting.

Re: C-Script problem... [Re: JimmyJazz] #167831
11/16/07 23:32
11/16/07 23:32
Joined: Nov 2007
Posts: 18
J
JimmyJazz Offline OP
Newbie
JimmyJazz  Offline OP
Newbie
J

Joined: Nov 2007
Posts: 18
Code:

// PlayerControls.wdl

// ** Global variables
var moveVector[3] = 0, 0, 0;

action playerControl {

player = me;

wait(1);

// ** Loop while player exists - check for keyboard / mouse input
while(player != null) {

// *************************************
// ** Control and update player movement

moveVector[0] = ((key_w - key_s) * 12 * time); // ** Sets "reldist" vector that sets the
// ** "direction" of the player's forward
// ** / reverse movement

moveVector[1] = ((key_a - key_d) * 6 * time); // ** Sets "reldist" vector that sets the
// ** "direction" of the players strafing
// ** movement

player.pan -= (mouse_force.x * 24 * time); // ** Pans the camera - controls x-rotation

// ** Tilts the camera while restricting the amount of tilt to + / - 75 degrees
var newTilt = 0;
var tempTilt = 0;
tempTilt = (mouse_force.y * 8 * time);

if((camera.tilt + tempTilt) > 75) {

newTilt = 75;

} else {

if((camera.tilt + tempTilt) < -75) {

newTilt = -75;

} else {

newTilt = (camera.tilt + tempTilt);
}
}

ent_move(moveVector, NULLVECTOR); // ** Moves the player

camera.x = player.x;
camera.y = player.y; // ** Moves the camera in relation to player
camera.z = (player.z + 125);
camera.pan = player.pan; // ** Rotates the camera
camera.tilt = newTilt; // ** Tilts the camera


if(mouse_left == 1) {

c_scan(camera.x, camera.pan, vector(15, 15, 1500), SCAN_ENTS);
}

wait(1);
}
}



Code:


// DoorFunctions.wdl


function manipulateDoor() {

if(event_type == EVENT_CLICK) {

my.pan += 45;
}
}

action doorControls {

my.ENABLE_CLICK = ON;
my.event = manipulateDoor;
}



Last edited by JimmyJazz; 11/16/07 23:34.
Re: C-Script problem... [Re: JimmyJazz] #167832
11/16/07 23:36
11/16/07 23:36
Joined: Nov 2007
Posts: 18
J
JimmyJazz Offline OP
Newbie
JimmyJazz  Offline OP
Newbie
J

Joined: Nov 2007
Posts: 18
Didn't know you could do that!

Hope this helps...

Cheers - Jim.

Re: C-Script problem... [Re: JimmyJazz] #167833
11/16/07 23:38
11/16/07 23:38
Joined: Nov 2007
Posts: 18
J
JimmyJazz Offline OP
Newbie
JimmyJazz  Offline OP
Newbie
J

Joined: Nov 2007
Posts: 18
P.S. Ignore the c_scan section triggered by the left mouse click - that was included after I encountered the problem as part of a workaround. Even without it the problem persists...

Cheers - Jim.

Re: C-Script problem... [Re: JimmyJazz] #167834
11/17/07 00:09
11/17/07 00:09
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
it could be mouse_mode ore mouse_range


"empty"
Re: C-Script problem... [Re: flits] #167835
11/17/07 00:20
11/17/07 00:20
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Yeah I think it's the mouse_range as well, couldn't find any other explanation, and the player input wont suck the input for other entities away

Last edited by Joozey; 11/17/07 00:26.

Click and join the 3dgs irc community!
Room: #3dgs
Re: C-Script problem... [Re: Joozey] #167836
11/17/07 10:02
11/17/07 10:02
Joined: Nov 2007
Posts: 18
J
JimmyJazz Offline OP
Newbie
JimmyJazz  Offline OP
Newbie
J

Joined: Nov 2007
Posts: 18
I've changed the mouse mode and the range is set at a suitable level (the world is just a single, hollow cube) but still no joy...

Cheers - Jim.

Re: C-Script problem... [Re: JimmyJazz] #167837
11/17/07 11:36
11/17/07 11:36
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
another try
make and add a mouse_map
and move the mouse wite

while(1)
{
mouse_pos.x += mouse_force.x;
mouse_pos.y += mouse_force.y;
wait(1);
}


"empty"
Re: C-Script problem... [Re: flits] #167838
11/17/07 12:08
11/17/07 12:08
Joined: Nov 2007
Posts: 18
J
JimmyJazz Offline OP
Newbie
JimmyJazz  Offline OP
Newbie
J

Joined: Nov 2007
Posts: 18
Thanks for the help Flits but still no joy!

I can't see where I've gone wrong with it - if I use a c_scan and change the doors ENABLE and EVENT the rotation occurs, it just doesn't seem to work with the click.

Frustrating!

Thanks again, Jim.

Page 1 of 3 1 2 3

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