Title: Manually Sticking a Blueprint on a Player Post by: pspeed on January 09, 2012, 07:39:55 PM So I threw this together this evening. If you know a specific blueprint that you want to add to a player then you can add this script to the mods/scripts or scripts directory and it will add it to any players that don't already have it.
I'm not making this an official example because the API will be improved to make this simpler in the future... and may slightly break this one. But it works now. It is still helpful to have read and tried the other examples: http://mythruna.com/forum/index.php?topic=505.0 http://mythruna.com/forum/index.php?topic=506.0 If nothing else, the second example will let you easily be able to figure out which blueprint and object is and then you can manually copy it out of your mythruna.db/blueprints directory to give to someone else along with this script. Code:
For blueprints, the name of the file is also the ID. So if you need to rename the file then just make sure it's still a number and then use that number in the script above. It's not very elegant but it works... and like I said in another thread, there will be official support for this someday anyway. Title: Re: Manually Sticking a Blueprint on a Player Post by: chessikr on August 10, 2012, 08:06:06 PM so if i were to put
boolean hasBlueprint = false; for( Entity e : items ) { if( blueprintId == e.get(BlueprintReference.class).blueprintId ) { hasBlueprint = true; break; } nested in a for() loop that iterates per blueprint in a folder (for simplicity sake i would probably create an array of blueprint names and cycle through that), i could theoretically ensure that any imported blueprints are added to my (or whoever joins) inventory on load? or, would the implementation be different for single player (as i assume this is geared towards server-side)? also, this import mythruna.es.*; import mythruna.script.*; loads the script library (?) and the access route to the blueprints file? Title: Re: Manually Sticking a Blueprint on a Player Post by: pspeed on August 14, 2012, 08:04:39 AM so if i were to put boolean hasBlueprint = false; for( Entity e : items ) { if( blueprintId == e.get(BlueprintReference.class).blueprintId ) { hasBlueprint = true; break; } nested in a for() loop that iterates per blueprint in a folder (for simplicity sake i would probably create an array of blueprint names and cycle through that), i could theoretically ensure that any imported blueprints are added to my (or whoever joins) inventory on load? or, would the implementation be different for single player (as i assume this is geared towards server-side)? In this case, if you write it properly for the server then it can work in both places. It's possible to cheat on the single player version so that it doesn't work in multiplayer but in general as long as you reference the player properly it should work in both... you just have to put the script in different places. also, this import mythruna.es.*; import mythruna.script.*; loads the script library (?) and the access route to the blueprints file? The imports make it so that you can reference classes by their "simple name" instead of the fully qualified name. For example: Code: import mythruna.es.Name Is the same as: Code: .... The first one is just easier to read. Title: Re: Manually Sticking a Blueprint on a Player Post by: chessikr on August 16, 2012, 07:03:32 PM i see, so the imports are kind of like namespaces.
Title: Re: Manually Sticking a Blueprint on a Player Post by: pspeed on August 16, 2012, 07:39:27 PM i see, so the imports are kind of like namespaces. Yeah, they're just for programmer convenience. They are just for the compiler to fully qualify the classes. |