Blockland Forums > Modification Help
OnPlayerWithItemTouch?
<< < (3/4) > >>
::Matt:::
Sorry meant to quote this...


--- Quote from: Space Guy on February 02, 2011, 04:48:38 PM ---To be able to pick an item type you'd need something like this which doesn't exist in the game yet.

--- End quote ---
Space Guy:

--- Quote from: ::Matt:: on February 03, 2011, 09:14:30 AM ---Sorry meant to quote this...


--- End quote ---
If you're looking for "on player with a specific item you're making - touch", that is possible.

If you're looking for an event which lets you pick an item out of any that exist on the server, it's not possible yet. Truce was making something like that idea I posted but stopped working on it about a year ago...
Truce:

--- Quote from: Space Guy on February 03, 2011, 12:22:50 PM ---Truce was making something like that idea I posted but stopped working on it about a year ago...

--- End quote ---

http://forum.blockland.us/index.php?topic=94935.0

I know I had a reason I stopped working on it, but I can't remember what it was, since this was from the end of 2009. I'm pretty sure I got it working though - it was probably just some optimization I was too lazy to put in (I made the mod during a long car ride). Anyway, I still have the files, so if someone wants to play around with it, touch it up, and release it, then be my guest:


--- Code: (server.cs) ---function registerInputParameter(%inputEvent,%parameters,%callback)
{
if(!isObject(InputParameters_ServerList))
new SimGroup(InputParameters_ServerList);

if(strPos("\tdatablock\tlist\tstring\tint\t","\t" @ getWord(%parameters,0) @ "\t") == -1)
return;

%entry = hasInputParameter_Server(%inputEvent);

if(%entry != -1)
InputParameters_ServerList.remove(%entry);

%entry = new ScriptObject()
{
inputEvent = %inputEvent;
parameters = %parameters;
callback = %callback;
};

InputParameters_ServerList.add(%entry);
}

function hasInputParameter_Server(%inputEvent)
{
if(!isObject(InputParameters_ServerList))
return -1;

for(%i = 0; %i < InputParameters_ServerList.getCount(); %i++)
{
%entry = InputParameters_ServerList.getObject(%i);

if(%entry.inputEvent $= %inputEvent)
return %entry;
}

return -1;
}

function serverCmdRequestInputParameters(%client)
{
commandToClient(%client,'clearInputParameters');

if(!isObject(InputParameters_ServerList))
return;

for(%i = 0; %i < InputParameters_ServerList.getCount(); %i++)
{
%entry = InputParameters_ServerList.getObject(%i);
commandToClient(%client,'registerInputParameter',%entry.inputEvent,%entry.parameters);
}
}

function serverCmdAddInputParameter(%client,%index,%parameter)
{
%brick = %client.wrenchBrick;

if(isObject(%brick))
%brick.eventInputParameter[%index] = %parameter;
}

package InputParameters_Server
{
function serverCmdRequestWrenchEvents(%client)
{
Parent::serverCmdRequestWrenchEvents(%client);
%brick = %client.wrenchBrick;

for(%i = 0; %i < %brick.numEvents; %i++)
{
%inputParameter = %brick.eventInputParameter[%i];

if(%inputParameter !$= "")
commandToClient(%client,'addInputParameter',%i,%inputParameter);
}
}

function fxDTSBrick::processInputEvent(%this,%inputEvent,%client)
{
for(%i = 0; %i < %this.numEvents; %i++)
{
%event = %this.serializeEvent(%i);
%input = getField(%event,1);

if(!getField(%event,0) || $InputEvent_Name["fxDTSBrick",%input] !$= %inputEvent)
continue;

%callback = hasInputParameter_Server(%inputEvent).callback;

if(isFunction(%callback))
{
if(!call(%callback,%this,%this.eventInputParameter[%i],%client))
continue;
}

%string = ".schedule(" @ getField(%event,2) @ ",";
%target = getField(%event,3);

if(%target == -1)
{
%class = "fxDTSBrick";

%group = %this.getGroup();
%index = getField(%event,4);
%name = %group.NTName[%index];

%targetList = "";

for(%j = 0; %j < %group.NTObjectCount[%name]; %j++)
%targetList = %targetList @ %group.NTObject[%name,%j] @ "\t";

%targetList = getSubStr(%targetList,0,strLen(%targetList) - 1);
}
else
{
%class = inputEvent_GetTargetClass("fxDTSBrick",%input,%target);

for(%j = 0; %j < getFieldCount($InputEvent_TargetList["fxDTSBrick",%input]); %j++)
{
%field = getField($InputEvent_TargetList["fxDTSBrick",%input],%j);

if(getWord(%field,1) $= %class)
{
%targetList = $InputTarget_[getWord(%field,0)];
break;
}
}
}

%output = getField(%event,5);
%string = %string @ "\"" @ $OutputEvent_Name[%class,%output] @ "\",";

for(%j = 0; %j < outputEvent_GetNumParametersFromIdx(%class,%output); %j++)
%string = %string @ "\"" @ getField(%event,6 + %j) @ "\",";

if($OutputEvent_AppendClient[%class,%output])
%string = %string @ "1,";

%string = getSubStr(%string,0,strLen(%string) -1) @ ");";

for(%j = 0; %j < getFieldCount(%targetList); %j++)
{
%eval = getField(%targetList,%j) @ %string;

echo(%eval);
eval(%eval);
}
}
}
};
activatePackage(InputParameters_Server);

--- End code ---


--- Code: (client.cs) ---package InputParameters_Client
{
function WrenchEventsDlg::reshuffleScrollbox(%this,%swatch)
{
%object = %swatch.inputParameter;

if(isObject(%object))
%object.delete();

Parent::reshuffleScrollbox(%this,%swatch);
}

function WrenchEventsDlg::createTargetList(%this,%swatch,%box)
{
Parent::createTargetList(%this,%swatch,%box);

%object = %swatch.inputParameter;

if(isObject(%object))
%object.delete();

if(!isObject(InputParameters_ClientList))
return;

%input = %box.getValue();
%parameters = hasInputParameter_Client(%input).parameters;

if(%parameters $= "")
return;

switch$(getWord(%parameters,0))
{
case "datablock":
%object = InputParameters_NewPopup(getWord(%swatch.getPosition(),1) + 19);
%dataClass = getWord(%parameters,1);

for(%i = 0; %i < DatablockGroup.getCount(); %i++)
{
%datablock = DatablockGroup.getObject(%i);
%uiName = %datablock.uiName;

if(%datablock.getClassName() $= %dataClass && %uiName !$= "")
%object.add(%uiName,%datablock);
}

%object.sort();
%object.addFront("NONE",-1);

%object.setSelected(-1);

case "list":
%object = InputParameters_NewPopup(getWord(%swatch.getPosition(),1) + 19);

for(%i = 1; %i < getWordCount(%parameters); %i += 2)
%object.add(getWord(%parameters,%i),getWord(%parameters,%i + 1));

%object.setSelected(0);

case "string":
%object = InputParameters_NewTextbox(getWord(%swatch.getPosition(),1) + 19);
%object.maxLength = getWord(%parameters,1);

%object.setValue(getWords(%parameters,2));

case "int":
%min = getWord(%parameters,1);
%object = InputParameters_NewTextbox(getWord(%swatch.getPosition(),1) + 19);
%object.command = "$ThisControl.setText(mClamp($ThisControl.getValue()," @ %min @ "," @ getWord(%parameters,2) @ "));";

%default = getWords(%parameters,3);

if(%default $= "")
%object.setValue(%min);
else
%object.setValue(%default);
}

%swatch.inputParameter = %object;
WrenchEvents_Scroll.add(%object);
}

function WrenchEventsDlg::send(%this)
{
Parent::send(%this);

for(%i = 0; %i < WrenchEvents_Box.getCount() - 1; %i++)
{
%parameter = WrenchEvents_Box.getObject(%i).inputParameter;

if(isObject(%parameter))
{
switch$(%parameter.getClassName())
{
case "GuiPopUpMenuCtrl":
commandToServer('addInputParameter',%i,%parameter.getSelected());

case "GuiTextEditCtrl":
commandToServer('addInputParameter',%i,%parameter.getValue());
}
}
else
commandToServer('addInputParameter',%i,"");
}
}
};
activatePackage(InputParameters_Client);

function hasInputParameter_Client(%inputEvent)
{
if(!isObject(InputParameters_ClientList))
return -1;

for(%i = 0; %i < InputParameters_ClientList.getCount(); %i++)
{
%entry = InputParameters_ClientList.getObject(%i);

if(%entry.inputEvent $= %inputEvent)
return %entry;
}

return -1;
}

function clientCmdClearInputParameters()
{
if(isObject(InputParameters_ClientList))
InputParameters_ClientList.clear();
}

function clientCmdRegisterInputParameter(%inputEvent,%parameters)
{
if(!isObject(InputParameters_ClientList))
new SimGroup(InputParameters_ClientList);

%entry = hasInputParameter_Client(%inputEvent);

if(%entry != -1)
InputParameters_ClientList.remove(%entry);

%entry = new ScriptObject()
{
inputEvent = %inputEvent;
parameters = %parameters;
};

InputParameters_ClientList.add(%entry);
}

function clientCmdAddInputParameter(%index,%parameter)
{
%object = WrenchEvents_Box.getObject(%index).inputParameter;

switch$(%object.getClassName())
{
case "GuiPopUpMenuCtrl":
%object.setSelected(%parameter);

case "GuiTextEditCtrl":
%object.setValue(%parameter);
}
}

function InputParameters_NewPopup(%y)
{
%object = new GuiPopUpMenuCtrl()
{
profile        = "GuiPopUpMenuProfile";
horizSizing    = "right";
vertSizing     = "bottom";
position       = "76 " @ %y;
extent         = "100 18";
minExtent      = "8 2";
visible        = 1;
maxLength      = 255;
maxPopupHeight = 200;
};

return %object;
}

function InputParameters_NewTextbox(%y,%command)
{
%object = new GuiTextEditCtrl()
{
profile        = "GuiTextEditProfile";
horizSizing    = "right";
vertSizing     = "bottom";
position       = "76 " @ %y;
extent         = "100 18";
minExtent      = "8 2";
visible        = 1;
maxLength      = 255;
};

return %object;
}

--- End code ---


--- Code: (example.cs) ---function Check_onProjectileHit(%brick,%parameter,%client)
{
return (%parameter $= "" || %parameter == -1 || $InputTarget_["Projectile"].getDatablock() == %parameter);
}

registerInputParameter("onProjectileHit","datablock ProjectileData","Check_onProjectileHit");

--- End code ---
NiXiLL:

--- Quote from: Truce on February 03, 2011, 12:43:05 PM ---http://forum.blockland.us/index.php?topic=94935.0

I know I had a reason I stopped working on it, but I can't remember what it was, since this was from the end of 2009. I'm pretty sure I got it working though - it was probably just some optimization I was too lazy to put in (I made the mod during a long car ride). Anyway, I still have the files, so if someone wants to play around with it, touch it up, and release it, then be my guest:

-megasnipofdoom-


--- End quote ---
Don't you get like, really nauseous when you do this?
I wouldn't be able to do it. D:
::Matt:::

--- Quote from: Truce on February 03, 2011, 12:43:05 PM ---http://forum.blockland.us/index.php?topic=94935.0

I know I had a reason I stopped working on it, but I can't remember what it was, since this was from the end of 2009. I'm pretty sure I got it working though - it was probably just some optimization I was too lazy to put in (I made the mod during a long car ride). Anyway, I still have the files, so if someone wants to play around with it, touch it up, and release it, then be my guest:


--- Code: (server.cs) ----snip-

--- End code ---

--- End quote ---

Wow this is pretty hardcore. I'll see if I can mess around with it a little.
I just looked through the server, is there anywhere in it I need a

--- Code: ---exec("./client.cs");
--- End code ---
Navigation
Message Index
Next page
Previous page

Go to full version