Posted: 5th Apr 2007 21:22
The title says everything!
Please Can Someone Post Joystick Commands (and an explanation)

Please, I need help on this!
Posted: 5th Apr 2007 21:28
Could you not look in the help files?
Posted: 6th Apr 2007 1:29
You mean like an example of something using a joystick to move? If that is the case, then I have an example I made a while ago which does exactly that. It also includes a camera_follow function which complements the way the joystick input is handled :P

+ Code Snippet
sync on : sync rate 45 : hide mouse

make matrix 1,1000,1000,20,20
randomize matrix 1,20
update matrix 1

make object cone 1,5
xrotate object 1,90
fix object pivot 1
set object cull 1,0
color object 1,0x00ff00

global speed# as float
global movement as integer
speed#=0.00
movement=0

type Player
    x# as float
    y# as float
    z# as float
    ya# as float
    lastcamya# as float
endtype

global Plr as Player

do
    if abs((abs(joystick x())+abs(joystick y())))<100 then movement=0
    if abs((abs(joystick x())+abs(joystick y())))>=100
        movement=1
        speed#=curvevalue(0.5,speed#,10)
        ang#=wrapvalue(wrapvalue((atanfull(joystick x(),joystick y())+180)*-1))
        Plr.ya#=wrapvalue(camera angle y(0)+ang#)
    endif
    if movement=0 then speed#=curvevalue(0,speed#,10)
    inc Plr.x#,sin(Plr.ya#)*speed#
    inc Plr.z#,cos(Plr.ya#)*speed#
    yrotate object 1,Plr.ya#
    position object 1,Plr.x#,get ground height(1,Plr.x#,Plr.z#)+2.5,Plr.z#
    camera_follow(0, 1, 15, 20)
    text 5,5,"Joystick to move"
    text 5,25,"Joystick X:"+str$(joystick x())
    text 5,45,"Joystick Y:"+str$(joystick y())
   sync
loop

function camera_follow(cam as integer,object as integer,maxdist# as float,smoothing as integer)
    `capture camera positions
    camx#=camera position x(cam)
    camy#=camera position y(cam)
    camz#=camera position z(cam)
    `capture object positions
    objx#=object position x(object)
    objy#=object position y(object)
    objz#=object position z(object)
    `get the distance between object and camera
    dist#=abs(sqrt(((camx#-objx#)^2)+((camy#-objy#)^2)+((camz#-objz#)^2)))
    `calculate the x and z of where the camera should end up around the
    `object with a buffer radius of maxdist#
    goalx#=(objx#+(sin(atanfull((camx#-objx#),(camz#-objz#)))*maxdist#))
    goalz#=(objz#+(cos(atanfull((camx#-objx#),(camz#-objz#)))*maxdist#))
    `calculate the camera's height at object position, plus 1-1/5 the object's height
    camy#=curvevalue(objy#+((object size y(object)/5)*6),camy#,smoothing)
    `calculate the new x and z for the camera if the object strays too far away
    if dist#>maxdist#
        camx#=curvevalue(goalx#,camx#,smoothing)
        camz#=curvevalue(goalz#,camz#,smoothing)
    else
        `move the camera upward if the player gets too close
        camy#=curvevalue(objy#+((object size y(object)/5)*6)+(maxdist#-dist#),camy#,smoothing)
    endif
    `point the camera at the object
    point camera cam,objx#,objy#,objz#
    `position the camera on the new calculated destination
    position camera cam,camx#,camy#,camz#
endfunction
Posted: 6th Apr 2007 11:11
I've now looked in the help file. All I now want to know is how to use the slider thingy (Used for throttle in Flight simulator).
Posted: 6th Apr 2007 13:14
this code snippet show what every button on the joy stick and mouse.

run it and see.

+ Code Snippet
  rem Standard Setup Code
rem mouse buttons and Wingman and others controlers
sync on : sync rate 0 :
backdrop on
color backdrop rgb(0,0,0) : hide mouse
set text font "arial" : set text size 12 : set text transparent
rem makes number to say what value joy button is
dim number$(32)
for i = 0 to 32
   number$(i)=str$(i+1)
next i

repeat
   mc = mouseclick()
   cls
   text 0, 10, "mouse CLICK: " + str$(mc)
   if (mc && 1) = 1 then text 0, 50, "LEFT"
   if (mc && 2) = 2 then text 0, 60, "RIGHT"
   if (mc && 3) = 3 then text 0, 70, "both"
   if (mc && 4) = 4 then text 0, 80, "wheel button"

rem && does an LOGICAL AND operation! It's not the same like AND! It compares the values BITWISE...
rem Bits:
rem 010 && 101 = 000
rem 010 && 111 = 010
rem 101 && 101 = 101

rem Decimals:
rem 2 && 5 = 0
rem 2 && 7 = 2
rem 5 && 5 = 5


for i = 0 to 32
   text 0+(i*10),120, str$(joystick fire x(i))
   if joystick fire x(i)=1
      text 0, 110, " fire CLICK: "+str$(i)
   else
   text 0, 110, " fire CLICK:    "
   endif
next i
rem check all 32 button
for f=0 to 32
   if (joystick fire x(f) && 1) = 1 then text 0, 150+(f*10)," fire button "+ number$(f)
next f
rem check slider and make it a value from 0 to 256
if joystick slider a() then text 0, 290," fire slider a = "+str$(int(abs(joystick slider a()-65536)/256))
rem work out the angle of the hat button
hat=joystick hat angle (0)
text 0,360,"hat angle = "+str$(hat/100)
rem work out the twist angle
tz=joystick twist z()
text 0,380,"Twist z angle = "+str$(tz/256)
rem value of up and down -1000 to 1000
jy=joystick y()
text 0,390,"Joy y up down= "+str$(jy)
rem as above
jx=joystick x()
text 0,400,"Joy x left right= "+str$(jx)
rem if you have it
jz=joystick z()
text 0,410,"Joy z = "+str$(jz)
rem puts in force to stick if a power stick
text 300,10,"Press upkey to make force Up "
if upkey()
force up 100
endif
text 300,20,"Press downkey to make force Down "
if downkey()
force down 100
endif
text 300,30,"Press Leftkey to make force Left "
if leftkey()
force left 100
endif
text 300,40,"Press Rightkey to make force Right "
if rightkey()
force right 100
endif
rem as above but using the hat button
hat#=joystick hat angle (0)/100
if hat#<>0
force angle 100,hat#,10
endif
rem update screen
sync
until 1=2
Posted: 8th Apr 2007 21:38
I didn't understand. Please explain slower.
Posted: 8th Apr 2007 21:44
rem check slider and make it a value from 0 to 256
if joystick slider a() then text 0, 290," fire slider a = "+str$(int(abs(joystick slider a()-65536)/256))


ok the above line is doing this,

Has the joystick slider a been moved, if it has then place the value its at, at text postion 0,290.
the next bit does some maths that makes it a joystick value read 0 to 256.
Posted: 31st Jul 2007 11:33
oh, I get it now. Thanks