Author Topic: candlelight script  (Read 976 times)

I made this the model of candlelight, and I wrote this script for key bind on/off toggle allow model unmount/mount on left hand and when active light on Press L on/off.



Code: [Select]

if (!$candlestick)
{
$remapDivision[$remapCount] = "candlestick";
$remapName[$remapCount] = "Action CandleStick";
$remapCmd[$remapCount] = "create button";
$remapCount++;
$candlestick = 1;
}
datablock ShapeBaseImageData(candlestickImage)
{
   shapeFile = "./CandleStick.dts";
   emap = true;

   mountPoint = 1;

   className = "ItemImage";
   item = BowItem;

   melee = false;
   armReady = false;
   
LightOn = true;
radius = 5;
brightness = 5;
color = "0.8 0.7 0.4 1";

FlareOn = false;
// FlareTP = true;
// Flarebitmap = "base/lighting/corona";
// FlareColor = "1 1 1";
// ConstantSizeOn = false;
// ConstantSize = 1;
// NearSize = 3;
// FarSize = 0.5;
// NearDistance = 10.0;
// FarDistance = 30.0;
// FadeTime = 0.1;
// BlendMode = 0;

AnimColor = false;
AnimBrightness = true;
AnimOffsets = false;
AnimRotation = false;
LinkFlare = false;
LinkFlareSize = false;
MinColor = "1 1 0";
MaxColor = "0 0 1";
MinBrightness = 0.0;
MaxBrightness = 5.0;
MinRadius = 0.1;
MaxRadius = 10;
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
MinRotation = 0;
MaxRotation = 359;

SingleColorKeys = false;
RedKeys = "AWTCFAH";
GreenKeys = "AWTCFAH";
BlueKeys = "AWTCFAH";

BrightnessKeys = "DEDEDFGF";
RadiusKeys = "AZAAAAA";
OffsetKeys = "AZAAAAA";
RotationKeys = "AZAAAAA";

ColorTime = 1.0;
BrightnessTime = 1.0;
RadiusTime = 1.0;
OffsetTime = 1.0;
RotationTime = 1.0;

LerpColor = false;
LerpBrightness = false;
LerpRadius = false;
LerpOffset = false;
LerpRotation = false;
textureName          = "base/data/particles/cloud";
dragCoefficient      = 1.0;
gravityCoefficient   = -7.0;
inheritedVelFactor   = 0.0;
windCoefficient      = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 200;
lifetimeVarianceMS   = 0;
spinSpeed     = 0;
spinRandomMin = -90.0;
spinRandomMax =  90.0;
useInvAlpha   = false;

colors[0] = "0.0 0.0 0.0 0.0";
colors[1] = "1   1   0.3 0.0";
colors[2] = "1   1   0.3 1.0";
colors[3] = "0.6 0.0 0.0 0.0";

sizes[0] = 0.0;
sizes[1] = 0.0;
sizes[2] = 0.09;
sizes[3] = 0.01;

times[0] = 0.0;
times[1] = 0.5;
times[2] = 0.51;
times[3] = 0.7;

   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   ejectionOffset   = 0.0;
   velocityVariance = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;

   //lifetimeMS = 5000;
   
//actionstuff

stateSequence[0] = "ready";

};

package Item_Candle_Stick
{
function serverCmdLight(%client)
{
   %player = %client.player;
   
   if(%player.getMountedImage(1) == 0)
      %player.mountImage(candlestickImage, 1);
   else if(%player.getMountedImage(1) == candlestickImage.getID())
      %player.unMountImage(1);
parent::serverCmdLight(%client);
}
activatePackage(Item_CandleStick);

Note: fire lite on the string top. I did name place at the string muzzlePoint. I use script light/Particle candle create by Kaje. and I put name mountPoint on the wax candle at bottom.

notice your "activatepackage(Item_candleStick)" and its not "activatepackage(Item_candle_stick)".

Is that the problem? I didn't see a question.

EDIT: what about that }; end bracket for the package?

notice your "activatepackage(Item_candleStick)" and its not "activatepackage(Item_candle_stick)".

Is that the problem? I didn't see a question.

EDIT: what about that }; end bracket for the package?
I am blind! it was under my nose whole time, lol I am going fix it.

EDIT: this not showed up on key bind.

Code: [Select]
if (!$candlestick)
{
$remapDivision[$remapCount] = "Tool Binds";
$remapName[$remapCount] = "CandleStick";
$remapCmd[$remapCount] = "serverCmdLight";
$remapCount++;
$candlestickServer::Binds = true;
}
« Last Edit: May 10, 2012, 07:17:06 PM by Cubelands »

I am blind! it was under my nose whole time, lol I am going fix it.

EDIT: this not showed up on key bind.

Code: [Select]
if (!$candlestick)
{
$remapDivision[$remapCount] = "Tool Binds";
$remapName[$remapCount] = "CandleStick";
$remapCmd[$remapCount] = "serverCmdLight";
$remapCount++;
$candlestickServer::Binds = true;
}

A few things
You are mixing up server sided and client sided code.  Item datablocks are server sided, but keybinds are client sided.  Also I don't think having the command for the keybind in multiple words like "create button" is valid.  You probably need a _ instead of a space.  Also, I don't see where you even have the function.  In this other keybind you have here, you are calling servercmdlight, which again is a server sided function that has a first argument of %client, and calling this keybind will set the first argument as either 0 or 1 depending on wether you are pressing the key or releasing.

On top of all that, I don't think you actually need to make a new keybind.  Using the existing light keybind should be fine.  Just stick to server sided code for this.

Also, if it doesn't show up at all, it might not have executed.  That syntax error computermix pointed out could be the cause.
« Last Edit: May 10, 2012, 07:49:47 PM by Nexus »

A few things
You are mixing up server sided and client sided code.  Item datablocks are server sided, but keybinds are client sided.  Also I don't think having the command for the keybind in multiple words like "create button" is valid.  You probably need a _ instead of a space.  Also, I don't see where you even have the function.  In this other keybind you have here, you are calling servercmdlight, which again is a server sided function that has a first argument of %client, and calling this keybind will set the first argument as either 0 or 1 depending on wether you are pressing the key or releasing.

On top of all that, I don't think you actually need to make a new keybind.  Using the existing light keybind should be fine.  Just stick to server sided code for this.

Also, if it doesn't show up at all, it might not have executed.  That syntax error computermix pointed out could be the cause.
Oh GOD! I am such idiot!
clinet.cs = for key bind
Server.cs = for script candle stuff
Do you think this will work or not?
« Last Edit: May 10, 2012, 07:56:53 PM by Cubelands »

Ok, among other things, he wants one keybind to makethe player hold the candle (which I would assume to work a lot like the Sit emote, for example; keybind it if you have it)
And it might, I'm workin on it but it'll take me a day or two

Cubelands, just package ServerCmdLight(%client)
« Last Edit: May 10, 2012, 10:48:16 PM by Treynolds416 »

I got this Syntax error.

Code: [Select]
dd-Ons/Item_Candle_Stick/server.cs Line: 125 - Syntax error.
>>> Some error context, with ## on sides of error halt:

package ServerCmdLight(##%##client)

{

^function serverCmdLight(%client)

^{

   %player = %client.player;

   

   if(%player.getMountedImage(1) == 0)

      %player.mountImage(candlestickImage, 1);

   else if(%player.getMountedImage(1) == candlestickImage.getID())

      %player.unMountImage(1);

Code: [Select]
package Candle
{
    function ServerCmdLight(%client)
    {
        //Code here
    }
};
activatePackage(Candle)

I changed some client script, remove server lines. I almost got it. I still not understand why key binds still not showed up, It should be worked.

Code: [Select]
if(!$candlestick::Binds)
{
$remapDivision[$remapCount] = "Tooggle CandleStick";
$remapName[$remapCount] = "Toggle On/Off";
$remapCmd[$remapCount] = "togglecandlestick";
$remapCount++;
$candlestick::Binds = 1;
}
activatepackage(candle);
datablock ShapeBaseImageData(candlestickImage)
{
   shapeFile = "./CandleStick.dts";
   emap = true;

   mountPoint = 1;

   className = "ItemImage";
   item = BowItem;

   melee = false;

   
LightOn = true;
radius = 5;
brightness = 5;
color = "0.8 0.7 0.4 1";

FlareOn = false;
// FlareTP = true;
// Flarebitmap = "base/lighting/corona";
// FlareColor = "1 1 1";
// ConstantSizeOn = false;
// ConstantSize = 1;
// NearSize = 3;
// FarSize = 0.5;
// NearDistance = 10.0;
// FarDistance = 30.0;
// FadeTime = 0.1;
// BlendMode = 0;

AnimColor = false;
AnimBrightness = true;
AnimOffsets = false;
AnimRotation = false;
LinkFlare = false;
LinkFlareSize = false;
MinColor = "1 1 0";
MaxColor = "0 0 1";
MinBrightness = 0.0;
MaxBrightness = 5.0;
MinRadius = 0.1;
MaxRadius = 10;
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
MinRotation = 0;
MaxRotation = 359;

SingleColorKeys = false;
RedKeys = "AWTCFAH";
GreenKeys = "AWTCFAH";
BlueKeys = "AWTCFAH";

BrightnessKeys = "DEDEDFGF";
RadiusKeys = "AZAAAAA";
OffsetKeys = "AZAAAAA";
RotationKeys = "AZAAAAA";

ColorTime = 1.0;
BrightnessTime = 1.0;
RadiusTime = 1.0;
OffsetTime = 1.0;
RotationTime = 1.0;

LerpColor = false;
LerpBrightness = false;
LerpRadius = false;
LerpOffset = false;
LerpRotation = false;
textureName          = "base/data/particles/cloud";
dragCoefficient      = 1.0;
gravityCoefficient   = -7.0;
inheritedVelFactor   = 0.0;
windCoefficient      = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 200;
lifetimeVarianceMS   = 0;
spinSpeed     = 0;
spinRandomMin = -90.0;
spinRandomMax =  90.0;
useInvAlpha   = false;

colors[0] = "0.0 0.0 0.0 0.0";
colors[1] = "1   1   0.3 0.0";
colors[2] = "1   1   0.3 1.0";
colors[3] = "0.6 0.0 0.0 0.0";

sizes[0] = 0.0;
sizes[1] = 0.0;
sizes[2] = 0.09;
sizes[3] = 0.01;

times[0] = 0.0;
times[1] = 0.5;
times[2] = 0.51;
times[3] = 0.7;

   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   ejectionOffset   = 0.0;
   velocityVariance = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;

   //lifetimeMS = 5000;
   
//actionstuff

stateSequence[0] = "ready";

};
deactivatepackage(candle);

function togglecandlestick(%client)
{
   %player = %client.player;
   
   if(%player.getMountedImage(1) == 0)
      %player.mountImage(candlestickImage, 1);
  $candle::On = true;
  armReady = true;
  clientcmdcenterPrint("\c6CandleStick Mount to left hand (active light, Press L)", 2);
   else if(%player.getMountedImage(1) == candlestickImage.getID())
      %player.unMountImage(1);
  parent::ClientCmdLight(%client);
  $candle::On = false;
  armReady = false;
  clientcmdcenterPrint("\c6CandleStick Unmout from left hand.", 2);
}
}

I got Syntax error line
armReady = true;
%player.unMountImage(1);
armReady = false;
« Last Edit: May 11, 2012, 03:26:05 AM by Cubelands »

You cannot use keybinds in that code. We tell you things for a goddamn reason, you need to loving listen.

You cannot use keybinds in that code. We tell you things for a goddamn reason, you need to loving listen.
fine, I am going lock it.
No, unlock the thread, and try reading for once
« Last Edit: May 11, 2012, 07:04:51 AM by Cubelands »

part 1 code
Code: [Select]
if(!$Asciify::Binds)
{
$remapDivision[$remapCount]="Chat Asciifyer";
$remapName[$remapCount]="Toggle On/Off";
$remapCmd[$remapCount]="toggleAscii";
$remapCount++;
$Asciify::Binds=1;
}

function asciify(%str)
{
for(%a=0;%a<strLen(%str);%a++)
{
%letter = getSubStr(%str, %a, 1);
%letter[%a] = strReplace(%letter, "C", "Ç");
%letter[%a] = strReplace(%letter[%a], "c", "ç");
%letter[%a] = strReplace(%letter[%a], "u", getSubStr("üûùú", getRandom(0,3),1));
%letter[%a] = strReplace(%letter[%a], "U", "Ü");
%letter[%a] = strReplace(%letter[%a], "e", getSubStr("éêëè", getRandom(0,3),1));
%letter[%a] = strReplace(%letter[%a], "E", "É");
%letter[%a] = strReplace(%letter[%a], "a", getSubStr("âäàåá", getRandom(0,4), 1));
%letter[%a] = strReplace(%letter[%a], "A", getSubStr("ÄÅ", getRandom(0,1), 1));
%letter[%a] = strReplace(%letter[%a], "o", getSubStr("ôöòó", getRandom(0,3), 1));
%letter[%a] = strReplace(%letter[%a], "O", "Ö");
%letter[%a] = strReplace(%letter[%a], "i", getSubStr("íïîì", getRandom(0,3), 1));
%letter[%a] = strReplace(%letter[%a], "I", "î");
%letter[%a] = strReplace(%letter[%a], "f", "ƒ");
%letter[%a] = strReplace(%letter[%a], "F", "ƒ");
%letter[%a] = strReplace(%letter[%a], "n", "ñ");
%letter[%a] = strReplace(%letter[%a], "N", "Ñ");
if(getRandom(0, 1) == 1)
%letter[%a] = strReplace(%letter[%a], "?", "¿");
if(getRandom(0, 1) == 1)
%letter[%a] = strReplace(%letter[%a], "!", "¡");
%letter[%a] = strReplace(%letter[%a], "<", "«");
%letter[%a] = strReplace(%letter[%a], ">", "»");
%stri = %stri @ %letter[%a];
}
return %stri;
}

deactivatepackage(asciify);
package asciify
{
function nmh_type::send(%this)
{
%val = %this.getValue();
if($asciify::on && strPos(%val, "http://") == -1 && getSubStr(%val, 0, 1) !$= "/")
{
%asciifyed = asciify(%val);
%this.setValue(%asciifyed);
}
parent::send(%this);
}
};
activatepackage(asciify);

function toggleAscii(%a)
{
if(!%a)
return;
if($asciify::On)
{
$asciify::On = false;
clientcmdcenterPrint("\c6Ascii chat disabled.", 2);
}
else
{
$asciify::On = true;
clientcmdcenterPrint("\c6Ascii chat enabled.", 2);
}
}
part 2 code
Code: [Select]
datablock ItemData(FlashlightItem)
{
category = "Item";
className = "Item";

image = FlashlightImage;
canDrop = false;
};

datablock ShapeBaseImageData(FlashlightImage)
{
   shapeFile = "./flashlight.dts";
   emap = true;

   mountPoint = 1;

   className = "ItemImage";
   item = BowItem;

   melee = false;
   armReady = false;
  
   lightType = "ConstantLight";
   lightColor = "1 1 1 1";
   LightTime = "1000";
   lightRadius = "8";

//actionstuff

stateSequence[0] = "ready";

};

function serverCmdFlashlight(%client)
{
   %player = %client.player;
  
   if(%player.getMountedImage(1) == 0)
      %player.mountImage(flashLightImage, 1);
   else if(%player.getMountedImage(1) == flashLightImage.getID())
      %player.unMountImage(1);
}

//Oh hey, you actually read the script. Hows things going over there? I hope its swell.
//Love and kisses, IceBlue.
part 3 code
Code: [Select]
package Vehicle_BlockoSedan
{
function serverCmdLight(%client)
{
if(isObject(%client.player) && !isObject(%client.player.light))
{
%player = %client.player;
%veh = %player.getControlObject();
if(isObject(%veh))
if(%veh.getDatablock() == BlockoSedanPoliceVehicle.getID())
{
%veh.useSiren = !%veh.useSiren;
return "";
}
}
parent::serverCmdLight(%client);
}
function Vehicle::setNodeColor(%this,%node,%color)
{
parent::setNodeColor(%this,%node,%color);
if(%this.getDatablock() == BlockoSedanPoliceVehicle.getID() && %node $= "ALL")
{
%r = getWord(%color,0);
%g = getWord(%color,1);
%b = getWord(%color,2);
%lowest = 1;
for(%a = 0; %a < 3; %a++)
{
%val = getWord(%color,%a);
if(%val > %highest)
%highest = %val;
if(%val < %lowest)
%lowest = %val;
}
%average = atof(%r) + atof(%g) + atof(%b);
%average /= 3;
%sat = %highest - %lowest;
if(%sat < 0.1 && %average > 0.25)
%sidePanel = "0 0 0.5 1.0";
else
%sidePanel = "0.9 0.9 0.9 1.0";
%this.setNodeColor("sidepanel",%sidePanel);
}
}
};
activatePackage(Vehicle_BlockoSedan);
which i want use the code?
Code: [Select]
if(!$Asciify::Binds)
{
$remapDivision[$remapCount]="Chat Asciifyer";
$remapName[$remapCount]="Toggle On/Off";
$remapCmd[$remapCount]="toggleAscii";
$remapCount++;
$Asciify::Binds=1;
}

Code: [Select]
function serverCmdFlashlight(%client)
{
   %player = %client.player;
  
   if(%player.getMountedImage(1) == 0)
      %player.mountImage(flashLightImage, 1);
   else if(%player.getMountedImage(1) == flashLightImage.getID())
      %player.unMountImage(1);
}
Code: [Select]
above rest the 3rd codeother my link
1.http://forum.blockland.us/index.php?topic=193853.0
2.http://forum.blockland.us/index.php?topic=193849.0
I been hard work on this.
EDIT: My plan make this one keybind to make the player hold the candle(mount/unmount) and press L for on/off on left hand.
« Last Edit: May 11, 2012, 07:22:10 AM by Cubelands »

Use that flashlight code, like I told you. Don't have any other code about binds

Use that flashlight code, like I told you. Don't have any other code about binds
fine, I need fix the emitter and model. I posted the link above.