Forum Discussion

tastytourist's avatar
9 years ago

[Solved] Script issue: Override works fine, but script does not (because script was doing it wrong)

I’d like to put the option to brew single cups back into the tea and coffee machines (this already exists but isn’t enabled), and while it works fine when I override the object tuning, I can’t get it to work when I script it (which I’d prefer, to avoid collisions). Can someone take a second look and maybe spot the error?


Relevant part of the tuning override:

  
14368
77667
( .. etc etc ..)




Script (plus scripthoge injector):

import services
import injector
import objects
import types

pbox_tea_single_cups_sa_instance_ids = (14368, )
pbox_coffee_single_cups_sa_instance_ids = (13168, )

pbox_teamachine_object_ids = (21256, 42603, 42604, 15558351141388958608, 15558351141388958610, 15558351141388958611, 15558351141388958612, 15558351141388958613, 15558351141388958614, 15558351141388958615, 15558351141388958616, 15558351141388958617, 12355955613677467008, 12355955613677467009, 12355955613677467010, 12355955613677467011, 12355955613677467012, )
pbox_coffeemachine_object_ids = (14484, 17785, 17786, 35692, 35693, 35713, 14486, 19552, 19553, 19554, 19556, 19557, 19558, 19560, 19561, 19562, 56999, 57000, 57001, 60654, 60659, 60661, )

def attachinteraction(sa_list, affordance_manager, sa_id):
tuning_class = affordance_manager.get(sa_id)
if not tuning_class is None:
sa_list.append(tuning_class)

@injector.inject_to(objects.game_object.GameObject, 'on_add')
def pbox_tea_single_cups_add_super_affordances_to_objects(original, self):
original(self)

if not self.guid64 in pbox_teamachine_object_ids:
return

sa_list = []
affordance_manager = services.affordance_manager()

if(isinstance(pbox_tea_single_cups_sa_instance_ids, int)):
attachinteraction(sa_list, affordance_manager, pbox_tea_single_cups_sa_instance_ids)
else:
for sa_id in pbox_tea_single_cups_sa_instance_ids:
attachinteraction(sa_list, affordance_manager, sa_id)
self._super_affordances = self._super_affordances + tuple(sa_list)

@injector.inject_to(objects.game_object.GameObject, 'on_add')
def pbox_coffee_single_cups_add_super_affordances_to_objects(original, self):
original(self)

if not self.guid64 in pbox_coffeemachine_object_ids:
return

sa_list = []
affordance_manager = services.affordance_manager()

if(isinstance(pbox_coffee_single_cups_sa_instance_ids, int)):
attachinteraction(sa_list, affordance_manager, pbox_coffee_single_cups_sa_instance_ids)
else:
for sa_id in pbox_coffee_single_cups_sa_instance_ids:
attachinteraction(sa_list, affordance_manager, sa_id)
self._super_affordances = self._super_affordances + tuple(sa_list)


(The long IDs up there are for a custom tea machine that is using the same object tuning as the base game one)

Downloads: Override / Script (including source)


Edited to add: yes, I have scripts enabled -- other (similar) scripts are working fine in parallel to the nonworkingness of this one.
  • Sounds like you're missing 14979 (based on the MTS thread). Can you confirm if that's the case and the issue is resolved?
  • Yes, thanks, it's resolved =) -- I really need to think up better names than "_object_ids" for that kind of thing .. I keep mixing up the actual definitions with the tuning IDs. >.<