mestiez / ppg-snippets Goto Github PK
View Code? Open in Web Editor NEWa number of useful code snippets that should help users write People Playground mods
Home Page: https://www.studiominus.nl/ppg-modding/
a number of useful code snippets that should help users write People Playground mods
Home Page: https://www.studiominus.nl/ppg-modding/
please add how to work on laser weapons, such as, change blast color, damage those stuff
my mod after compiling just says
Modcompiler, { expected at 5,13
Type or namespace definiton, or end-of-fie expected at 6,0
{ expected at 7,17
}expected at 7,17
; expected at 9,27
i want to make that a gun i have will shoot from a diffrend area then orginally.
Not like the auto generated shitty ones but complestly custom ones?
im pulling my freaking hair out, ive tried copypasting from dotpeek, theres weird nulls and crap and i cant figure out how to not make it error (there's no built in debugger!)
everything i add has the knife hitbox
Excuse me. I hate to bother you, as I know you're constantly working with studiominus. I was just wondering if/where I could find the sourcecode for the Energy Sword, as I'd like to make my own custom one for myself. I wouldn't want to just go in and change your team's png's of the different parts of the item. I'd rather have my own additional one. Basically the same source code you used to create your lightsaber mod. I'm sure you get asked this a lot, but I'd rather get an answer straight from the source.
Thank you very much.
I use such a function, but it does not execute the code when activating the item
private void Use(ActivationPropagation activation)
{
this.Shoot();
ModAPI.Notify("Test");
}
idk
i know i'm posting a lot here, but i'm trying to work on other things, what's the definition to load videos? I tried using
ModAPI.LoadVideo
or
ModAPI.LoadBroadcast
but these didn't work (don't exist), and i'm trying to make a custom TV transmission
I made a gun but it doesnt show up when I spawn it. It still shoots though
my code:
`using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Events;
namespace Mod
{
public class Mod
{
public static void OnLoad()
{
UnityEngine.Debug.Log("Loaded My Mod Succesfully");
}
public static void Main()
{
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Pistol"), //item to derive from
NameOverride = "Finger Gun -RandomMod", //new item name with a suffix to assure it is globally unique
DescriptionOverride = "Wait... It actually works?", //new item description
CategoryOverride = ModAPI.FindCategory("Firearms"), //new item category
ThumbnailOverride = ModAPI.LoadSprite("fingergunImage.png"), //new item thumbnail (relative path)
AfterSpawn = (Instance) => //all code in the AfterSpawn delegate will be executed when the item is spawned
{
//setting the sprite
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("C96.png");
//getting the FirearmBehaviour for later manipulation
var firearm = Instance.GetComponent<FirearmBehaviour>();
//creating a custom cartridge for the gun
Cartridge customCartridge = ModAPI.FindCartridge("9mm"); //load a copy of the 9mm cartridge
customCartridge.name = "Finger Gun"; //set a name
customCartridge.Damage *= 2f; //change the damage however you like
customCartridge.StartSpeed *= 1.5f; //change the bullet velocity
customCartridge.PenetrationRandomAngleMultiplier *= 0.5f; //change the accuracy when the bullet travels through an object
customCartridge.Recoil *= 0.7f; //change the recoil
customCartridge.ImpactForce *= 0.7f; //change how much the bullet pushes the target
//set the cartridge to the FirearmBehaviour
firearm.Cartridge = customCartridge;
//set the new gun sounds. this is an array of AudioClips that is picked from at random when shot
firearm.ShotSounds = new AudioClip[]
{
ModAPI.LoadSound("c96_1.wav"),
ModAPI.LoadSound("c96_2.wav"),
ModAPI.LoadSound("c96_3.wav"),
};
// set the collision box to the new sprite shape
// this is the easiest way to fix your collision shape, but it also the slowest.
Instance.FixColliders();
}
}
);
}
}
}`
I want to make a human with a knife head, I already made the accesory, but I don´t know how to make it so the knife accesory stabs.
I tried
head.gameObject.AddComponent();
but doesn´t work
I need to use System.Collections.Generic.Stack and System.Text.RegularExpressions but People playground gives me error about missing references
Hello, so I won't to change the sprite of a human when its spawned, I have an idea for it to be in the right click menu, but how would I change it, I had an idea for it to add or minus from a varible to chose what skin it has, but, how will I change its skin (I don't want an error and then get confused for like 10 minutes, I just want an answer)
how can i add a category for all my custom humans guns and objects?
using System;
using UnityEngine;
// GunSFX Mod.
namespace GunSFX {
public class GunSFX {
public static void Main() {
string[] ShotSounds = {"sfx\\OneShot.mp3", "sfx\\SecondShot.mp3", "sfx\\ThirdShot.mp3"};
var RandomInstance = new System.Random();
var ChosenShotSound = ShotSounds[RandomInstance.Next(ShotSounds.Length)];
ModAPI.OnGunShot += (Sender, Gun) => {
var ShotSound = ModAPI.LoadSound(ChosenShotSound);
Gun.GetComponent<AudioSource>().clip = ShotSound;
Gun.GetComponent<AudioSource>().Play();
};
}
}
}
Error please help
i was wanting to make clothing for my mod but cant seem to find how to do it anywhere on this github page.
I'm sorry if this is the wrong place to post my issue/question. I've had an issue with a mod I've been working on for months now and I cant figure it out. It only affects a fraction of users and I've never been able to recreate it.
The issue is when I try to pose a limb by directly calling InfluenceMotorSpeed which is the only way I've figured out as a way to set certain limbs without affecting the other limbs . And this works fine for most, but a few users experience completely different limb positions .
I'm hoping you can give me a suggestion on either what I'm doing wrong or a correct approach to achieve this same functionality.
This is my func:
public void CombineMove()
{
// Only pose specific limbs (continue previous actions)
foreach (KeyValuePair<string, LimbMove> pair in moves)
{
LB[pair.Key].InfluenceMotorSpeed(Mathf.DeltaAngle(
LB[pair.Key].Joint.jointAngle, pair.Value.angle * flipped) * pair.Value.force);
}
}
and a sample limb setting would be:
LowerLeg
93.72361 (angle)
-1 (flipped)
4 (force)
Hello sorry for posting here again a question >.< but I really can't understand how to make a custom right click option for only my custom humans. Can someone help me?
I'm trying to add a heat ray into my mod and it works but visually there are weird glowing bits left over, I presume the glowing bits are a separate texture but how would I override that?
Hi, i'm adding custom parts to a object, and when i spawn them facing the positive direction (E) everything works well, but when i spawn the object in the opposite/negative direction (Q) the custom part keeps facing the positive direction. There's a way to make the child follow the orientation of the parent?
used the snippet, says C# is outdated. How could i fix, or get an updated snippet?
I am making a camera item for my mod, however there is absolutely no sound effect upon activation. I tried using this method described in the modding wiki, and my code is:
AfterSpawn = (Instance) =>
{
var sound = ModAPI.LoadSound("shutter.wav");
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Pictures/camera.png",18);
Instance.GetOrAddComponent<UseEventTrigger>().Action = () =>
{
Instance.GetComponent<AudioSource>().clip = sound;
ModAPI.CreateParticleEffect("Flash", Instance.transform.position);
};
}
however, it doesn't work. I do have shutter.wav in my mod directory. Am i doing something wrong?
Here is the full mod incase if its needed: mod.zip
I just watched this video : https://youtu.be/bSVjDuNqZVk , but my accessory is not "sticked" to the android. It's just flying and not moving. Help!
how do i do it
nice
Hi! I finished adding my custom rims and then i tried to fix the trunk/hood collisions (as it is not perfect, it's scaled to the basic car so it's not compatible on the majority of models), and also the anchor of these, and i did it.
For example, this part of code is for the vehicle trunk, and i added the localPosition transform change to it:
var boot = Instance.transform.GetChild(4).gameObject;
boot.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("ChevroletCaprice_Trunk.png", 0.66f);
boot.transform.localPosition = new Vector2(-3f, 0f);
boot.FixColliders();
By far everything good, same for hood and some changes to the engine position, but when pasting/loading/uploading, it weird, i mean, everything spawns like 1 meter over the vehicle:
https://imgur.com/a/8O4bHLV
How do i fix that? considering that the changes are based on the localposition of the parent and it shouldn't happen.
I know how to create a button, but I need help with creating a button that allows you to insert a character.
For example, the "Set Angle" button.
ModAPI.OnItemSelected += (sender, phys) => {
object = phys;
};
with this i get what object is selected
how do i go about freezing this as you would in the right click menu?
also is it possible to know object is under the cursor?
i didnt find the answer in the docs
the and human and android textures aren't updated
(bug report)
/ I already solved this issue, please close! /
Solution: Tried something random, have no idea what fixed it.
I am trying to make a script that adds multiple liquids, and ofcourse, 4 liquid mixers to the game.
For more clarity:
This is my code for each recipe (I have not misspelt the liquids, and they are all registered in the liquid registry).
I have changed the names of the most of the variables for simplicity
(repeated 3 more times with values changed)
// Recipe1
var mixer1 = new LiquidMixInstructions(
Liquid.GetLiquid(liquid1.ID), // (this is changed)
Liquid.GetLiquid(liquid2.ID), // (this is changed)
Liquid.GetLiquid(targetliquid.ID)); // (this is changed)
mixer1.RatePerSecond = 0.4f; // rate of creation (liquid units per second) (this is changed)
// prevent liquids from mixing in limbs (this is not changed)
mixer1.ContainerFilter = container => !(container is CirculationBehaviour);
and here is the code that adds the recipes to the mixinstructions dictionary (after all the recipes, not before)
LiquidMixingController.MixInstructions.Add(mixer1);
LiquidMixingController.MixInstructions.Add(mixer2);
LiquidMixingController.MixInstructions.Add(mixer3);
LiquidMixingController.MixInstructions.Add(mixer4);
When testing in game, all parts of the mod work fine, no errors. But, only the first recipe works...
More specifically, it is the first recipe to be created/defined, not the first recipe to be added to the mixinstructions dictionary
The documentation says nothing about this.
So that some time isnt wasted:
I mentioned previously that nothing is misspelt and that every liquid is in the liquid registry. None of the liquid IDs of each liquid are the same as any other liquid, and have their own mod tag, so they cant be mixed up with pre-existing liquids in the game. All the liquids and mixing recipes have been added in the Main method.
If this is something to do with the documentation, please make it more apparent, or is it about the game only checking the mixing recipe dictionary with the first recipe and ignoring all the rest?
thankz
TL:DR
Only 1 mixing instruction works, but all the rest are ignored
I think syringe textures could be really useful for the syringe icons
a error in
ExplosionCreator.Explode(new ExplosionCreator.ExplosionParameters
{
//Explosion center
>Position = transform.position,
Hello There I Was Wondering How To Add Gun Animations Well To Guns When They Shoot Could You Help Me?
Hi, i'm a mod creator that's actually working on a vehicle mod, and i would like to know the name of the parts of a vehicle, as most of these are not going to be only sedans (pickup trucks, vans, station wagons). It would be really helpful for the people that wants to make vehicles but they don't know how to start.
Add Snippet for an Axe please
i need to find liquid amoint in limb, how do i do that?
The human from my mod is invisible, please help
code:
using UnityEngine;
namespace Mod
{
public class Mod
{
public static void Main()
{
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Human"), //item to derive from
NameOverride = "[PAF] Soldier", //new item name with a suffix to assure it is globally unique
DescriptionOverride = "PAF Soldier.", //new item description
CategoryOverride = ModAPI.FindCategory("Entities"), //new item category
ThumbnailOverride = ModAPI.LoadSprite("soldier.png"), //new item thumbnail (relative path)
AfterSpawn = (Instance) => //all code in the AfterSpawn delegate will be executed when the item is spawned
{
var skin = ModAPI.LoadTexture("soldier.png");
var flesh = ModAPI.LoadTexture("flesh.png");
var bone = ModAPI.LoadTexture("bone.png");
var person = Instance.GetComponent<PersonBehaviour>();
person.SetBodyTextures(skin, flesh, bone, 1);
person.SetBruiseColor(86, 62, 130); //main bruise colour. purple-ish by default
person.SetSecondBruiseColor(154, 0, 7); //second bruise colour. red by default
person.SetThirdBruiseColor(207, 206, 120); // third bruise colour. light yellow by default
person.SetRottenColour(202, 199, 104); // rotten/zombie colour. light yellow/green by default
person.SetBloodColour(108, 0, 4); // blood colour. dark red by default. note that this does not change decal nor particle effect colours. it only affects the procedural blood color which may or may not be rendered
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Human"), //item to derive from
NameOverride = "[PAF] Elite Unit", //new item name with a suffix to assure it is globally unique
DescriptionOverride = "Pretty cool.", //new item description
CategoryOverride = ModAPI.FindCategory("Entities"), //new item category
ThumbnailOverride = ModAPI.LoadSprite("elite soldier.png"), //new item thumbnail (relative path)
AfterSpawn = (Instance) => //all code in the AfterSpawn delegate will be executed when the item is spawned
{
var skin = ModAPI.LoadTexture("elite soldier.png");
var flesh = ModAPI.LoadTexture("flesh.png");
var bone = ModAPI.LoadTexture("bone.png");
var person = Instance.GetComponent<PersonBehaviour>();
person.SetBodyTextures(skin, flesh, bone, 1);
person.SetBruiseColor(86, 62, 130); //main bruise colour. purple-ish by default
person.SetSecondBruiseColor(154, 0, 7); //second bruise colour. red by default
person.SetThirdBruiseColor(207, 206, 120); // third bruise colour. light yellow by default
person.SetRottenColour(202, 199, 104); // rotten/zombie colour. light yellow/green by default
person.SetBloodColour(108, 0, 4); // blood colour. dark red by default. note that this does not change decal nor particle effect colours. it only affects the procedural blood color which may or may not be rendered
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Human"), //item to derive from
NameOverride = "[PAF] Pilot", //new item name with a suffix to assure it is globally unique
DescriptionOverride = "PAF Pilot.", //new item description
CategoryOverride = ModAPI.FindCategory("Entities"), //new item category
ThumbnailOverride = ModAPI.LoadSprite("pilotman.png"), //new item thumbnail (relative path)
AfterSpawn = (Instance) =>
//all code in the AfterSpawn delegate will be executed when the item is spawned
{
var skin = ModAPI.LoadTexture("pilotman.png");
var flesh = ModAPI.LoadTexture("flesh.png");
var bone = ModAPI.LoadTexture("bone.png");
var person = Instance.GetComponent<PersonBehaviour>();
person.SetBodyTextures(skin, flesh, bone, 1);
person.SetBruiseColor(86, 62, 130); //main bruise colour. purple-ish by default
person.SetSecondBruiseColor(154, 0, 7); //second bruise colour. red by default
person.SetThirdBruiseColor(207, 206, 120); // third bruise colour. light yellow by default
person.SetRottenColour(202, 199, 104); // rotten/zombie colour. light yellow/green by default
person.SetBloodColour(108, 0, 4); // blood colour. dark red by default. note that this does not change decal nor particle effect colours. it only affects the procedural blood color which may or may not be rendered
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Human"), //item to derive from
NameOverride = "[PAF] Officer", //new item name with a suffix to assure it is globally unique
DescriptionOverride = "PAF Officer.", //new item description
CategoryOverride = ModAPI.FindCategory("Entities"), //new item category
ThumbnailOverride = ModAPI.LoadSprite("officer.png"), //new item thumbnail (relative path)
AfterSpawn = (Instance) => //all code in the AfterSpawn delegate will be executed when the item is spawned
{
var skin = ModAPI.LoadTexture("officer.png");
var flesh = ModAPI.LoadTexture("flesh.png");
var bone = ModAPI.LoadTexture("bone.png");
var person = Instance.GetComponent<PersonBehaviour>();
person.SetBodyTextures(skin, flesh, bone, 1);
person.SetBruiseColor(86, 62, 130); //main bruise colour. purple-ish by default
person.SetSecondBruiseColor(154, 0, 7); //second bruise colour. red by default
person.SetThirdBruiseColor(207, 206, 120); // third bruise colour. light yellow by default
person.SetRottenColour(202, 199, 104); // rotten/zombie colour. light yellow/green by default
person.SetBloodColour(108, 0, 4); // blood colour. dark red by default. note that this does not change decal nor particle effect colours. it only affects the procedural blood color which may or may not be rendered
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Stick"),
NameOverride = "Officer cap",
NameToOrderByOverride = "A5",
DescriptionOverride = " ",
CategoryOverride = ModAPI.FindCategory("Entities"),
ThumbnailOverride = ModAPI.LoadSprite("Officer cap.png"),
AfterSpawn = (Instance) =>
{
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Officer cap.png");
Instance.FixColliders();
ArmorBehaviour armor = Instance.AddComponent<ArmorBehaviour>();
armor.stabResistance = 1f;
armor.armorPiece = "Head";
armor.armorTier = 1;
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Stick"),
NameOverride = "Pilot hood",
NameToOrderByOverride = "A5",
DescriptionOverride = " ",
CategoryOverride = ModAPI.FindCategory("Entities"),
ThumbnailOverride = ModAPI.LoadSprite("pilot.png"),
AfterSpawn = (Instance) =>
{
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("pilot.png");
Instance.FixColliders();
ArmorBehaviour armor = Instance.AddComponent<ArmorBehaviour>();
armor.stabResistance = 1f;
armor.armorPiece = "Head";
armor.armorTier = 1;
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Stick"),
NameOverride = "Elite Beret",
NameToOrderByOverride = "A5",
DescriptionOverride = " ",
CategoryOverride = ModAPI.FindCategory("Entities"),
ThumbnailOverride = ModAPI.LoadSprite("elite beret.png"),
AfterSpawn = (Instance) =>
{
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("elite beret.png");
Instance.FixColliders();
ArmorBehaviour armor = Instance.AddComponent<ArmorBehaviour>();
armor.stabResistance = 1f;
armor.armorPiece = "Head";
armor.armorTier = 1;
}
}
);
ModAPI.Register(
new Modification()
{
OriginalItem = ModAPI.FindSpawnable("Rod"),
NameOverride = "[PAF] Helmet",
NameToOrderByOverride = "A5",
DescriptionOverride = " ",
CategoryOverride = ModAPI.FindCategory("Entities"),
ThumbnailOverride = ModAPI.LoadSprite("helmet.png"),
AfterSpawn = (Instance) =>
{
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("helmet.png");
Instance.FixColliders();
ArmorBehaviour armor = Instance.AddComponent<ArmorBehaviour>();
armor.stabResistance = 3f;
armor.armorPiece = "Head";
armor.armorTier = 3;
}
}
);
}
}
}
THERE ARE NO ERRORS HERE.
so i have been making a gun mod but i need help so when the gun is activated there is smoke particles
Instance.GetComponent().sprites = new Sprite[]
{
ModAPI.LoadSprite("cube1.png"),
ModAPI.LoadSprite("cube2.png"),
ModAPI.LoadSprite("cube3.png"),
ModAPI.LoadSprite("cube4.png"),
};
and when i spawn the cube a plank just spawns
How do I change the color of a character when I inject a syringe in it? I got the syringe part down but how do I change the color of the victim? I've tried
limb.renderer.material.color= new UnityEngine.Color(0.54f, 0.37f, 0.24f);
but it doesnt work
Hi, when I compiled my mod, it gave me an error. I am not sure why, I dud everything in the code. I think the script is outdated.
19911999191
The modding docs are pretty darn good and they got me into modding the game real quick, but a few GUI examples would really fill a hole in my chest.
it would be a great thing if we dipped metal in water and is slowly rusted and if we stab people with it would kill the person even if its a small stab
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.