Jump to content

Scripting Question/Help


KaelVirum

Recommended Posts

Ok, to expand on my very first question here, so that you guys don't think I'm just trying to have someone else do my work for me, I have written my first script and I would like someone who knows how to script properly to go over it and tell me if my script is correct or not. If you have advice to make it work, if it's not going to, or if you don't have advice but know what's causing it to not function properly please let me know.

 

Here's the thing: I've created a race that is 0.25 in height and I have created Sandbox items that are scaled to them. I'm trying to restrict this race (for the purposes of this question I will call the race 0.25 as it's not really a WIP if I can't get this script to work) from using normal sized Sandbox Items while still allowing them the use of the Sandbox Items that are their size. I also want to restrict the normal races from use of the smaller Sandbox Items while still allowing their use of the normal SandBox Items. I've also taken into account new races added by other mods that might be able to use Sandbox items with my script so that it should restrict all normal NPCs from accessing smaller Sandbox items and vice versa.

 

Here's what I have so far of the script:

 

ScriptName RestrictRaceScript extends ObjectReference
Event onActivate(objectReference Bedroll010.25) This is the special bedroll I created for my race.
int Function GetRace() global
if GetRace() == 0.25Race
Bedroll010.25.BlockActivation(False) This should allow 0.25Race to use the item, if I'm correct.
else
Bedroll010.25.BlockActivation(True) This should keep all other races from using the item, if I'm correct.
endif
endFunction
endEvent
Event onActivate(objectReference Bedroll01) This is just a regular bedroll.
int Function GetRace() global
if GetRace() == 0.25Race
Bedroll01.BlockActivation(True) This should keep my race from using this item, if I'm correct.
else
Bedroll01.BlockActivation(False) This should allow any other race able to use this item, if I'm correct.
endif
endFunction
endEvent

 

I have studied scripting tutorials for days now trying to figure out how to do this. If you can see a flaw, even if it's a minor thing like a space where it's not needed, please inform me or if my code will not work please at least let me know why. Thank you to anyone that is able to help.

Link to comment
Share on other sites

That's not what blockactivation does. BlockActivation prevents the firing of the defauly behavior of the activator for all subsequent attempts. It doesn't do it on a per-actor basis (so if you block activation of an object, you do it for everybody, not just for your race. Also by the time an OnActivate script block is being executed, the default behavior has already begun, so running blockActivation at that point will only block future activations.
Link to comment
Share on other sites

Have you not considered playing with a default package on your race?

 

You could add a unique keyword to the 0.25 Idles

 

You create two default packages, one that disallows use of Idles and one that allows it if conditions are met (has keyword).

 

I'm sure the answers maybe slightly more complex than my notion, but that's how I would approach the problem myself. Of course I'm being hypothetical here.

Link to comment
Share on other sites

Lol, that does sound rather simple, doesn't it? We toyed around with setting conditionals on the default sandboxing package but found that the characters would still use the oversized items. We never thought to try that and it just seems so simple. The simplest answer is always the hardest to find. XD

Link to comment
Share on other sites

Ok, definitely major thanks to those who responded. I managed to figure out how to do what I was trying to do and I ended up not even needing a script for it, Yay! For anyone looking to do something similar with a small(er) race here's how I kept my 0.25 Race from utilizing idle markers that were too big for them without needing a script. I created duplicates of the idle markers (I haven't done all of them, just the ones I used to test, so far) and removed the keyword "RaceToScale" from the duplicates. I then went into my 0.25 Race and removed the Keyword "ActorTypeNPC" I created my own "actor type" keyword and applied that to my race but I also had to attach the keyword "ActorTypeCreature" to keep them from using the big stuff. Once that was done, I went into my duplicate markers (renamed to suit my needs) and changed the interaction type from "ActorTypeNPC" to "ActorType0.25". I have not yet tested whether this will keep the normal sized Races from using the smaller objects but it does keep my smaller race from using the normal idles while still allowing the use of their smaller idles. Of course, I've run into a different problem now so may ask for help if I can't figure out how to make that go away.

Link to comment
Share on other sites

Ok, definitely major thanks to those who responded. I managed to figure out how to do what I was trying to do and I ended up not even needing a script for it, Yay! For anyone looking to do something similar with a small(er) race here's how I kept my 0.25 Race from utilizing idle markers that were too big for them without needing a script. I created duplicates of the idle markers (I haven't done all of them, just the ones I used to test, so far) and removed the keyword "RaceToScale" from the duplicates. I then went into my 0.25 Race and removed the Keyword "ActorTypeNPC" I created my own "actor type" keyword and applied that to my race but I also had to attach the keyword "ActorTypeCreature" to keep them from using the big stuff. Once that was done, I went into my duplicate markers (renamed to suit my needs) and changed the interaction type from "ActorTypeNPC" to "ActorType0.25". I have not yet tested whether this will keep the normal sized Races from using the smaller objects but it does keep my smaller race from using the normal idles while still allowing the use of their smaller idles. Of course, I've run into a different problem now so may ask for help if I can't figure out how to make that go away.

Always good to share ;)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...