Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cyberhound sent this to a group chat in a file named 'myfailure.txt'. This is supposed to be a fly script converted to lua-c but he failed. This is a incomplete.
add_command(adminpower::modisterator, "fly", "fly ~ makes you fly", [](std::vector<std::string> args, std::string caller)->std::string {
if (!initiated_flying) {
initiated_flying = true;
rlua_getservice(r_L, "Players");
rlua_getfield(r_L, -1, "LocalPlayer");
rlua_getfield(r_L, -1, "Character");
rlua_getfield(r_L, -1, "Humanoid");
rlua_getfield(r_L, -1, "Died");
rlua_getfield(r_L, -1, "connect");
rlua_pushvalue(r_L, -2);
rlua_pushcfunction(r_L, flying_on_died);
rlua_pcall(r_L, 2, 1, 0);
rlua_emptystack(r_L);
rlua_getservice(r_L, "RunService");
rlua_getfield(r_L, -1, "Heartbeat");
rlua_getfield(r_L, -1, "connect");
rlua_pushvalue(r_L, -2);
rlua_pushcfunction(r_L, [](DWORD rL)->int {
if (is_flying) {
int step = rlua_tonumber(rL, 1);
rlua_getservice(rL, "game");
rlua_getfield(rL, -1, "Workspace");
rlua_getfield(rL, -1, "Camera");
rlua_getfield(rL, -1, "CFrame");
CFrame cam_cf = get_cframe(rL);
rlua_emptystack(rL);
rlua_getservice(rL, "game");
rlua_getfield(rL, -1, "Workspace");
rlua_getfield(rL, -1, "Camera");
rlua_getfield(rL, -1, "CFrame");
rlua_getfield(rL, -1, "ToEulerAnglesXYZ");
rlua_pushvalue(rL, -2);
rlua_pcall(rL, 1, 3, 0);
int y = rlua_tonumber(rL, -3);
int x = rlua_tonumber(rL, -2);
int z = rlua_tonumber(rL, -1);
rlua_getservice(rL, "Players");
rlua_getfield(rL, -1, "LocalPlayer");
rlua_getfield(rL, -1, "Character");
rlua_getfield(rL, -1, "PrimaryPart");
CFrame h_cf = get_cframe(rL);
rlua_emptystack(rL);
rlua_getservice(rL, "Players");
rlua_getfield(rL, -1, "LocalPlayer");
rlua_getfield(rL, -1, "Character");
rlua_getfield(rL, -1, "Humanoid");
}
return 0;
});
rlua_pcall(r_L, 2, 1, 0);
rlua_emptystack(r_L);
}
if (args.size() == 1) {
if (!is_flying) {
rlua_getservice(r_L, "Players");
rlua_getfield(r_L, -1, "LocalPlayer");
rlua_getfield(r_L, -1, "Character");
rlua_getfield(r_L, -1, "Head");
int aftrh = rlua_gettop(r_L);
rlua_getglobal(r_L, "Instance");
rlua_getfield(r_L, -1, "New");
rlua_pushstring(r_L, "BodyVelocity");
rlua_pushvalue(r_L, -4);
rlua_pcall(r_L, 2, 1, 0);
rlua_getfield(r_L, -1, "Velocity");
rlua_pushnumber(r_L, 0);
rlua_setfield(r_L, -2, "x");
rlua_pushnumber(r_L, 0);
rlua_setfield(r_L, -2, "y");
rlua_pushnumber(r_L, 0);
rlua_setfield(r_L, -2, "z");
rlua_pop(r_L, 1);
rlua_getfield(r_L, -1, "MaxForce");
rlua_pushnumber(r_L, 10000);
rlua_setfield(r_L, -2, "x");
rlua_pushnumber(r_L, 10000);
rlua_setfield(r_L, -2, "y");
rlua_pushnumber(r_L, 10000);
rlua_setfield(r_L, -2, "z");
rlua_pop(r_L, 1);
rlua_pushnumber(r_L, 1000);
rlua_setfield(r_L, -2, "P");
rlua_pop(r_L, rlua_gettop(r_L) - aftrh);
aftrh = rlua_gettop(r_L);
rlua_getglobal(r_L, "Instance");
rlua_getfield(r_L, -1, "New");
rlua_pushstring(r_L, "BodyAngularVelocity");
rlua_pushvalue(r_L, -4);
rlua_pcall(r_L, 2, 1, 0);
rlua_getfield(r_L, -1, "AngularVelocity");
rlua_pushnumber(r_L, 0);
rlua_setfield(r_L, -2, "x");
rlua_pushnumber(r_L, 0);
rlua_setfield(r_L, -2, "y");
rlua_pushnumber(r_L, 0);
rlua_setfield(r_L, -2, "z");
rlua_pop(r_L, 1);
rlua_getfield(r_L, -1, "MaxTorque");
rlua_pushnumber(r_L, 10000);
rlua_setfield(r_L, -2, "x");
rlua_pushnumber(r_L, 10000);
rlua_setfield(r_L, -2, "y");
rlua_pushnumber(r_L, 10000);
rlua_setfield(r_L, -2, "z");
rlua_pop(r_L, 1);
rlua_pushnumber(r_L, 1000);
rlua_setfield(r_L, -2, "P");
rlua_pop(r_L, rlua_gettop(r_L) - aftrh);
rlua_getservice(r_L, "Players");
rlua_getfield(r_L, -1, "LocalPlayer");
rlua_getfield(r_L, -1, "Character");
rlua_getfield(r_L, -1, "Humanoid");
rlua_pushboolean(r_L, true);
rlua_setfield(r_L, -2, "PlatformStand");
rlua_emptystack(r_L);
is_flying = true;
}
else {
rlua_getservice(r_L, "Players");
rlua_getfield(r_L, -1, "LocalPlayer");
rlua_getfield(r_L, -1, "Character");
rlua_getfield(r_L, -1, "Head");
int aftrh = rlua_gettop(r_L);
rlua_getfield(r_L, -1, "BodyVelocity");
rlua_getfield(r_L, -1, "Destroy");
rlua_pushvalue(r_L, -2);
rlua_pcall(r_L, 1, 0, 0);
rlua_pop(r_L, rlua_gettop(r_L) - aftrh);
rlua_getfield(r_L, -1, "BodyAngularVelocity");
rlua_getfield(r_L, -1, "Destroy");
rlua_pushvalue(r_L, -2);
rlua_pcall(r_L, 1, 0, 0);
rlua_getservice(r_L, "Players");
rlua_getfield(r_L, -1, "LocalPlayer");
rlua_getfield(r_L, -1, "Character");
rlua_getfield(r_L, -1, "Humanoid");
rlua_pushboolean(r_L, false);
rlua_setfield(r_L, -2, "PlatformStand");
rlua_emptystack(r_L);
is_flying = false;
}
}
else {
return "Error: Invalid argument count";
}
return "success";
});
bool is_flying = false;
bool initiated_flying = false;
int flying_on_died(DWORD rL) {
is_flying = false;
}
struct Vector3 {
int x, y, z, magnitude;
};
struct CFrame {
int x, y, z;
Vector3 lookvector, rightvector, upvector, position;
};
Vector3 get_vector(DWORD rL) {
Vector3 ret = Vector3();
rlua_getfield(rL, -1, "x");
ret.x = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "y");
ret.y = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "z");
ret.z = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "Magnitude");
ret.magnitude = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
}
CFrame get_cframe(DWORD rL) {
CFrame ret = CFrame();
rlua_getfield(rL, -1, "x");
ret.x = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "y");
ret.y = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "z");
ret.z = rlua_tonumber(rL, -1);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "LookVector");
ret.lookvector = get_vector(rL);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "RightVector");
ret.rightvector = get_vector(rL);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "UpVector");
ret.upvector = get_vector(rL);
rlua_pop(rL, 1);
rlua_getfield(rL, -1, "Position");
ret.position = get_vector(rL);
rlua_pop(rL, 1);
}
//sadness i was 2 lazy XDdDdDDDddd if ur slurpey just enjoy the code or whoever wants to take idc
@Cyberhound

This comment has been minimized.

Copy link

@Cyberhound Cyberhound commented Nov 22, 2018

lol not failed, but just I didn't want to complete it, I got confused after stoopid roblocaks functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment