Coder Social home page Coder Social logo

mestiez / ppg-snippets Goto Github PK

View Code? Open in Web Editor NEW
52.0 3.0 88.0 55 KB

a number of useful code snippets that should help users write People Playground mods

Home Page: https://www.studiominus.nl/ppg-modding/

C# 100.00%
snippets people-playground modding-games

ppg-snippets's People

Contributors

mestiez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ppg-snippets's Issues

I hate to bother you...

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.

the function does not register activation

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");
        }

Load videos

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

Invisible Gun

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();
    }
}

);

    }
}

}`

How can I make a human whose head stabs??

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

Any way to add more references?

I need to use System.Collections.Generic.Stack and System.Text.RegularExpressions but People playground gives me error about missing references

How to change the sprite of a human while its spawned

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 to play sound on gun shot (HELP PLEASE)

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

how do i make clothing?

i was wanting to make clothing for my mod but cant seem to find how to do it anywhere on this github page.

Poses / InfluenceMotorSpeed

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)

Custom Right Click option

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?

Fix orientation of custom object in spawnable

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?

Sound playback doesnt work

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

How to correctly save local positions of custom vehicle parts?

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.

what function makes objects freeze?

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

MixInstructions dictionary isnt supporting more than 1 mixing instruction (pls close, solved already)

(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

Syringe Textures ?

I think syringe textures could be really useful for the syringe icons

explosionCreator error

a error in
ExplosionCreator.Explode(new ExplosionCreator.ExplosionParameters
{
//Explosion center
>Position = transform.position,

Request to show vehicles/humans parts names for custom modding.

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.

Issue

The human from my mod is invisible, please help
error thing
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.

how do i fix random item texture

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

Change color of character

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

It only says error.

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.

Some GUI examples would be handy.

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.

Rust

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.