Author Topic: How could I add and remove events from bricks via code? - Solved  (Read 1222 times)

/title

I want to add an event to a brick when something happens and delete said event when something else happens.
« Last Edit: March 25, 2016, 02:56:40 PM by Pastrey Crust »

There's a bunch of event related fields on the brick. Start by dumping a brick object and looking through them.

With your specific example, though, I'd just enable/disable the event, rather than adding and removing it.

I'd rather not have every brick placed in the world added those events while only ~5% will actually need it. Helps cut down save file size with the already massive terrain.

How would you want it to be removed? Index number of the event?

Yeah, I want to add

OnPlayerTouch -> Player -> Burn
OnPlayerTouch -> Player -> AddHealth [-5]

and then remove those later on.
« Last Edit: March 25, 2016, 02:56:03 PM by Pastrey Crust »

Look at the checkpoint add-on, it adds an event when it gets placed you can learn from that.

So this would be

Code: [Select]
%obj.enableTouch = true;
%obj.addEvent(true, 0, "OnPlayerTouch", "Player", "BurnPlayer");
%obj.addEvent(true, 0, "OnPlayerTouch", "Player", "AddHealth",-5);

But I don't see a removeEvent/deleteEvent by pressing TAB on the console. :S

AssHealth [-5]
where's that event, I can't find it anywhere

So this would be

Code: [Select]
%obj.enableTouch = true;
%obj.addEvent(true, 0, "OnPlayerTouch", "Player", "BurnPlayer");
%obj.addEvent(true, 0, "OnPlayerTouch", "Player", "AddHealth",-5);

But I don't see a removeEvent/deleteEvent by pressing TAB on the console. :S
Go ingame and place a brick. Use /getid on it and type it's ID.dump(); in the console to see all the functions it has. Pressing tab doesn't show functions like fxDTSBrick::addEvent()

where's that event, I can't find it anywhere
ah yes, typo

Go ingame and place a brick. Use /getid on it and type it's ID.dump(); in the console to see all the functions it has. Pressing tab doesn't show functions like fxDTSBrick::addEvent()
It does if you put the first letter of the function such as

fxDTSBrick::s
TAB
fxDTSBrick::setColor
TAB
fxDTSBrick::setEmitter
and so on.


Also it doesn't show up in a dump.
Code: [Select]
 addEvent() -
  addScheduledEvent() -
  call() -
  cancelEvents() -
  canExplode() - (maxVolume, maxFloatingVolume)
  chainTrustCheckDown() -
  ChainTrustCheckUp() -
  ChainTrustCheckVolume() -
  chainUndoTrustCheckDown() -
  ChainUndoTrustCheckUp() -
  clearAttributes() -
  clearEvents() -
  clearNTObjectName() -
  clearScopeToClient() - clearScopeToClient(%client)Undo the effects of a scopeToClient() call.
  colorVehicle() -
  copyAttributes() -
  decrementPrintCount() -
  delete() -
  disappear() -
  door() -
  doorClose() -
  doorOpen() -
  dump() - obj.dump()
  dumpDownList() - ()Dumps the upbrick list.
  dumpEvents() -
  dumpUpList() - ()Dumps the upbrick list.
  eventFloodCheck() -
  explode() -
  fakeKillBrick() -
  fireRelay() -
  fireRelayDown() -
  fireRelayEast() -
  fireRelayFromBox() -
  fireRelayNorth() -
  fireRelaySouth() -
  fireRelayUp() -
  fireRelayWest() -
  getAngleID() - ()
  getAttribute() -
  getClassName() - obj.getClassName()
  getColorFxID() - ()
  getColorID() - ()
  getDataBlock() - ()Return the datablock this fxBrickDB is using.
  getDestructionVolume() - ()
  getDistanceFromGround() - Returns number of connections away from the ground
  getDownBrick() - (int index)Returns up brick at given index.
  getExposedAreaBottom() - ()
  getExposedAreaEast() - ()
  getExposedAreaNorth() - ()
  getExposedAreaSouth() - ()
  getExposedAreaTop() - ()
  getExposedAreaWest() - ()
  getFakeDeadTime() - ()
  getForwardVector() - Returns a vector indicating the direction this object is facing.
  getGhostID() -
  getGroup() - obj.getGroup()
  getId() - obj.getId()
  getLightId() - obj.getLightId()
  getName() - obj.getName()
  getNumDownBricks() - ()Returns number of bricks in downlist.
  getNumUpBricks() - ()Returns number of bricks in downlist.
  getObjectBox() - Returns the bounding box relative to the object's origin.
  getPosition() - Get position of object.
  getPrintCount() -
  getPrintID() - ()
  getScale() - Get scaling as a Point3F.
  getShapeFxID() - ()
  getSpawnPoint() -
  getStack() -
  getTaggedField() - obj.getTaggedFieldCount(int idx)
  getTooFarDist() -
  getTransform() - Get transform of object.
  getType() - obj.getType()
  getUpBrick() - (int index)Returns up brick at given index.
  getUpVector() - Returns a vector indicating the relative upward direction of this object.
  getWorldBox() - Returns six fields, two Point3Fs, containing the min and max points of the worldbox.
  getWorldBoxCenter() - Returns the center of the world bounding box.
  hasFakePathToGround() - ()Returns true if brick is attached to a baseplate (considers blown-up bricks to be dead).
  hasPathToGround() - ()Returns true if brick is attached to a baseplate.
  incrementPrintCount() -
  isBasePlate() - ()
  isBlocked() -
  isColliding() - ()
  isDead() - ()
  iloveposed() - ()exposed = no bricks attached to one end
  isFakeDead() - ()
  isInSceneGraph() -
  isInTree() -
  isPlanted() - ()
  isRayCasting() - ()
  isRendering() - ()
  isTreeRendering() -
  killBrick() - ()removes brick and any floating children
  moveDuplication() -
  onactivate() -
  onAdd() -
  onBlownUp() -
  onCameraEnterOrbit() -
  onCameraLeaveOrbit() -
  onClearFakeDeath() -
  onColorChange() -
  onDeath() -
  onDisappear() -
  onDoorClose() -
  onDoorOpen() -
  onFakeDeath() -
  onLoad() -
  onLoadPlant() -
  onMinigameReset() -
  onPlant() -
  onPlayerTouch() -
  onPrintCountOverFlow() -
  onPrintCountUnderFlow() -
  onProjectileHit() -
  onReappear() -
  onRelay() -
  onRemove() -
  onRespawn() -
  onToolBreak() -
  plant() - ()
  plantedTrustCheck() -
  playSound() -
  processInputEvent() -
  radiusImpulse() -
  reappear() -
  recoverVehicle() -
  Respawn() -
  respawnvehicle() -
  restoreOrignalColors() -
  save() - obj.save(fileName, <selectedOnly>)
  saveDuplication() -
  schedule() - object.schedule(time, command, <arg1...argN>);
  scheduleNoQuota() - object.schedule(time, command, <arg1...argN>);
  scopeToClient() - (NetConnection %client)Cause the NetObject to be forced as scoped on the specified NetConnection.
  sendWrenchData() -
  sendWrenchSoundData() -
  sendWrenchVehicleSpawnData() -
  serializeEvent() -
  serializeEventToString() -
  setAttribute() -
  setColliding() - (bool val)
  setColor() - (int color)
  setColorFX() - (int colorFxID)
  setDatablock() -
  setDoorDataBlock() -
  setEmitter() -
  setEmitterDirection() -
  SetEventEnabled() -
  setItem() -
  setItemDirection() -
  setItemPosition() -
  setItemRespawnTime() -
  setLight() -
  setMusic() -
  setName() -
  setNTObjectName() -
  setPrint() - (int printID)
  setPrintCount() -
  setRayCasting() - (bool val)
  setRecolorVehicle() -
  setRendering() - (bool val)
  setScale() - (Point3F scale)
  setScopeAlways() - Always scope this object on all connections.
  setShapeFX() - (int shapeFxID)
  setSound() -
  setTrainLocked() -
  setTransform() -
  setTrusted() - (bool val)sets isTrusted value
  setVehicle() -
  setVehiclePowered() -
  spawnDuplication() -
  spawnExplosion() -
  spawnItem() -
  spawnProjectile() -
  spawnVehicle() -
  ToggleEventEnabled() -
  toSaveStr() -
  TrainMode() -
  TrainTurn() -
  TrustCheckFailed() -
  trustCheckFinished() -
  unColorVehicle() -
  undoTrustCheck() -
  vehicleMinigameEject() -
  willCauseChainKill() - () returns true if killing this brick will cause others to fall

nvm, clearEvents();

I'm pretty sure addEvent isn't a default function, always be aware of things like this. It helps to develop things with other add-ons disabled.

addEvent is in the Checkpoint brick and in the dump when I didn't have the checkpoint enabled so it's safe to say that it is.

I'm pretty sure addEvent isn't a default function, always be aware of things like this. It helps to develop things with other add-ons disabled.
It is.


wha
addevent exists??

...goddamnit i didn't actually have to manually add the variables to the brick wtf
that would have simplified the prop tool event support by a lot. oh well.