Home   Help Search Login Register  

Author Topic: SetObjectTexture problems  (Read 2963 times)

0 Members and 1 Guest are viewing this topic.

Lean Bear

  • Guest
SetObjectTexture problems
« 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?




« Last Edit: 23 Dec 2004, 14:42:08 by Lean Bear »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:SetObjectTexture problems
« Reply #1 on: 23 Dec 2004, 16:22:56 »
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...
« Last Edit: 23 Dec 2004, 16:24:50 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #2 on: 23 Dec 2004, 18:14:45 »
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.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:SetObjectTexture problems
« Reply #3 on: 23 Dec 2004, 18:20:23 »
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
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #4 on: 23 Dec 2004, 20:10:13 »
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



Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:SetObjectTexture problems
« Reply #5 on: 23 Dec 2004, 21:59:29 »
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...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #6 on: 24 Dec 2004, 11:50:56 »
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.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:SetObjectTexture problems
« Reply #7 on: 24 Dec 2004, 13:12:45 »
Quote
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:
Code: [Select]
_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)?
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline KTottE

  • Former Staff
  • ****
Re:SetObjectTexture problems
« Reply #8 on: 24 Dec 2004, 17:42:11 »
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.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:SetObjectTexture problems
« Reply #9 on: 26 Dec 2004, 20:55:21 »
...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.
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:SetObjectTexture problems
« Reply #10 on: 27 Dec 2004, 09:18:54 »
Quote
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...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #11 on: 29 Dec 2004, 14:35:23 »
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.
« Last Edit: 29 Dec 2004, 14:37:47 by Lean Bear »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #12 on: 29 Dec 2004, 20:50:01 »
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
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #13 on: 29 Dec 2004, 21:02:15 »
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?



Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #14 on: 29 Dec 2004, 21:33:50 »
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
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #15 on: 29 Dec 2004, 21:35:15 »
Yeah, it looks like this:

class CfgPatches
{
   class LNB_House
   {
      units[] = {"LNB_House"};
      weapons[] = {};
      
      requiredVersion = 1.91;
   };
};
« Last Edit: 29 Dec 2004, 21:41:44 by Lean Bear »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #16 on: 29 Dec 2004, 21:40:08 »
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
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #17 on: 29 Dec 2004, 21:43:45 »
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.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #18 on: 29 Dec 2004, 21:47:30 »
Did you try the cfgModels section I posted yet?


Planck
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #19 on: 29 Dec 2004, 21:54:23 »
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.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #20 on: 29 Dec 2004, 22:07:32 »
The way I see this you have attached this action to the player......so:
Code: [Select]
_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
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #21 on: 30 Dec 2004, 19:20:39 »
OK, I tried it out and it came up with the following error:

Code: [Select]
""fred [#]= _this select 0" Error: reserved variable in use//or something like that
« Last Edit: 30 Dec 2004, 19:22:04 by Lean Bear »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #22 on: 30 Dec 2004, 19:46:35 »
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
« Last Edit: 30 Dec 2004, 19:48:26 by Planck »
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #23 on: 31 Dec 2004, 10:23:14 »
I think it meant that 0 is a reserved variable, not fred :P

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #24 on: 31 Dec 2004, 10:46:58 »
Quote
Leave it out, just use:

fred setObjectTexture [0,"\LNB_House\LNB_Paint1.paa"]

This time, nothing happens. at. all. :'(

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #25 on: 31 Dec 2004, 20:00:10 »
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 ::)
« Last Edit: 31 Dec 2004, 20:01:26 by Planck »
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #26 on: 31 Dec 2004, 20:42:20 »
Quote
Actually, I seem to recall that the texture file can only be a certain size, can't remember what though.

Isn't it 32x32?

Offline KTottE

  • Former Staff
  • ****
Re:SetObjectTexture problems
« Reply #27 on: 01 Jan 2005, 10:40:10 »
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.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #28 on: 01 Jan 2005, 13:06:44 »
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?
« Last Edit: 01 Jan 2005, 13:08:41 by Lean Bear »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #29 on: 01 Jan 2005, 21:50:31 »
Quote
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
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #30 on: 02 Jan 2005, 21:01:06 »
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

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:SetObjectTexture problems
« Reply #31 on: 02 Jan 2005, 21:05:52 »
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
« Last Edit: 02 Jan 2005, 21:09:27 by Planck »
I know a little about a lot, and a lot about a little.

Lean Bear

  • Guest
Re:SetObjectTexture problems
« Reply #32 on: 13 Jan 2005, 18:03:52 »
Quote
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.