Jump to content

How can I make a multi line string sing lined?

HealthyMindFresh

Hi,

So I am working on this app that can execute scripts into this game but the scripts are usually multi lined and I was wondering how I could fit them into a single line string. Most people seem to use \n or \r\n but they do not seem to work for me. Can anyone help?

Link to comment
Share on other sites

Link to post
Share on other sites

30 minutes ago, HealthyMindFrsh YouTube said:

Hi,

So I am working on this app that can execute scripts into this game but the scripts are usually multi lined and I was wondering how I could fit them into a single line string. Most people seem to use \n or \r\n but they do not seem to work for me. Can anyone help?

what is the game ? the scripting engine should have all the details about newline characters

Link to comment
Share on other sites

Link to post
Share on other sites

On 12/19/2018 at 8:31 PM, M.Yurizaki said:

\n and \r are the new line characters. If removing them isn't working, i.e., the string is still multi-line, then the routine probably isn't stripping them correctly or someone decided t be fancy and use some other delimiter.

I don't think I worded it out correctly but when I copy and paste someone else's script which uses \r\n or \n, it seems to work but when I do it with a custom script myself it does not work

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, HealthyMindFrsh YouTube said:

I don't think I worded it out correctly but when I copy and paste someone else's script which uses \r\n or \n, it seems to work but when I do it with a custom script myself it does not work

Do you have a snippet of the code and what you're using for the input?

Link to comment
Share on other sites

Link to post
Share on other sites

On 12/21/2018 at 2:55 PM, M.Yurizaki said:

Do you have a snippet of the code and what you're using for the input?

I don't know what you mean by input (I am very amateur and rely on dll's to do my work for me lol) but here is an example

this.api.SendLimitedLua("game.Workspace.Gravity = 5");

That is what I do but when I try to do something like this and put it into the "":

("getglobal game\ngetfield -1 Players\ngetfield -1 LocalPlayer\ngetfield -1 ChangeMoney\ngetfield -1 Fire\npushvalue -2\npushnumber 2000000000\npcall 2 1 0")

(got that off someone's source code) it does work but when I do it myself:

--Original Code
findCar()
myCar.Handling.MaxSpeed.Value = 10000
myCar.Handling.Torque.Value = 40000
myCar.Handling.SteeringRadiusConstant.Value = 15000
myCar.Handling.FrictionRoad.Value = 250
myCar.Handling.Nitro.NitroSpeed.Value = 500
myCar.Handling.Nitro.NitroForce.Value = 5000
--My Code
findCar()\nmyCar.Handling.MaxSpeed.Value = 10000\nmyCar.Handling.Torque.Value = 40000\nmyCar.Handling.SteeringRadiusConstant.Value = 15000\nmyCar.Handling.FrictionRoad.Value = 250\nmyCar.Handling.Nitro.NitroSpeed.Value = 500\nmyCar.Handling.Nitro.NitroForce.Value = 5000

It does not work (put the script in the "")

Link to comment
Share on other sites

Link to post
Share on other sites

The first problem is that \n is used for new line in a string ,whereas what you're doing is trying to keep all the code on a single line, which is totally different. Basically you would use \n for actual strings that you're printing out to the screen, not in between code snippets.

 

Also, the snippet that you posted that comes from some else's code is wrapped in parenthesis AND double quotes, so for that language that allows it to keep things together by treating the commands as a string.

Theoretically, you'd change your single-line command to:

("findCar()\nmyCar.Handling.MaxSpeed.Value = 10000\nmyCar.Handling.Torque.Value = 40000\nmyCar.Handling.SteeringRadiusConstant.Value = 15000\nmyCar.Handling.FrictionRoad.Value = 250\nmyCar.Handling.Nitro.NitroSpeed.Value = 500\nmyCar.Handling.Nitro.NitroForce.Value = 5000")

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×