Author Topic: Output Event Help [Solved by Treynolds]  (Read 653 times)

How would I make an output event have a list of the name variables of all the sim objects that are in a sim set?
« Last Edit: July 05, 2012, 12:39:18 PM by jes00 »

if the list is changing at all, the short answer is you can't

If it is a static list, it should be straightforward.  Copy the syntax out of some other output event that uses lists

I think it looks something like

0 defaultoption 1 nextoption 2 yetanotheroption

etc

if the list is changing at all, the short answer is you can't

If it is a static list, it should be straightforward.  Copy the syntax out of some other output event that uses lists

I think it looks something like

0 defaultoption 1 nextoption 2 yetanotheroption

etc
I was wondering if there is a less tiresome way to do it. For example the addItem event uses registerOutputEvent("Player", "addItem", "datablock ItemData", 1);

I attached some pics of my objects.

You could just make that string more easily and put it in the event

Code: [Select]
%count = %set.getCount();
for(%i=0;%i<%count,%i++)
    %str = %str SPC %i SPC %count.getObject(%i)
%str = trim(%str);

Code: [Select]
$FRPG::ShopDumb = "list";

for(%i = 0; %i < FRPG_Items.getCount(); %i++)
{
%obj = FRPG_Items.getObject(%i);

$FRPG::ShopDumb = $FRPG::ShopDumb SPC %obj.name SPC %i;
}

echo("\c2$FRPG::ShopDumb:" SPC $FRPG::ShopDumb);

registerOutputEvent("GameConnection", "addToShop", $FRPG::ShopDumb, 1);
It echos $FRPG::ShopDumb: list Oak Bow 0 Willow Bow 1 Maple Bow 2 Yew Bow 3 Moonwell Bow 4

And then below that it says:
WARNING: list has odd number of arguments on class:GameConnection, event:addToShop
BackTrace: ->SM_StartMission->createServer->onServerCreated->loadAddOns->registerOutputEvent->verifyOutputParameterList

And then the list looks like the attached.

How do I fix this?

EDIT: It works if I do the following but is there any way they can have spaces instead of using _ ?
Code: [Select]
$FRPG::ShopDumb = "list";

for(%i = 0; %i < FRPG_Items.getCount(); %i++)
{
%obj = FRPG_Items.getObject(%i);
%name = strReplace(%obj.name, " ", "_");

$FRPG::ShopDumb = $FRPG::ShopDumb SPC %name SPC %i;
}

echo("\c2$FRPG::ShopDumb:" SPC $FRPG::ShopDumb);

registerOutputEvent("GameConnection", "addToShop", $FRPG::ShopDumb, 1);
« Last Edit: July 05, 2012, 09:30:23 AM by jes00 »

Does registerOutputEvent accept tab-delimited lists?

Unfortunately, as far as I know, no.

Use this line of code (copy-paste it or it won't work:)
Code: [Select]
%val = strReplace(%val, " ", " ");

You can replace the %val with whatever, but if you touch the spaces you'll have to copy it back again.
It replaces the default space with the no-break space, which isn't registered as a new element in event parameters.

EDIT:
Code: [Select]
$FRPG::ShopDumb = "list";

for(%i = 0; %i < FRPG_Items.getCount(); %i++)
{
%obj = FRPG_Items.getObject(%i);

$FRPG::ShopDumb = $FRPG::ShopDumb SPC strReplace(%obj.name, " ", " ") SPC %i;
}

echo("\c2$FRPG::ShopDumb:" SPC $FRPG::ShopDumb);

registerOutputEvent("GameConnection", "addToShop", $FRPG::ShopDumb, 1);

Unfortunately, as far as I know, no.

Use this line of code (copy-paste it or it won't work:)
Code: [Select]
%val = strReplace(%val, " ", " ");

You can replace the %val with whatever, but if you touch the spaces you'll have to copy it back again.
It replaces the default space with the no-break space, which isn't registered as a new element in event parameters.

EDIT:
Code: [Select]
$FRPG::ShopDumb = "list";

for(%i = 0; %i < FRPG_Items.getCount(); %i++)
{
%obj = FRPG_Items.getObject(%i);

$FRPG::ShopDumb = $FRPG::ShopDumb SPC strReplace(%obj.name, " ", " ") SPC %i;
}

echo("\c2$FRPG::ShopDumb:" SPC $FRPG::ShopDumb);

registerOutputEvent("GameConnection", "addToShop", $FRPG::ShopDumb, 1);
It counted it as just a normal space for some reason.

It counted it as just a normal space for some reason.

If you're using any form of IDE it may automatically 'fix' copied text to fit its own format. This might include changing no-break spaces 'back' to regular spaces.