allways lost in the script (self)

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Tropheus
Corporal
Posts: 49
Joined: Sun Sep 14, 2003 11:19 pm
Location: france
Contact:

allways lost in the script (self)

Post by Tropheus »

Help everybody !
Have you ever seen a man lost in the scripting ocean ???
That's me in the middle of my problem.

So i thought i understood the self object as i said in my last post, but it isn't !!!

If in theory it's allright, when i want to make a map with self object appaers several problem.

I want to build a map with 2 documents to steal.
How do i'll call my documents ? with the same targetname ?

Do i have to put a trigger_use on it ? With wich name ?

How my trigger make reference to the tread in my scrpt. do i have to give a setthread value? do i have to give a target value to the trigger ?

If i could answer with the 2 parts separeted (mapping part and scripting part) it would be greatfull.

Thanks a lot for your help.

Tropheus
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post by Random »

Now i know there is a good tutorial in the tuts section on how to set up stealing the documents OBJ. I know it there cuz i used it and modified it a bit to set up 2 sets of documents instead of one. So if you read that and follow the directions there would be the answer for the Documents question. As for the self thing i have no idea.
Moderator
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Ok about the self thing . self is the entity that called the thread for example

$player thread do_thing // self will be $player
or
$documents thread do_thing // self will be documents
or

(trigger_multiple)

Key:setthread Value:do_thing // the trigger will be self
Key:target Vaule:$pathnode1

do_thing:

if (self.targetname == "player")

iprintln " do thing called by the player"

if(self.targetname == "documents")

iprintln " do thing called by the documents "

if(self.targetname == "mytrigger")

iprintln " do thing called by the trigger's setthread value "

$myenemyImade runto self.target // self is trigger self.target is $pathnode 1

end

So if you use a trigger_use and it's target is the documents then in the thread called by putting Key:setthread Value:mythread
self will be the trigger and self.target will be the documents then you can do what you want with that

mythread:

self nottriggerable // make trigger not triggerable again

self.target remove // remove the documents

level.I_have_the_documents = 1

end

etc....
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

if your documents have to be called the same thing (more complicated if your only learning scripting)

create trigger_use
key: setthread
value: steal_me
key: targetname
value: steal_trigger
key: #tropheus
value: 1 //have one on the 1st documents trigger
value: 2 //have two on the 2nd documents trigger

create the documents (script objects)
key: targetname
value: documents

then in the script have

steal_me:
self nottriggerable //so can only be stolen once
$documents[self.tropheus] hide
$documents[self.tropheus] notsolid
end

this is just the base of what you'll need, you'll need to create team checks if it's in MP,

as the $documents will be more than 1, the compiler will automatically give it a name of $documents[1], $documents[2] etc... so the self (being the trigger which has tropheus set as the indicator for which set to hide) will determine the correct documents set,

this is set in the .bsp so if you have problems with the wrong documents disappearing, change the #tropheus number to it's alternate (1 to 2 and 2 to 1)

bear in mind the array of the documents is made from the brush numbers, where any multiple targetnames get an array so the #tropheus value will need to be 1 on the 1st documents brush you drew :D
hope this helps, prob not cos it's all foreign 2 me :-/
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

actually nuggets that can get confuseing because the first one you create will be $documents when you create another one $documents becomes $documents[2] and the new one will be $document[1] and if you make another one $documents[2] will then be $documents[3] because the array gets incremented up when you add to it the last one created is $documents[1] . and if you delete one and add it again that changes the numbers again . What I think you need to do is key: #tropheus
Value: 1 for both the trigger and it's documents pair . Then when a trigger is triggered you look at all the $documents to find the one with the same key: #tropheus value as the trigger .
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Tropheus: Here for the document objectives: http://www.planetmedalofhonor.com/rjuka ... ctive.html

...and here is a quote from the section on the self object in my tutorial on scripting:
http://www.planetmedalofhonor.com/rjukanproject/tutorial/tutorial_scripting_language.html wrote:The self object

There is a special object called "self".

The "self" object has its value set at the creation of a group of threads. The following are some such situations:
Automatically started scripts

self is NULL for level scripts. Self is the character for animation scripts.
Command: thread label

Since the new thread has the same group as the original thread, self in the new thread is equal to self in the original thread.
Command: object thread label

self in the new thread is set equal to object.
Event threads

If a thread is initiated in response to an event of an object, then self is set equal to this object.
Admin .MAP Forums
Image
Head above heels.
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

i'll take your wordfor it but never had that problem with documents / bombs / waypoints

create trigger_use
key: setthread
value: steal_me
key: targetname
value: steal_trigger
key: #tropheus
value: 1 //only use 1 once, on the 2nd set use 2

create the documents (script objects)
key: targetname
value: documents
key: #tropheus
value: 1 //make this the same as the documents tropheus number
then in the script have
key: $doc_name
value: Generals_File //change this for every paper set if u want to or leave it blank, it's up to you


main:
level.stealers = "allies"
level.total_docs = $documents.size
end

steal_me:
if parm.other.dmteam == level.stealers
{self nottriggerable
for (local.i = 1; local.i <= $documents.size; local.i++)
{if $documents[local.i].tropheus == self.tropheus)
{$documents[local.i] hide
$documents[local.i] notsolid
level.total_docs--
if !($documents.docs_name == "NIL")
{iprintlnbold_noloc "The " $documents.doc_name " has been stolen!"}
else
{iprintlnbold_noloc "The documents have been stolen!"}
if (level.total_docs > 1)
{iprintlnbold_noloc level.total_docs " sets of papers remaining"}
if (level.total_docs == 1)
{iprintlnbold_noloc "1 set of papers remaining"}
if (level.total_docs == 0)
{iprintlnbold_noloc "All documents stolen!"
teamwin level.stealers}}}}
end

/*hope ya like it
this will work for any number of documents now (i think it would of before but best be safe than sorry :D
any more problems you know where i/we are
*/
hope this helps, prob not cos it's all foreign 2 me :-/
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

by the way ^^^^ that previous post is for an OBJ map
hope this helps, prob not cos it's all foreign 2 me :-/
Tropheus
Corporal
Posts: 49
Joined: Sun Sep 14, 2003 11:19 pm
Location: france
Contact:

Post by Tropheus »

hi everybody.
first thanks for your answers that i have to study, but you seem speaking about multiplayer map.
But i want to make a solo map?
doesn't it change a lot of things.

I think that in the definition of a self object it changes.

Thanks for your future answers.

Tropheus.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Oi oi above post reveals you still don't quite get it :? :wink:

There is no self object.

Instead, writing 'self' is a shortcut for writing the 'subject' of a thread.

For example, you could have:

$alarmspeakeronthethirdfloor thread sound_the_alarm

Then in the sound_the_alarm thread, you could either type:

$alarmspeakeronthethirdfloor loopsound mec_alarm

or, you could save yourself a lot of work and typos by typing:

self loopsound mec_alarm

Thus, 'self' always refers to the object before the 'thread' command. It is not an independent object by itself.
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

lmao@JV oi oi seems to be becoming world wide :P

anyyway, yes the setup is different, you don't need a team check and the objective lines are different,

as i don't usually deal with SP maps, i'll let some1 else answer your question on that

but i will add this

thread_1:
$a_object thread the_thread
$b_object thread the_thread
end

the_thread:
self do action
end

as $a_object and $b_object have both threaded the the_thread thread, as they are the subjects threading the_thread they will both do the action

however if:

the_thread: //was written this way
$a_object do action
end

$a_object will do the action twice as that's the thread being done,

$player thread _whatever

whatever:
self do thingy
end

so $player (which is doing the thread) will do thingy
hope this helps, prob not cos it's all foreign 2 me :-/
Post Reply