-If the former; I might've typo'd something...
Spotted it;
Code: Select all
elseif next ( GetStaff('Cook') )Moderator: NBJeff
Code: Select all
elseif next ( GetStaff('Cook') )
Brento666 wrote:None of it or just the staff part?
-If the former; I might've typo'd something...
Spotted it;is missing 'then'...common you figured that one out no?Code: Select all
elseif next ( GetStaff('Cook') )
Code: Select all
elseif next ( GetStaff('Psychologist') ) then
Echo("Opening the door for psychologist.")
this.Open
else
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)
endCode: Select all
function GetStaff(staff_type)
return this.GetNearbyObjects(staff_type, 1.5)
endCode: Select all
--else
--this.Open = 0
--Echo("Closing the door.")
Code: Select all
timer = timer + period --I do not know what this does.
if timer > 0.2 then
timer = 0
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.


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

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)
endoxygencraft wrote:If you need the code then its down below.
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)Code: Select all
--Opens the door. -> Fails to close
(or)
--Opens the door. But door stays open sometimes... or something!

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!
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
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).
Users browsing this forum: No registered users and 6 guests