Yeah, You could do if DoorUseEvent.Open = True:So when you close the door it will start the timer? I might have to remove that boolean from the doorevent.
else: return?
Yeah, You could do if DoorUseEvent.Open = True:So when you close the door it will start the timer? I might have to remove that boolean from the doorevent.
https://github.com/dretax/Python-Plugins/blob/master/AutoDoorCloser/AutoDoorCloser.py#L79Yeah, You could do if DoorUseEvent.Open = True:
else: return?
Nothing happens when I remove the line, The plugin still works as normalhttps://github.com/dretax/Python-Plugins/blob/master/AutoDoorCloser/AutoDoorCloser.py#L79
What happens if u remove that line?
[1/30/2015 8:41:58 PM] [Debug] [IronPython] An error occurred in: AutoDoorCloser plugin while calling method: AutoCloserCallback
[1/30/2015 8:41:58 PM] [Exception] [ IPPlugin->Invoke | IPPlugin->OnTimerCB | IPTimedEvent->_timer_Elapsed | Timer->Callback | ]
System.InvalidCastException: Cannot cast from source type to destination type.
at Fougerite.Util.GetDooratCoords (Vector3 givenPosition) [0x00000] in <filename unknown>:0
at Fougerite.Util.GetDooratCoords (Single x, Single y, Single z) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) System.Func`5<Fougerite.Util, single, single, single, Fougerite.Entity>:invoke_Entity__this___Util_single_single_single (Fougerite.Util,single,single,single)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`5[Fougerite.Util,System.Single,System.Single,System.Single,Fougerite.Entity].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <filename unknown>:0
at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <filename unknown>:0
Wuuu, thats ugly.INI:[1/30/2015 8:41:58 PM] [Debug] [IronPython] An error occurred in: AutoDoorCloser plugin while calling method: AutoCloserCallback [1/30/2015 8:41:58 PM] [Exception] [ IPPlugin->Invoke | IPPlugin->OnTimerCB | IPTimedEvent->_timer_Elapsed | Timer->Callback | ] System.InvalidCastException: Cannot cast from source type to destination type. at Fougerite.Util.GetDooratCoords (Vector3 givenPosition) [0x00000] in <filename unknown>:0 at Fougerite.Util.GetDooratCoords (Single x, Single y, Single z) [0x00000] in <filename unknown>:0 at (wrapper delegate-invoke) System.Func`5<Fougerite.Util, single, single, single, Fougerite.Entity>:invoke_Entity__this___Util_single_single_single (Fougerite.Util,single,single,single) at Microsoft.Scripting.Interpreter.FuncCallInstruction`5[Fougerite.Util,System.Single,System.Single,System.Single,Fougerite.Entity].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <filename unknown>:0 at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <filename unknown>:0
You forgot to import UnityEngine.Pushed. Should be working now.
if door is None:
Server.Broadcast("Door is none")
continue
I was able to get It, but System.MissingMemberException: attribute 'Linq' of 'namespace#' object is read-only..... ASDYou forgot to import UnityEngine.
also with UnityEngine imported, it finds the door. The bad news, it finds the door as None.
https://github.com/dretax/Python-Plugins/blob/master/AutoDoorCloser/AutoDoorCloser.py#L104
This is what I had for testing.
And in chat it broadcasts the messagePython:if door is None: Server.Broadcast("Door is none") continue
atm just shutting a door, i'll type up a quick door owner look up unless someone beats me too itI guys rule... is this for autoshutting doors and door owner display?
Super simple door owner lookup, If you try to open a door it will tell you the owners name unless you are the owner.I guys rule... is this for autoshutting doors and door owner display?
__author__ = 'DreTaX'
__version__ = '1.0'
import clr
clr.AddReferenceByPartialName("Fougerite")
clr.AddReferenceByPartialName("UnityEngine")
clr.AddReferenceByPartialName("System.Core")
import Fougerite
import re
import UnityEngine
from UnityEngine import *
import System
from System import Reflection
"""
Class
"""
DStable = "DoorCloser"
class AutoDoorCloser:
bd = None
def On_PluginInit(self):
self.bd = Util.TryFindReturnType("BasicDoor")
if self.bd is None:
Plugin.Log("Error", "Couldn't find return type.")
def Stringify(self, List):
s = re.sub("[[\]\'\ ]", '', str(List))
return str(s)
def Parse(self, String):
return String.split(',')
def ReplaceToDot(self, String):
str = re.sub('[(\)]', '', String)
return str.split(':')
"""
Timer Functions
"""
def addJob(self, id, xtime, location):
epoch = Plugin.GetTimestamp()
exectime = int(epoch) + int(xtime)
# ID, EXECTIME : Location | Requires to be splited
List = []
List.append(str(exectime))
List.append(str(location).replace(',', ':'))
DataStore.Add(DStable, id, self.Stringify(List))
self.startTimer()
def killJob(self, id):
DataStore.Remove(DStable, id)
def startTimer(self):
gfjfhg = 1700
try:
if not Plugin.GetTimer("AutoCloser"):
Plugin.CreateTimer("AutoCloser", gfjfhg).Start()
except:
pass
def stopTimer(self):
timer = Plugin.GetTimer("AutoCloser")
if timer is None:
return
timer.Stop()
Plugin.Timers.Remove("AutoCloser")
def getPlayer(self, d):
try:
id = str(d)
pl = Server.FindPlayer(id)
return pl
except:
return None
def clearTimers(self):
DataStore.Flush(DStable)
self.stopTimer()
def Find(self, x, y, z):
objects = UnityEngine.Resources.FindObjectsOfTypeAll(self.bd)
loc = Util.CreateVector(x, y, z)
for door in objects:
Distance = Util.GetVectorsDistance(loc, door.transform.position)
if Distance < 1.5:
#if door.transform.position == loc:
return door
return None
def On_DoorUse(self, Player, DoorUseEvent):
#if DoorUseEvent.Open:
if DoorUseEvent.Entity.Owner is not Player:
Player.Message(DoorUseEvent.Entity.Owner.Name + " owns this door")
loc = Util.CreateVector(float(DoorUseEvent.Entity.X), float(DoorUseEvent.Entity.Y), float(DoorUseEvent.Entity.Z))
self.addJob(Player.SteamID, 2, loc)
def AutoCloserCallback(self):
epoch = int(Plugin.GetTimestamp())
if DataStore.Count(DStable) >= 1:
pending = DataStore.Keys(DStable)
for id in pending:
if DataStore.Get(DStable, id) is None:
DataStore.Remove(DStable, id)
continue
params = self.Parse(str(DataStore.Get(DStable, id)))
if epoch >= int(params[0]):
self.killJob(id)
xto = self.ReplaceToDot(params[1])
door = self.Find(float(xto[0]), float(xto[1]), float(xto[2]))
if door is None:
continue
if self.bd is not None:
# Praise baluerino
self.bd.InvokeMember("ToggleStateServer", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, None, door, System.Linq.Enumerable.ToArray([None, Plugin.GetTimestamp().As[System.UInt64], None]))
else:
self.stopTimer()
I reported that yesterday to mikec, seems like it will be in 1.0.8 .Entity's do not have Entity.Location
Its Entity.X, Entity.Y, Entity.Z![]()
Thats always good! xDwe can't open It after that...........
Ur telling me... We dunno how to figure It out yet. The whole plugin is pushed to github for now. HmmmThats always good! xD
I'm pretty sure its possible now in 1.0.8.Did this ever get solved?interested to have it.