OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lean Bear on 23 Dec 2004, 14:40:19
-
OK, basically - that command doesn't work for me.
I am using the shortest of the BIS apartment blocks //or whatever you want to call them - the grey ones with loads of floors.
I would like to make a texture appear on the side of a building using an action. I made a new plane on the side of the building in O2 and called the face that points outwards "Side" in the selections box. I then textured it with a clear texture (transparent).
Next in the config of the building I put:
class CfgVehicles
{
   class All{};
   class Static: All{};
   class Building: Static{};
   class Strategic: Building{};
   class LNB_House: Strategic
   {
      scope=2;
      icon="Unknown_object";
      model="\LNB_House\LNB_House.p3d";
      displayName="LNB House";
      vehicleClass="Lean Bear's Buildings";
      accuracy=0.200000;
      typicalCargo[]={};
      destrType="DestructBuilding";
      transportAmmo=0;
      transportRepair=0;
      transportFuel=0;
      mapSize=11;
      cost=0;
      armor=2000;
      ladders[]={{"start","end"}};
      hiddenSelections[]={"Side"};
   };
};
Everything works out OK in the editor etc. the building comes up under its own class and works fine.
Then I made the scripts:
one called painthouse.sqs which is activated by a proximity trigger and contains:
player addAction ["Paint", "PaintingTime.sqs"]
Then, in PaintingTime.sqs:
_LNB_House = _this select 0
_LNB_House setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]
(btw neither of these work at all when I keep them in the pbo - so, on a side not, how do I include scripts in my addons?)
but nothing happens. When the player walks into the trigger, the action "Paint" comes up, but when used - nothing happens.
Can anyone help me out here?
-
The addAction passes three variables in the called script [on who/what the action is attached to ,user of the action (the one who activates it),action id], so in this case the line
_LNB_House = _this select 0
refers to the trigger (if on nothing at all), not the house...
Put the addAction command in the houses init field and it should work...
-
OK, although I didn't really understand what you said about the three variables (perhaps you could expound on that?) but I tried putting player addAction ["Paint","PaintingTime.sqs"] in the building's inti field, but when I did "Paint" the tex that I wanted on the side of the house came up tiny on the behind of my unit.
-
You might wanna use this instead of player because if you use player the _this select 0 referres to the player, not to the house...
So, in the houses init field:
this addAction ["Paint","PaintingTime.sqs"]
The explanation of the three variables can be found here:
http://www.ofpec.com/editors/comref.php?letter=A#addAction
-
Thanks for the three variables link.
I tried what you said but this time absolutely nothing happened.
Here's what I think:
in the script PaintingTime.sqs I said:-
_LNB_House = _this select 0
so surely when I put this in the addAction line - surely it is refering to the house (the object) - correct?
Actually I'm just waffling and have no idea how to get this to work - I've checked and re-checked FAB's tuts on his site, and my stuff looks exactly the same - but mine doesn;t work :P
-
Well, you could use some debugging in your script, so put some line like
hint format ["%1",_LNB_House]
after the line
_LNB_House = _this select 0
and see what the hint tells you...
Then you at least know what the variable _LNB_House actually includes...
-
Well, when the addAction line read player addAc... the hint came up with this:
WEST Alpha Black:1 (Lean Bear)
^ This, to me, seems very normal and doesn't really tell me anything except that that is the player.
Then, far more interesting :D, when the line read this addAc.. in the building's init field the hint came up with the following message:
15b77b00# NOID
lnb_house
Just like that. Doesn't really mean anything to me 'cept that there is probably an error or something.
-
15b77b00# NOID
lnb_house
Just like that. Doesn't really mean anything to me 'cept that there is probably an error or something.
well, I don't think that's an error (afaik)...
The NOID probably means that the object has no object ID because it was put on the map in the editor (again, pure guess...)
You could go another way around, by using the nearestBuilding function...
In the Painting time you would have something like:
_unit = _this select 1
_house = nearestBuilding _unit
_house setObjectTexture [0,"blah blah"]
I can't access to FABs site for some reason so I can't have a look at the tutorial you are talking about...
Are you sure you don't need to define anything for the house in CfgModels (in the config)?
-
Have you added the selection name in the CfgModels section of your config? Because if you haven't, the unit won't "have" the selection and all the setObjTexture's in the world won't matter.
-
...mapSize=11;
      cost=0;
      armor=2000;
      ladders[]={{"start","end"}};
      hiddenSelections[]={"Side"};
   };
};
i think this is your problem mate. I've done some configs and i believe hiddenSelections[]={ }; is to make avalible such things as the medic abilities. As KTottE said, i think you want to make this selection[]={ };
not 100% sure though.
-
i think this is your problem mate.
No, exactly the opposite...
The hiddenSelections MUST have the selections in it...
Because in the setObjectTexture [number,"texture"] the number refers to the hiddeSelections array (yes, it's an array...) and it works like 'regular' arrays so 0 is the first element and so on....
What KTottE means is the CfgModels part in the config...
-
OK, I'd just like to confirm what the cfgModels section is for a house/building so that I don't spend ages correcting mistakes.
class CfgModels
{
   class Default {};
   class Vehicle: Default {};
   class LNB_House: Vehicle
   {
      sections[] = {"Side"};
   };
};
^
| Is this correct?
edit
This is what I had been using, but as it didn't seem to make any difference, I cut it out.
-
If your p3d file is indeed called ....LNB_House.p3d.......then this looks correct to me.
Hmmm.....a house that is a vehicle.........does it have wheels too? ;D
Planck
-
Yes, that is what it's called.
As there are no buildings defined in the cfgModels section I have actually changed it to:
class CfgModels
{
class Default {};
class LNB_House: Default {};
{
sections[] =
{
"Side"
};
};
};
(since it isn't a mobile home :))
Also, I got fed up and tried using setObjectTexture directly in the house's init field:
this setObjectTexture [0,"LNB_Paint1.paa"]
and I put the texture in the mission folder.
....nothing.....
I was so used to the texture appearing on the rear end of my unit that I was very shocked to see that nothing had happened.
Perhaps there is something else that's wrong?
-
Try this one:
class CfgModels
{
class Default
{
sections[] = {};
sectionsInherit="";
};
class Building: Default{};
class Strategic: Building{};
class LNB_House: Strategic
{
sections[] = {"Side"};
};
};
Also do you have a cfgPatches section in your config?
Planck
-
Yeah, it looks like this:
class CfgPatches
{
   class LNB_House
   {
      units[] = {"LNB_House"};
      weapons[] = {};
     ÂÂ
      requiredVersion = 1.91;
   };
};
-
So:
LNB_TagHouse is the name of your PBO file?
And LNB_TagHouse is the class name of the building in cfgVehicles?
If not you better make it so.
Planck
-
oops :-X took it out of the wrong config ;D
(corrected now)
Yeah, I made everything have the name LNB_House. Variable name, class names, p3d names (you get the idea) - to keep it simple.
-
Did you try the cfgModels section I posted yet?
Planck
-
Yeah, just finished testing.
I got the now usual texture-on-the-rear as well as the following hint:
scalar bool array string
0xff3ffffffcfffeff //loads of weird numbers etc.
-
The way I see this you have attached this action to the player......so:
_LNB_House = _this select 0
_LNB_House setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]
This would mean that _LNB_House would be the player.
Try naming the building......say.....fred
Then you could try:
fred setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]
Planck
-
OK, I tried it out and it came up with the following error:
""fred [#]= _this select 0" Error: reserved variable in use//or something like that
-
Thats a new one, I've never heard of the reserved variable fred.
Don't use the ....fred = this select 0 line
Leave it out, just use:
fred setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]
Planck
-
I think it meant that 0 is a reserved variable, not fred :P
-
Leave it out, just use:
fred setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]
This time, nothing happens. at. all. :'(
-
Hahahahaha......ok
Try this:
fred == this select 0
fred setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]
No guarantees mind. ::)
Actually, I seem to recall that the texture file can only be a certain size, can't remember what though.
Planck ::)
-
Actually, I seem to recall that the texture file can only be a certain size, can't remember what though.
Isn't it 32x32?
-
The texture can be any size you wish as long as it's in a power of two format.
That is, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 and so on, and it doesn't have to be square, it can be rectangular.
-
The one I'm using is 256^256 anyway, so that shouldn't make a difference then.
I've heard it comes out as 32^32 quality though. Is this tue?
edit
btw Does the texture I replace need to be the same size as the one I'm putting on?
Cause I think I textured it with a 512^512 transparent texture, but I want to add a 256^256, would that make any difference?
-
Isn't it 32x32?
Yes I think that is right LB, but, I have read somewhere else that the limit was 64 X 64.
It sort of limits setObjectTexture a little bit.
Planck
-
So, d'ya think that if was to re-size the texture I want to SetObjectTexture with, it might work?
Then I could always work up from there, maybe try 64x64 :D
-
It won't do any harm to try.
Always experiment, I know it can get tedious sometimes, but it is nearly always the way to find things out.
Another thing..........Maybe your texture is being mapped to your building, but, you can't see it because the plane it is mapped to is behind the wall plane.
Maybe you have to make your plane the one that is on top
Planck
-
Another thing..........Maybe your texture is being mapped to your building, but, you can't see it because the plane it is mapped to is behind the wall plane.
Maybe you have to make your plane the one that is on top
It is on top (actually about 1m away from it). I did this so I could see all the sides (in case I'd named the wrong selection) and so what you said wouldn't happen.
Resizing it didn't work either, I'm afraid.
I tried 32x32 and went through all the possible arrangements with scripts, names etc. but nothing worked.