ID:179404
 
how do i make it so like the list can have a max of 10 things in it, and if the user wants to add another thing to it, it gets rid of the oldest thing on the list?

seccond, how do i clear a list? like, empty it, without knowing whats in it..... that might sound kinda wierd, but is there a way, if so, how?
dbz73 wrote:
how do i make it so like the list can have a max of 10 things in it, and if the user wants to add another thing to it, it gets rid of the oldest thing on the list?

if(list.len == 10)
list.Cut(1,2) //snip out the first list item
list += item //and add the new item onto the end


seccond, how do i clear a list? like, empty it, without knowing whats in it..... that might sound kinda wierd, but is there a way, if so, how?

There are two ways.

One:

list.len = 0

Two:

for(var/X in list)
list -= X
In response to Spuzzum

if(list.len == 10)
list.Cut(1,2) //snip out the first list item
list += item //and add the new item onto the end


list.len = 0


ok is list.len just an example or is that what i really type?
In response to dbz73
ok is list.len just an example or is that what i really type?

I don't hand out code. It's an example. =)

You need to put that code, properly indented and with 'list' referring to the appropriate list, in the place where you want to clear the list.
In response to Spuzzum
runtime error: Cannot read null.len.
proc name: Chat (/mob/verb/Chat)
usr: the dbz73 (/mob)
src: the dbz73 (/mob)
call stack:
the dbz73 (/mob): Chat("hello?")
runtime error: type mismatch



and it doesnt show up where it is supposed to

EDIT: this is the area i think would be giveing me problems

mob/verb/Chat(T as text)
if(usr.Chating==1)
if(usr.ATT==1)
var/M="<font color=blue>< </font><font color=white>[usr]</font><font color=blue> > <font color=white>[html_encode(T)]</font>
"
if(Q.len == 10)
Q.Cut(1,2) //snip out the first list item
FloodBlock()
FloodCheck()
Q+=M
else
usr << "You have had the privlage to talk taken away!"
else
usr << "You are not currently chatting!"


I get no errors compileing
In response to Spuzzum
Go in dream maker and look up const vars.
In response to dbz73
mob/verb/Chat(T as text)
if(usr.Chating==1)
if(usr.ATT==1)
var/M="<font color=blue>< </font>\
<font color=white>
[usr]</font><font color=blue> > \
<font color=white>
[html_encode(T)]</font><br>"
if(Q.len == 10)
Q.Cut(1,2) //snip out the first list item
FloodBlock()
FloodCheck()
Q+=M
else
usr << "You have had the privlage to talk taken away!"
else
usr << "You are not currently chatting!"


You need to initialise Q. There is no problem with this code.

(You should compile your game in DEBUG mode. Go to Build|Preferences to turn it on.)
In response to Spuzzum
I activated it i belive, i put

var/list/Q

in the top of my code, and it doesnt work..... still, i did that debug mode thing
In response to dbz73
uggg no matter what i do i always get this

runtime error: Cannot read null.len.


heeeeeelp please
In response to dbz73
Look up const vars
In response to dbz73
dbz73 wrote:
I activated it i belive, i put

var/list/Q

in the top of my code, and it doesnt work..... still, i did that debug mode thing

Nope. It has to be an actual new list. That is, at run time, you have to actually create the list.

All var/list/Q does is set aside a place where a list could later be put in memory. It is up to you to make that list a reality by using the list() proc.

mob/var/list/Q

mob/New()
Q = list()
..()
In response to Super16
Super16 wrote:
Look up const vars

I already did, it didnt really help much, ill look again.
In response to Super16
Super16 wrote:
Look up const vars

Const vars have nothing to do with this situation. What are you talking about exactly?
In response to Spuzzum
mob/var/list/Q
>
> mob/New()
> Q = list()
> ..()


the list is a world list, not a usrs list
In response to dbz73
dbz73 wrote:
mob/var/list/Q
> >
> > mob/New()
> > Q = list()
> > ..()

the list is a world list, not a usrs list

Well then make it belong to var/list/Q and world/New(). =P
In response to Spuzzum
Spuzzum wrote:
dbz73 wrote:
mob/var/list/Q
> > >
> > > mob/New()
> > > Q = list()
> > > ..()

the list is a world list, not a usrs list

Well then make it belong to var/list/Q and world/New(). =P

I did that before i read this belive it or not =) but it didnt work =( now all it wont even show the list, it just shows /list instead of showing what is in the list =(
In response to dbz73
I did that before i read this belive it or not =) but it didnt work =( now all it wont even show the list, it just shows /list instead of showing what is in the list =(

That's what lists do when you output them. You need to output everything in them using a for() loop.
In response to Spuzzum
Spuzzum wrote:
That's what lists do when you output them. You need to output everything in them using a for() loop.

can you show me an example of how to do this? the F1 help for it confused me
In response to dbz73
dbz73 wrote:
Spuzzum wrote:
That's what lists do when you output them. You need to output everything in them using a for() loop.

can you show me an example of how to do this? the F1 help for it confused me

for(var/obj/O in list)
usr << O
In response to Spuzzum
Spuzzum wrote:

for(var/obj/O in list)
usr << O

Doh! thats confuseing too.
Page: 1 2