MF99K Posted April 8, 2016 Share Posted April 8, 2016 I'm working on a mod and I'd like to be able to make this one creature have a different name chosen at random every day. Sort of like the pigmen, but have it so that the name changes every once in a while. example: instance of the prefab day 1: Jason day 2: George day 3: Paul day 4: etc from a list of names Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/ Share on other sites More sharing options...
Kzisor Posted April 8, 2016 Share Posted April 8, 2016 Added the named component to the prefab, then set the name like pigmen. Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-746794 Share on other sites More sharing options...
DarkXero Posted April 8, 2016 Share Posted April 8, 2016 (edited) This is what the Moose Goose does. It picks Moose or Goose. local function rename(inst) inst.components.named:PickNewName() end inst:AddComponent("named") inst.components.named.possiblenames = {STRINGS.NAMES["MOOSE1"], STRINGS.NAMES["MOOSE2"]} inst.components.named:PickNewName() inst:DoPeriodicTask(5, rename) Edited April 8, 2016 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-746984 Share on other sites More sharing options...
MF99K Posted April 8, 2016 Author Share Posted April 8, 2016 (edited) 6 hours ago, Kzisor said: Added the named component to the prefab, then set the name like pigmen. But I mean, that would give the thing a name from a list of names, but the name wouldn't randomly change. @DarkXero and that would allow the name to change at random? Edited April 8, 2016 by mf99k Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-746985 Share on other sites More sharing options...
Aquaterion Posted April 8, 2016 Share Posted April 8, 2016 2 minutes ago, mf99k said: But I mean, that would give the thing a name from a list of names, but the name wouldn't randomly change. @DarkXero and that would allow the name to change at random? yes PickNewName picks a random name from the "possiblenames". Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-746987 Share on other sites More sharing options...
DarkXero Posted April 8, 2016 Share Posted April 8, 2016 9 minutes ago, mf99k said: and that would allow the name to change at random? inst:DoPeriodicTask(5, rename) A function that picks a new name is ran every 5 seconds. You can set it to 480, which is a day's duration. Or you can make it like: inst:WatchWorldState("cycles", rename) A cycle is completed when a day is completed. (Game goes from Day 1 to Day 2) Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-746998 Share on other sites More sharing options...
MF99K Posted April 8, 2016 Author Share Posted April 8, 2016 1 minute ago, DarkXero said: inst:DoPeriodicTask(5, rename) A function that picks a new name is ran every 5 seconds. You can set it to 480, which is a day's duration. Or you can make it like: inst:WatchWorldState("cycles", rename) A cycle is completed when a day is completed. (Game goes from Day 1 to Day 2) awesome, thanks Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-747001 Share on other sites More sharing options...
MF99K Posted April 10, 2016 Author Share Posted April 10, 2016 On 4/8/2016 at 11:01 AM, DarkXero said: This is what the Moose Goose does. It picks Moose or Goose. local function rename(inst) inst.components.named:PickNewName() end inst:AddComponent("named") inst.components.named.possiblenames = {STRINGS.NAMES["MOOSE1"], STRINGS.NAMES["MOOSE2"]} inst.components.named:PickNewName() inst:DoPeriodicTask(5, rename) could I set up the possiblenames part of the code to have the names listed directly instead of referencing strings? Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-747870 Share on other sites More sharing options...
DarkXero Posted April 10, 2016 Share Posted April 10, 2016 14 minutes ago, mf99k said: could I set up the possiblenames part of the code to have the names listed directly instead of referencing strings? Yeah, sure. possiblenames just needs a table with strings. local my_custom_names = { "Jeff", "Bob", "Berethor", "Spasmodicus, The Third", } inst.components.named.possiblenames = my_custom_names Link to comment https://forums.kleientertainment.com/forums/topic/66163-is-it-possible-to-have-a-prefab-change-examination-names/#findComment-747874 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now