Author Topic: Mounting Images on Selection  (Read 2552 times)

Code: [Select]
registerOutputEvent(Bot, setPetType, "datablock ShapeBaseImageData", 1);


function Player::setPetType(%player,%image,%data)
{
%player.setDataBlock("HorseArmor");
%player.hidenode(head);
%player.hidenode(body);
clearAllPlayerNodes(%player);
%player.mountimage(BeagleImage, 1);
}

//Model Support
datablock ShapeBaseImageData(BeagleImage)
{
shapeFile = "./Models/DogBeagle.dts";
emap = false;
mountPoint = $BackSlot;
offset = "0 0 -0.35";
eyeOffset = "-1 -1 -1";
rotation = "0 0 0 0";
className = "ItemImage";
uiName = "Dog - Beagle";
};

datablock ShapeBaseImageData(HuskyImage)
{
shapeFile = "./Models/DogHusky.dts";
emap = false;
mountPoint = $BackSlot;
offset = "0 0 -0.35";
eyeOffset = "-1 -1 -1";
rotation = "0 0 0 0";
className = "ItemImage";
uiName = "Dog - Husky";
};

I am making an event that mounts images to the bot player model. I am having trouble because the event only allows me to mount the image I specify in the code, instead of the selection in the event menu(ShapeBaseImageData)

%player.mountimage(ImageSelectionHere, 1); <

How would I go about mounting the image selected from the wrench menu?
This way I could mount different images to the bot selected through events instead of just one

Any help is greatly appreciated!!

The function the event is trying to call is AIPlayer::setPetType(%bot, %image, %client).

If you wanted it to be for both players and bots, you could do something like this:
Code: [Select]
registerOutputEvent(Bot, setPetType, "datablock ShapeBaseImageData", 1);
registerOutputEvent(Player, setPetType, "datablock ShapeBaseImageData", 1);

function AIPlayer::setPetType(%bot, %image, %client)
{
    setPetType(%bot, %image, %client);
}

function Player::setPetType(%player, %image, %client)
{
    setPetType(%player, %image, %client);
}

function setPetType(%obj, %image, %client)
{
    //Do stuff here.
}
« Last Edit: August 31, 2014, 06:29:00 AM by jes00 »

The function the event is trying to call is AIPlayer::setPetType(%bot, %image, %client).

Wouldn't Player work anyway because AIPlayer inherits from Player?

Wouldn't Player work anyway because AIPlayer inherits from Player?

Yeah, I was going to mention that too. I didn't since the events system might just basically eval(%className @ "::" @ %methodName @ ...); in which case it wouldn't work;.

Wouldn't Player work anyway because AIPlayer inherits from Player?
Whoops. Forgot about that.
Yeah, I was going to mention that too. I didn't since the events system might just basically eval(%className @ "::" @ %methodName @ ...); in which case it wouldn't work;.
I'll have to test that.

EDIT: Registering the event as bot and defining the function as player works perfectly fine.
« Last Edit: August 31, 2014, 02:50:14 PM by jes00 »

Thanks for the help guys, but what I actually mean is this:

When I wrench a bot spawn I do the event
onBotSpawn > Bot > setPetType > {LIST}

The event works fine, I can select any 'pet' from the 'shapeBaseImageData' list
However, instead of mounting the image selected in the list, it only mounts the image defined in the setPetType function.

I was wondering if there was a way to mount any "shapeBaseImageData" with a ui name to the bot, instead of just a single defined one.

Basically:
onBotSpawn > Bot > setPetType > Husky : mounts the huksy image to the bot
onBotSpawn > Bot > setPetType > Beagle : mounts the beagle image to the bot

?

So then instead of
Code: [Select]
function Player::setPetType(%player,%image,%data)
{
%player.mountimage(BeagleImage, 1);
}

What would I do to mount the image selected in the setPetType list?

Again, thanks for the help. This one really has me stumped.
« Last Edit: August 31, 2014, 06:21:51 PM by Goth77 »

Perhaps you could use a list?
Code: [Select]
registerOutputEvent("Bot", "setPetType", "list Beagle 0 Husky 1 Etc 2");
function AIPlayer::setPetType(%this, %image, %data)
{
   %imageList = "BeagleImage HuskyImage EtcImage";
   %player.mountImage(getWord(%imageList, %image), 1);
}

Perhaps you could use a list?
Code: [Select]
registerOutputEvent("Bot", "setPetType", "list Beagle 0 Husky 1 Etc 2");
function AIPlayer::setPetType(%this, %image, %data)
{
   %imageList = "BeagleImage HuskyImage EtcImage";
   %player.mountImage(getWord(%imageList, %image), 1);
}


Thanks. That did help a little bit but it seems the list isn't defined? I did what you said but the model image selected doesn't show and I am getting this in the console
Code: [Select]
getWord - wrong number of arguments.
usage: (string text, int index)
I do not know what this means D:

It means what it says, the wrong number of arguments were called. Be sure to use it in the same format that Pah1023 has, where's it's %player.mountImage(getWord(%imageList,%image),1); and be sure to note that getWord is using %imagelist and %image, where %imageList is a list of names, and %image is being used as a number as defined by the event.

Edit:
I almost forgot, you should add in %image++; because I don't think getWord(%sting,0); will work.
« Last Edit: September 01, 2014, 01:44:05 AM by Thorfin25 »

Edit:
I almost forgot, you should add in %image++; because I don't think getWord(%sting,0); will work.

getWord is zero indexed. getWord(%string, 0) will get you the first word. getWord(%string, N) will get you the (N-1)th word.

Thanks for the help everyone.

Topic Solved and Locked