home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


Some CubeScript questions

by Papriko on 01/12/2011 18:19, 21 messages, last message: 03/06/2011 18:42, 3695 views, last view: 05/10/2024 18:20

Well, my questions are simple:
If I create a list, lets say
x = [1 2 3 4 5]
how do I find certain values in it, how do I add new and how to remove them? If it helps: for now I am going to use only numbers.

What I also wanted to know: is there a way to let a script "watch" the chat and only react on certain keywords? If yes how? And can I/it also determine who said it (local message via echo, actual chat, teamćhat, server broadcast, etc...)?

I already thank everybody in advance for answering!

   Board Index    Go to next 20 messagesGo to last 20 messages

#1: ..

by Razgriz on 01/12/2011 23:26

to get a specific value from a list, use:
(at $list <pos starting from 0>)

if you need to get the position of an item from a list, use:
(indexof $list <item>)

to add an item to a list, do:
list = (concat $list <item>)

to remove a value, well, that's a bit harder. depending on your skill of cubescript, i could suggest something more elegant, but i'll give a pretty simple example. do not use the dots:

looplist i $list [
....if (!=s $i <item to be removed>) [ // =s is a shortcut for the STRCMP command, the ! is used as NOT
........list_temp = (concat $list_temp @i) //the @ is used when in need to grab the value of a variable from within a child bracket where i could have changed value, for example, in loops using sleep
....]
]



reply to this message

#2: ..

by Papriko on 01/13/2011 17:36

Yep, works perfectly, thanks. I am even understanding what\'s done there.
Now I can do a little more again with my scripts. I was planing something where I need a list as \"mastervalue\" to handle a bunch of others...

reply to this message

#3: i think...

by |ice|sub-zero|L on 01/15/2011 05:36

it may be possible if you make a small server mod which reacts to certain commands, say someone decided to use a "vulgar" word, it can say "mrblank said a vulgar word, and as punishment he is to muted for a full hour"

however as for cubescript, i don't think so unless you made yourself a "bot" in a way. (look in quadropolis.us for the "auto sorry script" that makes you say sorry when you frag a teamate)

CS is pretty powerful, i just don't know if that is possible unless you either make a server mod or are in the server at the time.

reply to this message

#4: ..

by Papriko on 01/15/2011 17:01

Yes, I saw the auto-sorry-script before and directly downloaded it. Sadly it is not listening to the chat or something like that. It is just permanently comparing your score with the total kills you made or something like that.

reply to this message

#5: ..

by srbs on 01/18/2011 23:25

fyi papriko, you can use:
(listdel <list> <list of items to remove>)

reply to this message

#7: ..

by Papriko on 01/26/2011 17:52

Okay, new question: does SB only have lists, or are arrays supported too?

reply to this message

#8: Re: ..

by Razgriz on 01/26/2011 21:23, refers to #7

is there much of a difference between the two? >_>

reply to this message

#9: Re: ..

by srbs on 01/26/2011 23:31, refers to #8

Razgriz: omg yes there is.
Papriko: No arrays, cubescript only has lists.

reply to this message

#10: ..

by Papriko on 01/27/2011 19:07

I had another idea to the arrays: For example if I wanted a 5*5 "array", could I take 5 lists where each has 5 objects and stick those in some kind of master-list? Example:

listA = [1 2 3 4 5]
listB = [5 4 3 2 1]
listC = [6 6 6 6 6]
listD = [0 1 0 1 0]
listE = [9 8 7 6 5]
Masterlist = [listA listB listC listD listE]

reply to this message

#11: Re: ..

by Razgriz on 01/27/2011 21:05, refers to #10

masterlist = (concat $listA $listB ..) ?

reply to this message

#12: ..

by Papriko on 01/27/2011 22:11

Naw, I mean it so:
echo Masterlist
listA listB listC listD listE

By your code do I get this:
echo Masterlist
1 2 3 4 5 5 4 3 2 ...

So I could nest the looplist command for example. Inside the looplist for the master one, is another looplist command which runs over listA to listE, that was the plan.

reply to this message

#13: Re: ..

by srbs on 01/28/2011 04:26, refers to #12

So, if you want to do that, what is your question?
(fyi, yes you can do that)

reply to this message

#14: sandbox

by Hirato Kirata on 01/28/2011 13:01

I did write up some stuff for cubescript lists in sandbox's wiki; you may find it useful

http://sandboxgamemaker.com/wiki/index.php?title=Cubescript#Lists

reply to this message

#15: Re: sandbox

by Razgriz on 01/28/2011 15:17, refers to #14

maybe we should refrain from the fact that "some" parts of this are outdated or do not apply in sauer? i did spot a couple of them.

reply to this message

#16: ..

by Papriko on 01/28/2011 17:08

@ srbs: My question was if that, what I said in my last post, is actually possible. I wanted to run a looplist-command inside a looplist-command, but in order to do that I need some lists inside the list. Question now: CAN I stack them in each like that?

reply to this message

#17: Re: ..

by srbs on 01/28/2011 19:01, refers to #16

@Papriko: yup
looplist i $masterlist [
looplist j (getalias $i) [
echo $j
]
]

@Hirato: Yeah, either prettylist has changed significantly in sandbox, or you have no idea what it does.

reply to this message

#18: Re: ..

by SheeEttin on 01/28/2011 19:30, refers to #16

Yes, I think so. Something like:

loop i (listlen Masterlist) [looplist (at Masterlist i)]

...where looplist is your function.

You could also do it recursively, but you'd need something to tell whether something was a list-element or a data-element.

reply to this message

#19: Re: ..

by SheeEttin on 01/28/2011 19:33, refers to #18

Hah wow. 29-minute ninja. (My excuse: the dog wanted its walk.)
I'll also take this opportunity to correct a mistake I made: that last "i" should be "$i".

Also, Razgriz: It's a wiki, you're free to correct it. :P

reply to this message

#20: Re: ..

by Razgriz on 01/29/2011 11:10

@SheeEtin: not much point in correcting a wiki of a game i don't play, regardless of its activity state :P

@Papriko: what srbs said.

forgot to post this last night, heh

reply to this message

#21: Severs on a mac

by seb1010 on 02/25/2011 15:33

How to create a server on mac? I saw how one makes on Windows but I cannot how make on mac.

reply to this message

   Board Index    Go to next 20 messagesGo to last 20 messages


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
54039263 visitors requested 71819985 pages
page created in 0.020 seconds using 9 queries
hosted by Boost Digital