having problems trying to refine the user instancing, does blender/python do it’s own user instancing?
like if I have 30 objects sending messages to one object and that one object is set to perform a task (lets say subtract 1 from an int property) for each message, but each object may be sending it’s message at nigh the exact same time or exactly the same time. if they all happened at exactly the same time would the outcome be int -1 OR int -30?
The point of user instancing is to allow multiple objects/players to all have access to a single field, property or object to tell it to do something, and to tell the objects/players what to do while waiting for access (also known as I/O programming).
Currently I tried looping two functions triggered by a starter function.
like this: (where wait is a bool property, and WaitBool is a property actuator, Num is a int property, and subtract is a property actuator set to add -1 to Num)
def Check():
if sens.positive:
def goTo():
if own.get("Wait") == "TRUE":
goToLoop()
def goToLoop():
if own.get("Wait") == "FALSE":
WaitBool.setValue("TRUE")
cont.activate(WaitBool)
cont.deactivate(WaitBool)
cont.activate(subtract)
cont.deactivate(subtract)
WaitBool.setValue("FALSE")
cont.activate(WaitBool)
cont.deactivate(WaitBool)
else:
goTo()
goToLoop()
but I’m getting an error (“RuntimeError: maximum recursion depth exceeded”) which is telling me that although the code is switching the Wait to false the script cannot see that it became false during it’s looping. this leaves me to have to run it again for the desired effect.
I have another way to deal with it that’s more complex and I’m trying to avoid it, it involves using the message body to send a unique object/user name then pairing this name with the requirements into a list, which requires the following list editing skills (from easiest to hardest):
1: writing to a text entry in virtual memory to treat as a list
2: reading from a text list; text.split(", ")[entry #]
3: adding an entry to the end of the list; text + ", “+ entry
4: removing an entry from the start of the list; text.split(text.split(”, ")[0])[1]
and the biggest problem is that this requires user instancing of it’s own, because multiple requests are being made on one object.
the second problem is what if text[0] is the same as other text in the list? for example the same object/user spams a message, the second message would cut off all messages following it from being retained from all users.
this requires the addition of message timing to the list where each entry is [user, message, time] instead of [user, message]
this requires message sorting based on time when writing to the list.
and even then you have the problem of 170+ computer controlled objects all spamming their message at the exact same time. so what does that need? User Instancing! now each user not only has a name but a number designated to filter their own spammy requests. so the entry becomes [#, user, message, time] from where it has to know if it should filter it as a duplicate or add it to the list. If it adds it to the list then it needs to record how many iterations of this message are open and where to find them in the list, and needs to do that for each user.
suddenly the user instancing object is a mess, because all these entries need to be stored outside the script so that they can be referenced by another script when it runs to check what to do next. that means massive amounts of file writing OR storing it in a logic brick. as the number of users may change or be randomly massive that means creating one ‘port’ for each user which in this case is a file, globalDict entry (globalDict is also a file so I avoid it, I try to stay in memory or virtual memory to keep from wearing out the hard drive) or a logic brick.
so, Help. Please.
does blender/python do it’s own message sorting/prioritization? (AKA am I making this hard on myself by not trusting Blender/python’s inherent code handling capabilities?)
or is there a better way to do user instancing?