Talking Weapon

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Talking Weapon

Post by kelly1111 »

Hello There,

I'm pretty new at scripting. And have a question about generating a talking weapon. When I say pretty new. I mean : I don't have to faintest idea how to start :)

I want to create a weapon that talks to the player when it is equiped. Do I use a onequiphook?
And what kind of script would I make (and where to place it) to get the talking part completly random (every once in a while)

Can u guys get me started with an example ? ... I would love to puzzel with it myself if I get a head start :)
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Talking Weapon

Post by Neikun »

I think.. you could use the onEquip hook to activate a timer with a lengthy interval that activates a random phrase script. You could use the onUnequip hook to deactivate the timer.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Talking Weapon

Post by Komag »

You would probably want to put all the phrases into a big table talkTable = { }, then whenever the timer fires off have the script pull a random table element and hudPrint it
hudPrint(talkTable[math.random(1,#talkTable)])
Finished Dungeons - complete mods to play
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Talking Weapon

Post by kelly1111 »

Thanks. so far I tried this for testing. but it gives an error.
what does this error mean. ive linked it to a presure plate to test it

error: attempt to get a lenght of a global 'talktable' (a nil value) X

function talkingweapon()

talkTable = {"kill kill kill", "hate hate hate", "pain pain pain" },
hudPrint(talkTable[math.random(1,#talkTable)])

end
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Talking Weapon

Post by Komag »

maybe that extra comma at the end of the table line is causing the problem. Also, if the table isn't going to change, you might want to put it outside the function, like right before it, so it gets defined at map start.
Finished Dungeons - complete mods to play
Post Reply