Author Topic: General Coding Questions (Floating Text, Getting Brick Position, Ect.) [Solved]  (Read 1738 times)

I have a few things I need to do for my gamemode.

1 of them is having text float in front of a door like how Conan's DPS meter looks https://forum.blockland.us/index.php?topic=312375.0

I also need to know the position of a brick in game so I can teleport players to that position.

I also need to know where I player leaves a zone / enters a zone at a given position so I can determine their location (inside, outside).
« Last Edit: December 17, 2017, 02:16:31 PM by rggbnnnnn »

I also need to know the position of a brick in game so I can teleport players to that position.
it should be something like %brick.position

it should be something like %brick.position
%brick.getTransform();

for teleporting players I recommend using event - doPlayerTeleport

for brick text use this

as for zones, you can use the zone events and use onPlayerEnterZone and onPlayerLeaveZone

Hope this helps, cheers!

%brick.getTransform(), %brick.getPosition(), and iirc %brick.position all work for getting a brick's world position. it will be at the center of the brick bounds.

the text on my DPS meter is %item.setShapeName("something"); put somewhere after the item spawns. its hovering over the item.

leaving/entering zones requires you to create a zone datablock, the creating zone instances and writing functions to catch calls to things like onEnterZone, onLeaveZone, etc.

for teleporting players I recommend using event - doPlayerTeleport

for brick text use this

as for zones, you can use the zone events and use onPlayerEnterZone and onPlayerLeaveZone

he said coding help you twinkie

he said coding help you twinkie
he could still dive into the code of those add-ons and figure out how they work so he can use the code from them

zones

trigger datablock
Code: [Select]
datablock TriggerData(Bounds_Trigger)
{
   tickPeriodMS = 50;
};
tickPeriodMS specifies how often it checks for updates on player positions

code for entering and leaving triggers
Code: [Select]
function Bounds_Trigger::onEnterTrigger(%db,%trig,%pl)
{
parent::onEnterTrigger(%db,%trig,%pl);
}

function Bounds_Trigger::onLeaveTrigger(%db,%trig,%pl)
{
parent::onLeaveTrigger(%db,%trig,%pl);
}

every tick of the trigger any player inside will call this function
Code: [Select]
function Bounds_Trigger::onTickTrigger(%db,%trig,%pl)
{
parent::onTickTrigger(%db,%trig,%pl);
}


code to create a trigger the same position and dimensions of a brick
Code: [Select]
function fxDtsBrick::createTrigger(%this,%data,%polyhedron)
{
if(%polyhedron $= "")
%polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";

if(isObject(%this.trigger))
%this.trigger.delete();

%t = new Trigger()
{
datablock = %data;
polyhedron = %polyhedron;
};
missionCleanup.add(%t);

%boxMax = getWords(%this.getWorldBox(), 3, 5);
%boxMin = getWords(%this.getWorldBox(), 0, 2);
%boxDiff = vectorSub(%boxMax,%boxMin);
%boxDiff = vectorAdd(%boxDiff,"0 0 0.2");
%t.setScale(%boxDiff);
%posA = %this.getWorldBoxCenter();
%posB = %t.getWorldBoxCenter();
%posDiff = vectorSub(%posA, %posB);
%posDiff = vectorAdd(%posDiff, "0 0 0.1");
%t.setTransform(%posDiff);

%this.trigger = %t;
%t.brick = %this;

return %t;
}

Alright, thanks. Locking.