Modding Help

Discussion about Mods for Prison Architect

Moderator: NBJeff

oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Modding Help

Postby oxygencraft » Fri Oct 30, 2015 10:49 am

I want to create a doors mod and I need help with that. I am new to modding I read some guides about modding but i still want some help because its my very first mod. What I am trying to do is make a door that automatically opens when staff request to open the door or when prisoners want to go into areas that they are allowed to.
Trixi
level2
level2
Posts: 245
Joined: Wed Mar 04, 2015 9:22 am
Location: Ulm, Germany
Contact:

Re: Modding Help

Postby Trixi » Fri Oct 30, 2015 9:50 pm

no mod needed for that.

install a pressure plate in front of the door and connect this pressure plate to the door servo.
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sat Oct 31, 2015 6:25 am

Trixi wrote:no mod needed for that.

install a pressure plate in front of the door and connect this pressure plate to the door servo.


Pressure plates can let prisoners escape i don't want that. I want a door that nothing can stop it closing and control which part of the prison that prisoners are allowed to go to.
Last edited by oxygencraft on Sun Nov 01, 2015 3:13 am, edited 1 time in total.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sat Oct 31, 2015 12:41 pm

Hi Oxygencraft !

I just made a mod heavily featuring new doors (paint, upgrade, downgrade, sign)... What are your intensions?
-A door that acts like an ingame default door, openable by all?
-Or something with a script and special behavior to select and detect who goes trough?

Either way it's going to be not so easy; not for your first mod...
-Extending doors so they work well is quite tricky and mods that do so aren't compatible with each other, so I lack time and motivation to help create something that will be incompatible with my own work...!

-Modding extra behavior onto doors can be done: but is allot of work and the results up to date are quite script-intense and still not fully working as intended (from what I gathered);
...I recently spoke to Aubergine18 about his efforts to create an emergency exit type of door on here... I don't know where he is now @ on that project, he might be better able to tell you what and why scripted doors are a tough nut to crack!!
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sat Oct 31, 2015 10:16 pm

Brento666 wrote:Hi Oxygencraft !

I just made a mod heavily featuring new doors (paint, upgrade, downgrade, sign)... What are your intensions?
-A door that acts like an ingame default door, openable by all?
-Or something with a script and special behavior to select and detect who goes trough?

Either way it's going to be not so easy; not for your first mod...
-Extending doors so they work well is quite tricky and mods that do so aren't compatible with each other, so I lack time and motivation to help create something that will be incompatible with my own work...!

-Modding extra behavior onto doors can be done: but is allot of work and the results up to date are quite script-intense and still not fully working as intended (from what I gathered);
...I recently spoke to Aubergine18 about his efforts to create an emergency exit type of door on here... I don't know where he is now @ on that project, he might be better able to tell you what and why scripted doors are a tough nut to crack!!


I want to make stronger doors. Like 10 times stronger then solitary doors.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sun Nov 01, 2015 12:28 am

Great that's easily doable!

Get started with 3.1: http://prisonarchitectwiki.com/wiki/Modding_guide#Scripting_Changes

that will give you the base game setup files, they are a great wealth of information on how stuff works and how it is seprated across files... then get your own subfolder in your games mod folder and start filling in the manifest and the data-subfolder of that...

Again getting a door to be opened by everyone or all staff is tough. And like I said automatically incompatible with my own work... Just guard access is done with easy setups in your very own materials.txt and referencing the images you make in your 'sprite.png' file.

The link above should get you going for now, but do come back if you get stuck... or if you're done and want to show off :mrgreen:
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sun Nov 01, 2015 1:34 am

Does this.GetNearbyObjects radius of 1 still looks behind the door?
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sun Nov 01, 2015 2:12 am

It goes as far as you set it;

Code: Select all

local objects = Object.GetNearbyObjects("Prisoner", 500)
    for obj, dist in pairs(objects) do
        obj.Damage = 1
    end


edit: With a radius of 1 you may just miss the prisoner, maybe you need a little more... you will get 'false positives'...

Like Trixi said;; you're then basically having a pressure plate servo setup with script... which may be cool still...

Unless the door is only supposed to open on certain situations you define and control... You can easily set the door to open or close by this.Open = 1 or 0 or inbetween, but that is instant...

If you're already for scripting then you may already have found this guide by yourself; http://steamcommunity.com/sharedfiles/filedetails/?id=480978426 Aubergine18 is in the process to move the info to GitHub; https://github.com/aubergine10/Prison-Architect-API/wiki/scripts (But not all the info has been moved yet, so steam is also still a valid place to read up on things)

-Check the OpenTimer functions to see if you can contribute by 'sussing out' if/how it works and reporting back in here or steam if you find anything interesting!!
Last edited by Brento666 on Sun Nov 01, 2015 2:33 am, edited 2 times in total.
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sun Nov 01, 2015 2:18 am

And also how do I delay my code so my door wont instantly close when it opens.
Last edited by oxygencraft on Sun Nov 01, 2015 3:13 am, edited 1 time in total.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sun Nov 01, 2015 2:32 am

(edited my earlier reply)
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sun Nov 01, 2015 3:03 am

I am getting errors with this code. What did I do wrong?

Code: Select all

function Create()
    Game.DebugOut("Opening the door for staff.");
end

function Update()
    this.GetNearbyObjects( 'Workmen', 1)
       if next( workmens ) then
           this.Open = 1
end
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sun Nov 01, 2015 6:34 am

Quite a lot actually ;)

Code: Select all

local timer = 0
function Create()
end

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      local workers = this.GetNearbyObjects( 'Workman', 1)
      if next( workers ) then
        --Game.DebugOut("Opening the door for staff.")
        this.Open = 1
     else
       this.Open = 0
       --Game.DebugOut("Opening the door for staff.")
     end
  end
end


-remember to close every if statement
-use variables to contain stuff queried from the api (workers)
-no need for ;
-I have disabled your debug statements as it should be obvious to you if this is working :D
-don't overtax the system too much (hence timer)

-> You may try;
local workers = this.GetNearbyObjects( 'Staff', 1)

I have heard rumors it works... can you confirm?
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Mon Nov 02, 2015 5:20 am

I finished coding and i want someone to check my code tell me if i done any thing wrong. Note: I copied and pasted the code in so the code might be wrong.

Code: Select all

local timer = 0
function Create()
end

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      local workers = this.GetNearbyObjects( 'Workman', 1)
     local janitor = this.GetNearbyObjects( 'Janitor', 1)
     local gardener = this.GetNearbyObjects( 'Gardener', 1)
     local doctor = this.GetNearbyObjects( 'Doctor', 1)
     local cook = this.GetNearbyObjects ('Cook', 1)
     local warden = this.GetNearbyObjects ('Warden', 1)
     local chief = this.GetNearbyObjects ('Chief', 1)
     local foreman = this.GetNearbyObjects ('Foreman', 1)
     local lawyer = this.GetNearbyObjects ('Lawyer', 1)
     local accountant = this.GetNearbyObjects ('Accountant', 1)
     local psychologist = this.GetNearbyObjects ('Psychologist', 1)
      if next( workers ) then
        Game.DebugOut("Opening the door for workmen.")
        this.Open = 1
      elseif next( janitor ) then
       Game.DebugOut("Opening the door for janitor.")
       this.Open = 1
          elseif next( gardener ) then
           Game.DebugOut("Opening the door for gardener.")
           this.Open = 1
             elseif next( doctor ) then
              Game.DebugOut("Opening the door for doctor.")
             this.Open = 1
                elseif next ( cook )
                   Game.DebugOut("Opening the door for cook.")
                   this.Open = 1
               elseif next ( warden ) then
                   Game.DebugOut("Opening the door for warden.")
                  this.Open = 1
                     elseif next ( chief ) then
                      Game.DebugOut("Opening the door for chief.")
                     this.Open = 1
                       elseif next ( foreman ) then
                         Game.DebugOut("Opening the door for foreman.")
                                this.Open = 1
                          elseif next ( lawyer ) then
                            Game.DebugOut ("Opening the door for lawyer.")
                           this.Open = 1
                             elseif next ( accountant ) then
                               Game.DebugOut("Opening the door for accountant.")
                              this.Open = 1
                                elseif next ( psychologist ) then
                                  Game.DebugOut("Opening the door for psychologist.")
                                 this.Open
                                                else
                                                this.Open = 0
                                                Game.DebugOut("Closing the door.")
                                          end
                                 end
                              end
                           end
                        end
                     end
                  end
               end
            end
           end
      end
  end
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Mon Nov 02, 2015 11:43 am

oxygencraft wrote:I finished coding and i want someone to check my code tell me if i done any thing wrong. Note: I copied and pasted the code in so the code might be wrong.

Hi OxygenCraft,
Your code was going to work, apart from too many "end" 's.
-I refactored your code a bit; created 2 functions for often used debugging and getting.
->Also, now if a Workman is found; the other staff types won't be needlessly poled(!)

Code: Select all

local timer = 0
function Create()
end

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      if next( GetStaff( 'Workman') ) then
            Echo("Opening the door for workmen.")
            this.Open = 1
      elseif next( GetStaff( 'Janitor') ) then
            Echo("Opening the door for janitor.")
            this.Open = 1
      elseif next( GetStaff( 'Gardener') ) then
            Echo("Opening the door for gardener.")
            this.Open = 1
      elseif next( GetStaff( 'Doctor') ) then
            Echo("Opening the door for doctor.")
            this.Open = 1
      elseif next ( GetStaff('Cook') )
            Echo("Opening the door for cook.")
            this.Open = 1
      elseif next ( GetStaff('Warden') ) then
            Echo("Opening the door for warden.")
            this.Open = 1
      elseif next ( GetStaff('Chief') ) then
             Echo("Opening the door for chief.")
             this.Open = 1
      elseif next ( GetStaff('Foreman') ) then
             Echo("Opening the door for foreman.")
             this.Open = 1
      elseif next ( GetStaff('Lawyer') ) then
             Echo("Opening the door for lawyer.")
             this.Open = 1
      elseif next ( GetStaff('Accountant') ) then
              Echo("Opening the door for accountant.")
              this.Open = 1
      elseif next ( GetStaff('Psychologist') ) then
             Echo("Opening the door for psychologist.")
             this.Open
      else
              this.Open = 0
              Echo("Closing the door.")
      end
   end
end

function Echo(s)
    Game.DebugOut(s)
end

function GetStaff(staff_type)
    return this.GetNearbyObjects(staff_type, 1)
end

-Above script should do it for ya.

-> Would you please also try the following update function in your code/setup for me? (Like I said; it's rumored it should maybe work);

Code: Select all

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      if next( GetStaff( 'Staff') ) then
            Echo("Opening the door for Staff!")
            this.Open = 1
      elseif next( GetStaff( 'staff') ) then
            Echo("Opening the door for lowercase staff!")
            this.Open = 1
      else
              this.Open = 0
              Echo("Closing the door.")
      end
   end
end

-I'd love confirmation on it (and too busy on a whole other type of mod to go test).
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Mon Nov 02, 2015 11:57 pm

Brento666 wrote:
oxygencraft wrote:I finished coding and i want someone to check my code tell me if i done any thing wrong. Note: I copied and pasted the code in so the code might be wrong.

Hi OxygenCraft,
Your code was going to work, apart from too many "end" 's.
-I refactored your code a bit; created 2 functions for often used debugging and getting.
->Also, now if a Workman is found; the other staff types won't be needlessly poled(!)

Code: Select all

local timer = 0
function Create()
end

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      if next( GetStaff( 'Workman') ) then
            Echo("Opening the door for workmen.")
            this.Open = 1
      elseif next( GetStaff( 'Janitor') ) then
            Echo("Opening the door for janitor.")
            this.Open = 1
      elseif next( GetStaff( 'Gardener') ) then
            Echo("Opening the door for gardener.")
            this.Open = 1
      elseif next( GetStaff( 'Doctor') ) then
            Echo("Opening the door for doctor.")
            this.Open = 1
      elseif next ( GetStaff('Cook') )
            Echo("Opening the door for cook.")
            this.Open = 1
      elseif next ( GetStaff('Warden') ) then
            Echo("Opening the door for warden.")
            this.Open = 1
      elseif next ( GetStaff('Chief') ) then
             Echo("Opening the door for chief.")
             this.Open = 1
      elseif next ( GetStaff('Foreman') ) then
             Echo("Opening the door for foreman.")
             this.Open = 1
      elseif next ( GetStaff('Lawyer') ) then
             Echo("Opening the door for lawyer.")
             this.Open = 1
      elseif next ( GetStaff('Accountant') ) then
              Echo("Opening the door for accountant.")
              this.Open = 1
      elseif next ( GetStaff('Psychologist') ) then
             Echo("Opening the door for psychologist.")
             this.Open
      else
              this.Open = 0
              Echo("Closing the door.")
      end
   end
end

function Echo(s)
    Game.DebugOut(s)
end

function GetStaff(staff_type)
    return this.GetNearbyObjects(staff_type, 1)
end

-Above script should do it for ya.

-> Would you please also try the following update function in your code/setup for me? (Like I said; it's rumored it should maybe work);

Code: Select all

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      if next( GetStaff( 'Staff') ) then
            Echo("Opening the door for Staff!")
            this.Open = 1
      elseif next( GetStaff( 'staff') ) then
            Echo("Opening the door for lowercase staff!")
            this.Open = 1
      else
              this.Open = 0
              Echo("Closing the door.")
      end
   end
end

-I'd love confirmation on it (and too busy on a whole other type of mod to go test).


The code did not work.

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 5 guests