Page 1 of 1

Sending Info to scripts

Posted: Wed Oct 19, 2005 3:18 am
by kkcahdcakcyt
ok i'm trying to make one of my custom maps compatible with mefy's custom map mods.

So far so good except for the bases. All other custom map .scr have this

waitthread command to base.scr::addbasepair "xxxxx xxxx xxx xxx" "xxxx xxxx xxx xxx"

(the xxxx are a number). I'm wondering would it then be sending the information the thread in the base.scr, because next to the thread there is this

addbasepair local.alpos local.axpos local.altype local.axtype local.alangles local.axangles


But that doesn't seem right because the amount of info doesn't add up to the number of variables.

Basically Does anyone know what those numbers next to the addbasepair call is? are they coord? or just info being sent to the addbasepair thread....

Posted: Wed Oct 19, 2005 10:09 am
by lizardkid
not sure what you mean, if you're asking about passing parameters, it goes like this.

Code: Select all

thread1:

thread thread2 1 2 5

end

thread2 local.a local.b local.c:

iprintln "You passed..."
iprintln "a: " local.a
iprintln "b: " local.b
iprintln "c: " local.c
iprintln "To thread2"

end
these two would print

You passed...
1
2
5
To thread2

on the screen.

How it works is the numbers after thread <threadname> are what are passed to corrosponding fields in the threadname. I'm not sure if illegal parameters are actually legal (in other words if MOH just gives a warning or if it gives a fullout error when it touches this point), so it could be that the description of addBasePairs is just old and they dont need one of the values listed.

Sorry if this isn't what you meant. :oops:

Posted: Wed Oct 19, 2005 4:39 pm
by GiffE1118
see the bottom of this thread

http://dynamic.gamespy.com/%7Emap/mohaa ... hp?t=10964

basically ur threading it with the valuse u want to pass and then in the new thread before the : ya add local.angle local.origin etc

it has to be in the same order

Posted: Wed Oct 19, 2005 4:44 pm
by jv_map
In your case, local.alpos and local.axpos will become the numbers you specified... all other variables will just be NIL.

Posted: Thu Oct 20, 2005 2:03 am
by mefy
The first two parameters are required and the rest are optional.

Code: Select all

addbasepair local.alpos local.axpos local.altype local.axtype local.alangles local.axangles 
alpos is the position string of the allied base
axpos is the position string of the axis base
altype is the type of allied base (default is a player model)
axtype is the type of axis base (default is a player model)
alangles is the exact angles of the allied base (default is ( 0 yaw 0 ) where yaw is the angle you specified in the position string)
axangles is the exact angles of the axis base (default is ( 0 yaw 0) where yaw is the angle you specified in the axis position string)

Altype and axtype are used if you want a different kind of base (like a tank or flak cannon).

Alangles and axangles are used when you have a vehicle base that needs to be properly tilted to make it look right when it sits on the terrain.

See the stock map scripts (like mohdm2.scr) where these are used.

Posted: Thu Oct 20, 2005 2:14 am
by kkcahdcakcyt
holy crap its mefy..... :shock: I considre you a genius lol ( and really patient, i get quit frustrated with this scripting!)

so...

addbaspair "x y z angle" "x y z angle"


and those two position strings coordinate to the variable alpos and axpos thus the others are left blank?

Posted: Thu Oct 20, 2005 6:01 am
by mefy
Yes but you should give a description of the base too:

Code: Select all

waitthread global/libmef/bases.scr::addbasepair "x y z angle desc" "x y z angle desc"
See the tutorial for more info:
http://mefymods.clan-dwr.com/viewtopic.php?t=23

Posted: Thu Oct 20, 2005 6:43 pm
by GiffE1118
mefy i actually have a question to u about that.

In ur script u thread it with 2 arrays. Yet in your thread ur sending to there is more then one variable. even though u sent 2. so my question to u is

when threading something with an array size of 3. Can u name the thread

Code: Select all

thread_tocall local.a local.b local.c:
and that would break up the array?

i know u can

thread and with an aray of 4 then in the thread have something like
(an origin then an angle)

Code: Select all

thread_tocall local.a:
local.origin[1] = local.a[1]
local.origin[2] = local.a[2]
local.origin[3] = local.a[3]
local.angle = local.a[4]
but does the other way work to break it up or no?

Posted: Fri Oct 21, 2005 1:29 am
by lizardkid
The answer is no. arrays are only really handy ways of keeping data stored in one place under one name. It doesn't really do anything else afaik.

each member of an array is a separate value like anything else.

Although i've never tried sending arrays as a whole to a thread, you can do it in high-level languages like C++ and Java, but in MOH i sorta doubt it.

Posted: Fri Oct 21, 2005 2:35 am
by mefy
Arrays are passed by reference. A thread will not automatically "break up" the array's elements into each of its parameters. Keep in mind the keys of the array aren't necessarily numbers and so breaking up doesn't really make any sense. You have to address each element that you want.
In ur script u thread it with 2 arrays. Yet in your thread ur sending to there is more then one variable. even though u sent 2. so my question to u is
You'd have to show me what you're looking at because I think you're misinterpreting it.

Posted: Fri Oct 21, 2005 3:51 am
by GiffE1118

Code: Select all

	waitthread global/libmef/bases.scr::addbase local.seteam " -898  904  496.13    -90 South Bldg Top Level"
and in addbase

Code: Select all

addbase local.team local.pos local.type local.angles
see how ur setting 1 set of "" and the local.team. in the thread name ya got more than 2 where do they come from


OR do they just come out as NIL and ya get the data from somewhere else...

Posted: Fri Oct 21, 2005 6:34 am
by mefy
They'll just be NIL. Those are optional parameters like I explained in my first post. Also there's no arrays being passed. The position string is parsed later on.

Posted: Fri Oct 21, 2005 6:39 pm
by GiffE1118
ah i got it now then :D
just mis interpreted