Jump to content
  • 0
Stormy Stratten

How to make a script programmatically

Question

Hello! Does anyone know how to programmatically create a scripts with a different source code inside. For example, create 100 scripts in a loop and declare variables in each of the scripts: integer i = 0; integer i = 1; integer i = 2; ... integer i = 99;

That is, in each generated script, its own variable will be declared and initialised.

And to do all this with a single script programmatically.

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

This cannot be done. Scripts cannot create scripts, write to scripts/notecards or even directly copy itself.

Technically there are ways to easily create this exact effect, but what's the purpose you're trying to achieve?

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites
  • 0
  • create script with global variable and listener to accept variable - it must be set to listen exactly once and then stop listening also scripts must not reset on rez.
  • drop script into a prim box
  •  drop prim box in new box
  • write script that keeps rezzing the object in for loop and telling the updated variable
  • optional get thrown of region for prim littering / abhorrent script use
  • despair in collecting your script boxes as they all carry the same name (hovertext displaying your integer might come in handy)

This was just an example that you actually can do it if you want to but it is not very usefull at all.

Why would you want to do so?

Share this post


Link to post
Share on other sites
  • 0

Thanks for answers! I thought it really wasn’t necessary. I am looking for different ways to do one task. I need to make such a script, which after purchase is deleted after a day, for example. At the same time, restarting this script should not affect its lifetime. I think that without the server side this is not done. I need to save the "Avatar UUID" + "Script UDID" + "Timestamp of first state_entry" params on the server, and manage the lifetime through requests to the server, but the Script UDID changes every time the script is reloaded. Therefore, I do not know how to make a script that lives during the day. I also tried to save some information in the script description programmatically, but the API does not allow this. That is my task is to make a temporary script that does not depend on the reset of scripts in prim.

Thank!

Edited by Stormy Stratten

Share this post


Link to post
Share on other sites
  • 0
5 minutes ago, Stormy Stratten said:

That is my task is to make a temporary script that does not depend on the reset of scripts in prim.

Scripts in a no-modify object cannot be manually restarted. Alternatively, if you'd rather respect the user's freedom with the object, you could store the timestamp on the object the script is in, like as an invisible hovertext as it cannot be changed without scripts and the user is extremely unlikely to know it's being used.

Share this post


Link to post
Share on other sites
  • 0
34 minutes ago, Wulfie Reanimator said:

could store the timestamp on the object the script is in, like as an invisible hovertext

But it not my object. User can be place my script in other object. And i can not use any text fields of not my prim.

And i can not change script text filds, as far as I know

Edited by Stormy Stratten

Share this post


Link to post
Share on other sites
  • 0

If I put the script with my invisible prim, let's say, the user will still be able to copy this script into his inventory and then put this script into his object. At the same time, the script will not know whether it is in its object or not, if you do not use, for example, the set/get description of the script itself (API not allowed this, as far as I know).

Edited by Stormy Stratten

Share this post


Link to post
Share on other sites
  • 0
On 1/16/2019 at 7:33 AM, Stormy Stratten said:

If I put the script with my invisible prim, let's say, the user will still be able to copy this script into his inventory and then put this script into his object. At the same time, the script will not know whether it is in its object or not, if you do not use, for example, the set/get description of the script itself (API not allowed this, as far as I know).

You can lock operation of a script to a host by referencing its creation time, using the llGetObjectDetails() constant OBJECT_CREATION_TIME.

You just have to use a unique host that only you created that will not be used with any other application.

So either rez a cube or upload a mesh and only use that host for your script to operate in.

Assign verification(check current link's creation time versus hard-coded creation time) to a global integer in state_entry() and reference said global integer at the start of each vital script event.

If your object is mod, another area of concern might include checking if another script exists in the same link as your script. It's a concern because certain functions can trigger the same event in multiple scripts in the same link.

Edited by Lucia Nightfire

Share this post


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

×