SphereCommunity
Random word/name - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Random word/name (/Thread-Random-word-name)



Random word/name - Catalan_mistral - 02-14-2017 04:59 AM

I need to generate a random word or name, grabbing it ideally from a list like in sphere_names.scp, was hoping to be able to utilise the name generator for characters ie #Name_random but think that doesn't fire until the npc is placed.

Any ideas?


RE: Random word/name - Anarch Cassius - 02-14-2017 07:17 AM

The @create doesn't fire but you can use the same sort of command anywhere.

SRC.TAG0.NICKNAME=#NAMES_ORC

TARG.NAME=#NAMES_RANDOM_JUNK


RE: Random word/name - Catalan_mistral - 02-14-2017 08:59 AM

Doesn't work alas

Code:
ON=@DClick
TAG.NICKNAME=#NAMES_ORC
SRC.SYSMESSAGE <Tag.Nickname>

returns #NAMES_ORC, so no name is generated.

i can do a workaround using
Code:
[FUNCTION words_Random]
DOSWITCH <EVAL RAND(2)>
RETURN "Cat"
RETURN "Dog"
RETURN "RABBIT"
ENDDO

But adding new words/names to the list would become a pain.


RE: Random word/name - Coruja - 02-14-2017 11:56 AM

I think there's no function to generate random names from sphere_names.scp, because the name list is only called to set NPC names

but you can use an simple workaround for this
Code:
[FUNCTION GetRandomName]
SERV.NEWNPC c_pig
NEW.NAME=<ARGS>
ARGS=<NEW.NAME>
NEW.REMOVE
return <ARGS>
eg: <GetRandomName #NAMES_ORC> will return a random name from #NAMES_ORC of sphere_msgs.scp


RE: Random word/name - Catalan_mistral - 02-14-2017 12:17 PM

Lovely Coruja Thank you, exactly what i wanted Smile