generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Generating a random message, can't be explained in title

Previous Thread :: Next Thread 
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
21 Jun 2012 09:27 PM
I'm trying to make a script where it has random choices to say things. For instance, it would have a set of nouns and verbs, and a player. It would say

(Player) (verb/ed) (Preposition maybe?) (Name's) (noun).


So let's make a list of players.


PLAYERS
Pieguardian
Andmeister

VERBS
ran
jumped

PREPOSITIONS
On
Over

NOUNS
Bike
Hospital


So let's say it chooses random words to fill the correct spots so it could say something following that pattern described above,

"Pieguardian ran over Andmeister's hospital!"

This would make so much more sense if I could describe the game I was making that required this script. I need it to go off every so often so it keeps the game going. I'd say every fifteen minutes. Can someone just give me a place to start? Not do the script for me, but start it and I can try the rest? If I can't, I might come back for help.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
21 Jun 2012 09:28 PM
I would suggest to store all the possible words in a table. Sorry if not much help, I'm not as advanced on the manner.






~Leave me in the city with 50 bucks and watch me come back a millionaire~
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
21 Jun 2012 09:28 PM
"This would make so much more sense if I could describe the game I was making that required this script."


I can't, because I don't want any ideas taken. However, I will give you an in-game credit GUI if you help me.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
21 Jun 2012 09:30 PM
You should also make the table something simple to remember, if you might use it later on.

Words = {"table", etc. etc}






~Leave me in the city with 50 bucks and watch me come back a millionaire~
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
21 Jun 2012 09:31 PM
Okay. Thank you.
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
21 Jun 2012 09:32 PM
Save the preset words in different tables and then make it choose a random word from each table to construct your random statement.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
21 Jun 2012 09:32 PM
And if you take a look at sword fight tournament scripts, you might see they use a system SIMILAR to making randomized messages, except the message shows what map is chosen, etc.
But that might get you on a better track as well.






~Leave me in the city with 50 bucks and watch me come back a millionaire~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
21 Jun 2012 11:02 PM
It would be more helpful if you told us the actual idea, but I'll respect your decision to keep it private, and use your examples. Anyways, as Green suggested, I would use tables. Might be a better way, but I would do something like:

    Players = {"Pieguardian", "Andmeister"}
    Verbs = {"ran", "jumped"}
    Preps = {"on", "over"}
    Nouns = {"bike", "hospital"}
    
    while wait(900) do
    local Player = Players[math.random(1, #Players)]
    local Player2 = Players[math.random(1, #Players)]
    local Verb = Verbs[math.random(1, #Verbs)]
    local Prep = Preps[math.random(1, #Preps)]
    local Noun = Nouns[math.random(1, #Nouns)]
    local m = Instance.new("Message", Workspace)
    m.Text = Player.. " " ..Verb.. " " ..Prep.. " " ..Player2.. "'s " ..Noun.. "."
    wait(5)
    m:Destroy()
    end

Top of my head and untested, but you should get the gist of it.
 
† KMXD †
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
21 Jun 2012 11:15 PM
@Knightmare... DARN YOU!!! I started making a script myself then I glanced back and you had already finished one xD!!
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 08:48 AM
@Knight,



Thank you for your help. However, the script doesn't work. :c I already had tables so I tried to edit it to that. I think I succeeded. I just changed my table's name. Could it be that you put "while wait(900)" instead of "wait(900)?"

Players = {"Pieguardian", "Andmeister"}
Verbs = {"ran", "jumped"}
Preps = {"on", "over"}
Nouns = {"bike", "hospital"}

while wait(900) do
local Player = Players[math.random(1, #Players)]
local Player2 = Players[math.random(1, #Players)]
local Verb = Verbs[math.random(1, #Verbs)]
local Prep = Preps[math.random(1, #Preps)]
local Noun = Nouns[math.random(1, #Nouns)]
local m = Instance.new("Message", Workspace)
m.Text = Player.. " " ..Verb.. " " ..Prep.. " " ..Player2.. "'s " ..Noun.. "."
wait(5)
m:Destroy()
end
Report Abuse
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
22 Jun 2012 08:53 AM
@pie

while wait() do
end
is the same as
while true do
wait()
end

It just shortens it.

~Moo~ Happie birth dai to meh! ~Moo~
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 08:54 AM
@18,


Ah. Thank you.
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
22 Jun 2012 08:57 AM
This might be a little late, but:



Players = {"Pieguardian", "Andmeister"}
Verbs = {"ran", "jumped"}
Preps = {"on", "over"}
Nouns = {"bike", "hospital"}

while true do
local Player = Players[math.random(1, #Players)]
local Player2 = Players[math.random(1, #Players)]
local Verb = Verbs[math.random(1, #Verbs)]
local Prep = Preps[math.random(1, #Preps)]
local Noun = Nouns[math.random(1, #Nouns)]
local m = Instance.new("Message", Workspace)
m.Text = Player.. " " ..Verb.. " " ..Prep.. " " ..Player2.. "'s " ..Noun.. "."
print(m.Text) wait(5)
m:Destroy()
end



works. :/
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 08:59 AM
@Ninja,


I'll try it. Thank you!
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 09:09 AM
@Ninja,


It works! Thank you! One last question, if I want it to repeat, should I put this below the "end?"

wait(900) then repeat
Report Abuse
TehChikenHater is not online. TehChikenHater
Joined: 11 Jun 2012
Total Posts: 497
22 Jun 2012 09:12 AM
Erm maybe this for example of 1 table;

Nouns={"Apple","Cake","Computer"}

object=Nouns[math.random(1,#Nouns)]

print(object)

--TehChikenHater ლ(ಠ_ಠლ)
Report Abuse
TehChikenHater is not online. TehChikenHater
Joined: 11 Jun 2012
Total Posts: 497
22 Jun 2012 09:13 AM
@Pieguardian, for a repeat:


time=60 --Time between switches in seconds.
while wait(time) do
Players = {"Pieguardian", "Andmeister"}
Verbs = {"ran", "jumped"}
Preps = {"on", "over"}
Nouns = {"bike", "hospital"}
while true do
local Player = Players[math.random(1, #Players)]
local Player2 = Players[math.random(1, #Players)]
local Verb = Verbs[math.random(1, #Verbs)]
local Prep = Preps[math.random(1, #Preps)]
local Noun = Nouns[math.random(1, #Nouns)]
local m = Instance.new("Message", Workspace)
m.Text = Player.. " " ..Verb.. " " ..Prep.. " " ..Player2.. "'s " ..Noun.. "."
print(m.Text) wait(5)
m:Destroy()
end
end

--TehChikenHater ლ(ಠ_ಠლ)
Report Abuse
TehChikenHater is not online. TehChikenHater
Joined: 11 Jun 2012
Total Posts: 497
22 Jun 2012 09:14 AM
Also, yes I did use the other guy's code.

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)

--TehChikenHater ლ(ಠ_ಠლ)
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 09:16 AM
@Teh,


Thank you! I will give you guys credit in the game. Tell me if I forget you. I'll link to the game when I'm done.
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 10:18 AM
@Teh,


It doesn't seem to work.
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
22 Jun 2012 11:05 AM
Teh's code should work or just try this.

Players = {"Pieguardian", "Andmeister"}
Verbs = {"ran", "jumped"}
Preps = {"on", "over"}
Nouns = {"bike", "hospital"}

while wait(900) do
local Player = Players[math.random(1, #Players)]
local Player2 = Players[math.random(1, #Players)]
local Verb = Verbs[math.random(1, #Verbs)]
local Prep = Preps[math.random(1, #Preps)]
local Noun = Nouns[math.random(1, #Nouns)]
local m = Instance.new("Message", Workspace)
m.Text = Player.. " " ..Verb.. " " ..Prep.. " " ..Player2.. "'s " ..Noun.. "."
print(m.Text) wait(5)
m:Destroy()
end
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 12:36 PM
@White,


It works.
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
22 Jun 2012 12:36 PM
You're welcome.
Report Abuse
Pieguardian is not online. Pieguardian
Joined: 22 Jul 2008
Total Posts: 15807
22 Jun 2012 12:38 PM
@White,



Sorry, I meant to say thank you in that message, but then there was a floodcheck so I had to wait. :c


So thank you! :D


Only one last question, how can I get users to be the people in the game.
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
22 Jun 2012 12:40 PM
Make it get the list of Players in the game by using an onEntered Event so it can add each new player to the list and also remove people from the list if they leave.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image