ID:150811
 
I have tried a few different things, but the closest I can get is using view().
I want it to where only a certain kingdom can here the chat, no matter were at in the world. Is this possible?
Thanx,
Obliv
On 7/23/01 1:08 pm Oblivian wrote:
I have tried a few different things, but the closest I can get is using view().
I want it to where only a certain kingdom can here the chat, no matter were at in the world. Is this possible?
Thanx,
Obliv

Create a list for each team:

var/list
donutheads
spatulettes
thundermuffins

Initialize the lists:

world
New()
donutheads = new()
spatulettes = new()
thundermuffins = new()

Add a team variable to your mobs:
mob
team

Have a proc to add members to a team:

proc/add_team(who, which_team)
switch(which_team)
if("donutheads")
donutheads.Add(who)
else if("spatulettes")
spatulettes.Add(who)
else if("thundermuffins")
thundermuffins.Add(who)
else
usr << "No such team!"
return
usr.team=which_team

Finally, you can send a message to any of the teams using:

donutheads << "[usr]: [msg]" // etc.


I left out a few details for you to figure out. For example, you need to find a good way to call add_team() from user input. You also need to set up a team chat verb for yourself. If you ask me how to do either of these without trying for yourself, I will remove your kidney and replace it with a Mr. Potato-Head.

For our audience at home, please note that there is a more elegant way to do this, using a list of lists, and passing your own team variable to the send message proc to send to the proper sublist. Of course, that way I couldn't use a cool list name like "spatulettes." You gotta have your priorities...

/mob/skysaw

In response to Skysaw
On 7/23/01 1:26 pm Skysaw wrote:
On 7/23/01 1:08 pm Oblivian wrote:
I have tried a few different things, but the closest I can get is using view().
I want it to where only a certain kingdom can here the chat, no matter were at in the world. Is this possible?
Thanx,
Obliv

Create a list for each team:

var/list
donutheads
spatulettes
thundermuffins

Initialize the lists:

world
New()
donutheads = new()
spatulettes = new()
thundermuffins = new()

Add a team variable to your mobs:
mob
team

Have a proc to add members to a team:

proc
add_team(who, which_team)
switch(which_team)
if("donutheads")
donutheads.Add(who)
else if("spatulettes")
spatulettes.Add(who)
else if("thundermuffins")
thundermuffins.Add(who)
else
usr << "No such team!"
return
usr.team=which_team

Finally, you can send a message to any of the teams using:

donutheads << "[usr]: [msg]" // etc.


I left out a few details for you to figure out. For example, you need to find a good way to call add_team() from user input. You also need to set up a team chat verb for yourself. If you ask me how to do either of these without trying for yourself, I will remove your kidney and replace it with a Mr. Potato-Head.

For our audience at home, please note that there is a more elegant way to do this, using a list of lists, and passing your own team variable to the send message proc to send to the proper sublist. Of course, that way I couldn't use a cool list name like "spatulettes." You gotta have your priorities...

/mob/skysaw

Thanx for the info, I really cannot figure out how to do the proc at all, I need a way to let which kingdom they choose when first logging in to carry over to this proc.. Unless there is an different or better way that I need to do this?
It makes me mad to have to ask questions, but i'm totally stumped.. grrr
In response to Oblivian
On 7/23/01 4:33 pm Oblivian wrote:

Thanx for the info, I really cannot figure out how to do the proc at all, I need a way to let which kingdom they choose when first logging in to carry over to this proc.. Unless there is an different or better way that I need to do this?
It makes me mad to have to ask questions, but i'm totally stumped.. grrr

Post your kingdom choosing code here and I'll toss you a hint.

That part works already, right?
In response to Skysaw
On 7/23/01 6:30 pm Skysaw wrote:
On 7/23/01 4:33 pm Oblivian wrote:

Thanx for the info, I really cannot figure out how to do the proc at all, I need a way to let which kingdom they choose when first logging in to carry over to this proc.. Unless there is an different or better way that I need to do this?
It makes me mad to have to ask questions, but i'm totally stumped.. grrr

Post your kingdom choosing code here and I'll toss you a hint.

That part works already, right?

Yea it works, but I have it set up different than you may be use to.. Three doors open up into the kingdoms, if a player touchs one, two new commands pop up(open, and kingdom info).. If the player chooses open a question pops up asking if he/she is sure, anyways enough talk.. here it is:
ummitgate
icon = 'door.dmi'
icon_state = "ummit"
density = 1
verb
open()
set category = "Commands"
set src in view(1)
var/k = input("You have choosen to enter the kingdom of Ummit, are you sure?","Kingdom Selection") in list("Yes","No")
switch(k)
if("Yes")
usr.Move(locate(481,362,1))
world << "[usr] has chosen to play in Ummit!"
if("No")
usr.Move(locate(7,4,1))
verb
ummit_info()
set category = "Commands"
set src in view(1)
usr << "This is the kingdom of Ummit."

haldridgate
icon = 'door.dmi'
icon_state = "haldrid"
density = 1
verb
open()
set category = "Commands"
set src in view(1)
var/k = input("You have choosen to enter the kingdom of Haldrid, are you sure?","Kingdom Selection") in list("Yes","No")
switch(k)
if("Yes")
usr.Move(locate(445,47,1))
world << "[usr] has chosen to play in Haldrid!"
if("No")
usr.Move(locate(7,4,1))
verb
haldrid_info()
set category = "Commands"
set src in view(1)
usr << "This is the kingdom of Haldrid."

dadreegate
icon = 'door.dmi'
icon_state = "gate"
density = 1
verb
open()
set category = "Commands"
set src in view(1)
var/k = input("You have choosen to enter the kingdom of Dadree, are you sure?","Kingdom Selection") in list("Yes","No")
switch(k)
if("Yes")
usr.Move(locate(45,410,1))
world << "[usr] has chosen to play in Dadree!"
if("No")
usr.Move(locate(7,4,1))
verb
dadree_info()
set category = "Commands"
set src in view(1)
usr << "This is the kingdom of Dadree."
In response to Oblivian
On 7/23/01 8:47 pm Oblivian wrote:
ummitgate
icon = 'door.dmi'
icon_state = "ummit"
density = 1
verb
open()
set category = "Commands"
set src in view(1)
var/k = input("You have choosen to enter the kingdom of Ummit, are you sure?","Kingdom Selection") in list("Yes","No")
switch(k)
if("Yes")
usr.Move(locate(481,362,1))
world << "[usr] has chosen to play in Ummit!"
<font color="yellow">add_team(usr, "donutheads")</font>
if("No")
usr.Move(locate(7,4,1))

If you include my previous code, this will work if your Ummit population are donutheads. You may want to rename the teams ;-)

Now when you want to talk to all donutheads, you use:
donutheads << [msg]
In response to Skysaw
On 7/24/01 6:42 am Skysaw wrote:
On 7/23/01 8:47 pm Oblivian wrote:
ummitgate
icon = 'door.dmi'
icon_state = "ummit"
density = 1
verb
open()
set category = "Commands"
set src in view(1)
var/k = input("You have choosen to enter the kingdom of Ummit, are you sure?","Kingdom Selection") in list("Yes","No")
switch(k)
if("Yes")
usr.Move(locate(481,362,1))
world << "[usr] has chosen to play in Ummit!"
<font color="yellow">add_team(usr, "donutheads")</font>
if("No")
usr.Move(locate(7,4,1))

If you include my previous code, this will work if your Ummit population are donutheads. You may want to rename the teams ;-)

Now when you want to talk to all donutheads, you use:
donutheads << [msg]

Thanx for the help, I almost got it to work! just getting 1 error now tho :(

var/list
dadree
haldrid
ummit
world
New()
dadree = new()
haldrid = new()
ummit = new()
mob
team
proc/add_team(usr, which_team)
switch(which_team)
if("dadree")
dadree.Add(who)
else if("haldrid")
haldrid.Add(who)
else if("ummit")
ummit.Add(who)
else
usr << "No such team!"
return
usr.team=which_team

turfs.dm:204:error:usr.team:bad var
turfs.dm:195::warning: empty switch statement

I should know what this is... I havn't ever had this error before tho..
In response to Oblivian

proc/add_team(usr, which_team)
switch(which_team)
if("dadree")
dadree.Add(who)
else if("haldrid")
haldrid.Add(who)
else if("ummit")
ummit.Add(who)
else
usr << "No such team!"
return
usr.team=which_team

turfs.dm:195::warning: empty switch statement

The if("dadree") etc should be indented. Erm.. Must post without emoticons.. 0()hAJH!
In response to Oblivian
On 7/24/01 10:50 am Oblivian wrote:
mob
team

From reading this thread, it looks like you want to create a mob variable called team, right? The above code doesn't do that, it creates a new type of mob called team. You want to declare team as a mob variable, so change that one line to var/team.

proc/add_team(usr, which_team)

(as far as I know) You can't have usr in the declaration of a proc because usr is a special variable. Also see recent posts in Design Philosophy on why it's generally bad to use usr. Anyway, you can always put usr in when you call a proc from another proc, but not when you first declare that proc. I would change the above to something like:

proc/add_team(mob/adduser, which_team)

That does two good things: one, it uses the variable name "adduser" instead of usr, which is ambiguous and can get you into trouble. Two, it tells the compiler that adduser is a mob, so you can reference any mob variable or proc any place you have adduser within add_team(). Now, you would just replace occurrances of usr with adduser down below.

switch(which_team)
if("dadree")
dadree.Add(who)
else if("haldrid")
haldrid.Add(who)
else if("ummit")
ummit.Add(who)
else
usr << "No such team!"
return
usr.team=which_team

As Vortezz pointed out, the if statements under switch() need to be indented. Read up a little bit on switch(). You'll find that you don't need the else parts of "else if(..)". You just need the last else. It might look something like this:

switch(which_team)
if("dadree")
dadree.Add(who)
if("haldrid")
haldrid.Add(who)
if("ummit")
ummit.Add(who)
else
adduser << "No such team!"
return
adduser.team=which_team

Finally, what is the variable "who" and where is it defined? I don't see that anywhere. I'm guessing you really wanted adduser instead of who.

turfs.dm:204:error:usr.team:bad var

See my first comment.

turfs.dm:195::warning: empty switch statement

Vortezz's comment on indentation.

Hope this helps!
In response to Air Mapster
On 7/24/01 11:22 am Air Mapster wrote:
proc/add_team(usr, which_team)

(as far as I know) You can't have usr in the declaration of a proc because usr is a special variable....

&

Finally, what is the variable "who" and where is it defined? I don't see that anywhere. I'm guessing you really wanted adduser instead of who.

Both of these were handled in the original proc I wrote for Oblivian. The proc should not have been put under the mob, and "who" was the mob passed to the proc.
In response to Skysaw
On 7/24/01 11:28 am Skysaw wrote:
Both of these were handled in the original proc I wrote for Oblivian. The proc should not have been put under the mob, and "who" was the mob passed to the proc.

Aha. Then I guess he should have listened a little more carefully...
In response to Vortezz
On 7/24/01 11:06 am Vortezz wrote:
proc/add_team(usr, which_team)
switch(which_team)
if("dadree")
dadree.Add(who)
else if("haldrid")
haldrid.Add(who)
else if("ummit")
ummit.Add(who)
else
usr << "No such team!"
return
usr.team=which_team

turfs.dm:195::warning: empty switch statement

The if("dadree") etc should be indented. Erm.. Must post without emoticons.. 0()hAJH!

Ok, thanx alot all.. I can figure the rest out(which you all told me :))