Question about locations

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
digitac
Sergeant
Posts: 58
Joined: Mon Jul 28, 2003 3:30 pm

Question about locations

Post by digitac »

How to get the location of an script object ?

i want an object only to move if it's in a position i choose
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

$object_targetname.origin :wink:

Welcome to .map :D
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

and this:

Code: Select all

if ($object_targetname.origin == (40 40 40))
{
    iprintln "$object_targetname is in position
}
:)
digitac
Sergeant
Posts: 58
Joined: Mon Jul 28, 2003 3:30 pm

Post by digitac »

so if i have an elevator that is on 320 high

and i want to have in my script that when u use the trigger
and the elevator needs to get down.
how can i say that ?

Code: Select all

$elevator_platform time 5.8
$elevator_door_up_left time 2
$elevator_door_up_right time 2
$elevator_door_down_left time 2
$elevator_door_down_right time 2
$elevator_trigger waittill trigger
if ($elevator_platform.origin == 320)
{
$elevator_door_up_trigger nottriggerable
$elevator_trigger movedown 320
$elevator_trigger move
$elevator_platform movedown
$elevator_platform waitmove
$elevator_door_down_left rotatey 45
$elevator_door_down_right rotatey -45
$elevator_door_down_left move
$elevator_door_down_right move
wait 5
$elevator_door_down_left rotatey -45
$elevator_door_down_right rotatey 45
$elevator_door_down_trigger triggerable
}

if ($elevator_platform.origin == 0)
{
$elevator_door_down_trigger nottriggerable
$elevator_trigger moveup 320
$elevator_trigger move
$elevator_platform moveup
$elevator_platform waitmove
$elevator_door_up_left rotatey 45
$elevator_door_up_right rotatey -45
$elevator_door_up_left move
$elevator_door_up_right move
wait 5
$elevator_door_up_left rotatey -45
$elevator_door_up_right rotatey 45
$elevator_door_up_trigger triggerable
}

or something ( please change if needed ) i am a novice newbee :)
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

nononononononono. an origin is three numbers: coordinate x, coordinate y, and coordinate z.

remember, this is quake3, not half-life. you can do a few easier things here.

make a trigger_use in your map. heres an example script:

Code: Select all

main:

    level waittill prespawn

    level waittill spawn

    waitthread elevator_setup //wait for thread named elevator_setup before continuing
    thread elevator //start thread elevator when ready
    end

elevator_setup: // the thread we called

    $elevator_trigger bind $elevator_platform //object a automatically moves at an offset with object b
    //this next line assumes our elevator is in the "down" position... so we create our own variable that determines if its up or down...
    $elevator_platform.state = "down"
    $elevator_platform time 5.8 
    $elevator_door_up_left time 2 
    $elevator_door_up_right time 2 
    $elevator_door_down_left time 2 
    $elevator_door_down_right time 2 

    end

elevator: //our main elevator thread

    $elevator_trigger waittill trigger
    if ($elevator_platform.state == "down")
    {
        $elevator_door_down_trigger nottriggerable 
        $elevator_platform moveup 320
        $elevator_platform waitmove
        $elevator_door_up_left rotatey 45 
        $elevator_door_up_right rotatey -45 
        $elevator_door_up_left move 
        $elevator_door_up_right move 
        wait 5 
        $elevator_door_up_left rotatey -45 
        $elevator_door_up_right rotatey 45 
        //update to new position
        $elevator_platform.state  = "up"
        $elevator_door_up_trigger triggerable 
    }
    else if ($elevator_platform.state == "up")
    {
        $elevator_door_up_trigger nottriggerable 
        $elevator_platform movedown 320
        $elevator_platform waitmove 
        $elevator_door_down_left rotatey 45 
        $elevator_door_down_right rotatey -45 
        $elevator_door_down_left move 
        $elevator_door_down_right move 
        wait 5 
        $elevator_door_down_left rotatey -45 
        $elevator_door_down_right rotatey 45 
        //update to new position
        $elevator_platform.state = "down"
        $elevator_door_down_trigger triggerable 
    }
    end
something like that. :wink:
Parts
Sergeant
Posts: 72
Joined: Thu Apr 10, 2003 12:35 pm
Location: UK
Contact:

Post by Parts »

The SDK Explains this pretty well but here goes anyway:

the origin property is actually a vector as pople have already explained consisting of x , y and z coordinates. If we are talking about up and down like in an elevator then you are interested in the Z coordinate.

Therefore to find out the height of the object you could do something like:

local.ElevatorHeight = $Elevator.origin[2]

o.e. take the third element out of the origin array. In the array 0 is x coord, 1 is y coord and 2 is z coord
[VS-UK]Capt.Parts[BnHQ]
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

yeah, so you could put

if ($elevator_platform.origin[2] == 320) //that would be if the z coordinate (vertical) is 320.
digitac
Sergeant
Posts: 58
Joined: Mon Jul 28, 2003 3:30 pm

Post by digitac »

This solution gives me NIL

dunno what that means :roll:

Maybee i did something wrong ?

if ($elevator_platform.origin[2] == 0)
{
.....
}
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Could you post the exact error message?
Image
Post Reply