Modding Help

Discussion about Mods for Prison Architect

Moderator: NBJeff

User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Tue Nov 03, 2015 8:45 am

None of it or just the staff part? :D
-If the former; I might've typo'd something...

Spotted it;

Code: Select all

elseif next ( GetStaff('Cook') )
is missing 'then'...common you figured that one out no? :mrgreen:
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Tue Nov 03, 2015 10:09 am

Brento666 wrote:None of it or just the staff part? :D
-If the former; I might've typo'd something...

Spotted it;

Code: Select all

elseif next ( GetStaff('Cook') )
is missing 'then'...common you figured that one out no? :mrgreen:


Edited the code and its still not working its saying:
ERROR: ERROR : [string "local timer = 0..."]:83 '=' expected near 'else
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Tue Nov 03, 2015 10:52 am

Code: Select all

elseif next ( GetStaff('Psychologist') ) then
             Echo("Opening the door for psychologist.")
             this.Open
      else


this.Open....! :P
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Wed Nov 04, 2015 10:01 am

I tested my mod and i saw i bug in my mod the bug is the door closes and opens at the same time witch makes it look like its closing and opening. Other bug is when a guard comes to the door he/she tries to open with his/her keys and then it instantly closes and triggers the bug above and you need any staff member to fix it. I want those two bugs fixed.

Code: Select all

local timer = 0
function Create()
end

function Update(period)
    timer = timer + period --I do not know what this does.
    if timer > 0.2 then
      timer = 0
      if next( GetStaff( 'Workman') ) then
            Echo("Opening the door for workmen.")
            this.Open = 1 --Opens the door.
      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') ) then
            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 = 1
      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
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Wed Nov 04, 2015 2:15 pm

Glad to hear we atleast got all the script-typo's out now :D

So you now have a very agitated and snappy door!!
-Does it kill anyone coming through with that open/close behavior? :twisted:

I was afraid of setting the search distance to 1 would create something like what you're experiencing... try 1.5 or 2 for distance;

Code: Select all

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


I would also like suggest letting the door close on it's own accord... so try commenting out the else part at the end of the if/else statements;

Code: Select all

      --else
              --this.Open = 0
              --Echo("Closing the door.")


About

Code: Select all

timer = timer + period --I do not know what this does.
    if timer > 0.2 then
      timer = 0

this makes it so your script isn't being run every single cycle! It adds several cycle periods together... and when that amount totals up to 0.2 'game-time-length-units' it runs your code once!
(the timer getting reset is an important step for getting the next run of your script scheduled.)

You could play around with this number aswell. (Maybe running to code more/less often might help manage the door a bit better, I'm not sure.
-Maybe "timer > 0.1" would improve the door mechanic, or it might not do much for ya.
-If you feel the code could be run less often; then please do make it "timer > 0.3" or higher... in general; the less script being run needlessly the better!

Hope that helps you a bit! I also suggest looking into open/(close)timer properties of the door...(instead of setting "open").. They could help smooth the opening! As suggested I'd leave the closing part commented out so closing should be smoother already!

Hope that helps ya!
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Thu Nov 05, 2015 5:44 am

I found a bug again the bug is when staff requests to open the door it opens but stays open until you put it in locked shut and then normal it does not matter if there are any are any prisoners in the prison. I want someone to help me fix the bug.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Thu Nov 05, 2015 6:04 am

oxygencraft wrote:I found a bug again the bug is when staff requests to open the door it opens but stays open until you put it in locked shut and then normal it does not matter if there are any are any prisoners in the prison. I want someone to help me fix the bug.

I'll try to get a little addition to your script maybe tomorrow...
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Fri Nov 06, 2015 9:57 am

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

Re: Modding Help

Postby oxygencraft » Sat Nov 07, 2015 4:44 am

Is anyone even going to reply or not? :(
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sat Nov 07, 2015 9:06 am

oxygencraft wrote:Is anyone even going to reply or not? :(

Hmmm, not here to script your stuff from a to z, definitely not liking the tone(!)

Repost your current script, start to finish. If the door broke, you made a booboo...
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sat Nov 07, 2015 10:41 pm

If you need the code then its down below.

Code: Select all

local timer = 0
local openstate = Object.GetProperty( this, "Open" )
local amountofprisoners = this.GetNearbyObjects('Prisoner', 99999)
function Create()
end

function Update(period)
    timer = timer + period
    if timer > 0.2 then
      timer = 0
      if next( GetStaff( 'Workman') ) then --If a workmen is found nearby then this triggers.
            Echo("Opening the door for workmen.") --Displays text inside "" to the script debugger.
            this.Open = 1 --Opens the door.
      elseif next( GetStaff( 'Janitor') ) then --If a janitor is found nearby then this triggers.
            Echo("Opening the door for janitor.") --Displays text inside "" to the script debugger.
            this.Open = 1 --Opens the door.
      elseif next( GetStaff( 'Gardener') ) then --If a gardener is found nearby then this triggers.
            Echo("Opening the door for gardener.") --Displays text inside "" to the script debugger.
            this.Open = 1 --Opens the door.
      elseif next( GetStaff( 'Doctor') ) then --If a doctor is found nearby then this triggers.
            Echo("Opening the door for doctor.") --Displays text inside "" to the script debugger.
            this.Open = 1 --Opens the door.
      elseif next ( GetStaff('Cook') ) then --If a cook is found nearby then this triggers.
            Echo("Opening the door for cook.") --Displays text inside "" to the script debugger.
            this.Open = 1 --Opens the door.
      elseif next ( GetStaff('Warden') ) then --If a warden is found nearby then this triggers.
            Echo("Opening the door for warden.") --Displays text inside "" to script debugger.
            this.Open = 1 --Opens the door.
      elseif next ( GetStaff('Chief') ) then --Goes on for every staff.
            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 = 1
      end
   end
end

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

function GetStaff(staff_type)
    return this.GetNearbyObjects(staff_type, 1)
end
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sun Nov 08, 2015 1:43 pm

oxygencraft wrote:If you need the code then its down below.

Your code shows zero evidence of you researching the bug/or trying to come up with a solution :(

I fully expect to see evidence of testing-activities like maybe;

Code: Select all

if timer > 0.5 then--no negative effect
--if timer > 0.2 then--initial
--if timer > 1 then--too slow
--if timer > 0.1 then--doesn't need tobe this fast
...
--return this.GetNearbyObjects(staff_type, 1)
return this.GetNearbyObjects(staff_type, 1.5)

->Or atleast a hint which "ifelse" is actually giving you grief!

Again, not here to make your mod dreams reality, only here to help you out a bit here and there... Fact is I am not running/debugging this code ever; because it isn't my project!
-So I need you to show in your script what you tried, what worked, what didn't AND most importantly where it is failing;
so somewhere (but not everywhere) I should read;

Code: Select all

--Opens the door. -> Fails to close
(or)
--Opens the door. But door stays open sometimes... or something!

Perhaps you do need to actively close the door after a small while on some cases, perhaps even 'lock' it briefly to get it to close...

->Definitely drop/comment-out this dreck;
"local openstate = Object.GetProperty( this, "Open" ) and local amountofprisoners = this.GetNearbyObjects('Prisoner', 99999)"
-If something isn't adding to your solution, take it out or comment it out for later use!

Please understand I mostly hang around here to chat and discuss ideas and specific problems.
>General problem solving / script debugging / development should come from you!
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Sun Nov 08, 2015 9:42 pm

Brento666 wrote:
oxygencraft wrote:If you need the code then its down below.

Your code shows zero evidence of you researching the bug/or trying to come up with a solution :(

I fully expect to see evidence of testing-activities like maybe;

Code: Select all

if timer > 0.5 then--no negative effect
--if timer > 0.2 then--initial
--if timer > 1 then--too slow
--if timer > 0.1 then--doesn't need tobe this fast
...
--return this.GetNearbyObjects(staff_type, 1)
return this.GetNearbyObjects(staff_type, 1.5)

->Or atleast a hint which "ifelse" is actually giving you grief!

Again, not here to make your mod dreams reality, only here to help you out a bit here and there... Fact is I am not running/debugging this code ever; because it isn't my project!
-So I need you to show in your script what you tried, what worked, what didn't AND most importantly where it is failing;
so somewhere (but not everywhere) I should read;

Code: Select all

--Opens the door. -> Fails to close
(or)
--Opens the door. But door stays open sometimes... or something!

Perhaps you do need to actively close the door after a small while on some cases, perhaps even 'lock' it briefly to get it to close...

->Definitely drop/comment-out this dreck;
"local openstate = Object.GetProperty( this, "Open" ) and local amountofprisoners = this.GetNearbyObjects('Prisoner', 99999)"
-If something isn't adding to your solution, take it out or comment it out for later use!

Please understand I mostly hang around here to chat and discuss ideas and specific problems.
>General problem solving / script debugging / development should come from you!



I dont get what you mean but i am doing with the openstate and amountofprisoners variable is trying to fix it. But i havent fount a way to fix it.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Modding Help

Postby Brento666 » Sun Nov 08, 2015 10:23 pm

Code: Select all

if timer > 0.5 then--no negative effect
--if timer > 0.2 then--initial
--if timer > 1 then--too slow
--if timer > 0.1 then--doesn't need tobe this fast

What a sniplet of code like above does is inform the reader; disable what you doesn't work (--) and write something to remind you/others what worked and what didn't.

The 'amountofprisoners' and 'openstate' have no function (in your current script), so comment it out (--).

If you pinpoint the situation where it goes wrong (with a comment in your script) I could help you along... (you need to set "this.Mode=2" and reset to "this.Mode=0" shortly after, maybe.)

Also, you could publish your mod, set it to private and share a link here, if you want me to run a test (at my leisure).
oxygencraft
level1
level1
Posts: 24
Joined: Wed Feb 18, 2015 6:53 am

Re: Modding Help

Postby oxygencraft » Mon Nov 09, 2015 9:38 am

Brento666 wrote:

Code: Select all

if timer > 0.5 then--no negative effect
--if timer > 0.2 then--initial
--if timer > 1 then--too slow
--if timer > 0.1 then--doesn't need tobe this fast

What a sniplet of code like above does is inform the reader; disable what you doesn't work (--) and write something to remind you/others what worked and what didn't.

The 'amountofprisoners' and 'openstate' have no function (in your current script), so comment it out (--).

If you pinpoint the situation where it goes wrong (with a comment in your script) I could help you along... (you need to set "this.Mode=2" and reset to "this.Mode=0" shortly after, maybe.)

Also, you could publish your mod, set it to private and share a link here, if you want me to run a test (at my leisure).


I will upload the mod but its not the full mod. The mod has a door that you can test. I will send a pm with the mod to you.

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 6 guests