Timer.Repeat( delay, times, function() ) in Python?
Discussion in 'Rust Development' started by TheRotAG, Feb 1, 2015.
-
Wulf Community Admin
Spot on.
-
Problem with that code in Python.
delay is ok, times also... no about Functions() and what it does the issue comes...
tried timer.Repeat( 5, 0, self.PrintThis ) and it worked the first time, but didnt repeat... istead is gave me:
[Oxide] 7:43 PM [Error] RadtownEvent: ArgumentTypeException while calling OnServ
erInitialized: Invoke() takes exactly 4 arguments (3 given) -
but not sure that it's good for PythonCode:
timer.Repeat( 5, 0, self.PrintThis, self.Object )
-
With self, self.PrintThis it worked for the first time and the error was:
[Oxide] 8:43 PM [Error] Failed to run a timer. (MissingMemberException: RadtownE
vent instance has no __call__ method) -
Code:
import System from System import Actionclass Test: def __init__(self): self.Title = "Test Plugin" self.Author = "Nogrod" self.Version = V(1, 0, 0) self.HasConfig = True def OnServerInitialized(self): def my_callback_func(): print "Timer: " + self.Title timer.Once(1.0, Action(my_callback_func), self.Plugin ) timer.Once(1.0, Action(self.other_callback), self.Plugin ) timer.Repeat(1.0, 5, Action(my_callback_func), self.Plugin ) timer.Repeat(1.0, 5, Action(self.other_callback), self.Plugin ) def other_callback(self): print "Other Timer: " + self.Title -
Oohh, that "Action()" is from python or from our library?
-
It's from .NET
