ID:263744
 
I can't seem to figure this out. I know the solution is that I'm a noob at this but here goes.

Code:
        get()
set src in usr.loc
var
obj/group/O = locate(src.type) in usr.contents
obj/group/P
if(!O)
src.Move(usr)
src.NumUpdate()
else
for(O)
if(!O.num >= O.max_num)
P = O
if(!P)
src.Move(usr)
src.NumUpdate()
else
P.NumAdd(src.num)
P.NumUpdate()
del src


Problem description:
I pick up 50 of an item.
I pick up 1 of an item and it move it to my inventory.
I pick up 4 more and it moves them to my inventory instead of grouping them.
I'm trying to do an item grouping snippet but it doesn't find 'P' and therefore won't group anything. I know it's probably an easy solution but I can't get it to work...
You almost certainly need brackets around that if(!O.num etc. in any case, so that it's if(!(O.num...)).
In response to Hazman
Hazman wrote:
You almost certainly need brackets around that if(!O.num etc. in any case, so that it's if(!(O.num...)).

Do you perhaps mean parentheses, which are what you actually used? Because brackets [ ] would be pretty dumb there.

Lummox JR
In response to Lummox JR
ARGH. What is up with you and brackets? The word 'bracket' can refer to any of (), {}, [], or <>.
Fine, what I mean is round brackets. Braaacckkkeeeetsssss. Braaaaaaaaaccccckkkkkkeeeeeettttttssssss.
In response to Hazman
Hazman wrote:
ARGH. What is up with you and brackets? The word 'bracket' can refer to any of (), {}, [], or <>.
Fine, what I mean is round brackets. Braaacckkkeeeetsssss. Braaaaaaaaaccccckkkkkkeeeeeettttttssssss.

Brackets are [ ] and ( ) are .. I forgot how to spell them XP and < > are Html Tags, or commonly just know as tags in some case. and other than the } { I dont know what they are called but they are used in php.
In response to Fusioneko
Well, this got off topic...

Thats not the problem here. I've move the parenthesis all over the place. The problem is that it won't find an object in my inventory that has a num that is less than the min_num whether or not it is true... Actual help is appreciated as well...
In response to Hazman
Hazman wrote:
ARGH. What is up with you and brackets? The word 'bracket' can refer to any of (), {}, [], or <>.
Fine, what I mean is round brackets.

No, what you mean is parentheses. The word "brackets" does not mean parentheses, and it does not mean braces. It also does not mean angle brackets, unless you use the word "angle" with it.

Lummox JR
In response to Lummox JR
Well now that the real problem has been solved...can someone lend a hand please. I really can't figure this one out...
In response to Hiro the Dragon King
Tried using a less-than-or-equal sign in the if() instead of a greater-than-or-equal sign?
In response to Lummox JR
Lummox JR wrote:

No, what you mean is parentheses. The word "brackets" does not mean parentheses, and it does not mean braces.

In British English, it's fairly common usage that () are called "brackets", [] are "square brackets", and {} are "braces" (or "curly brackets"). Though we do also use parentheses for (), in formal writing.
In response to Hazman
Yeah. I've tried every different itteration of that if statment I can, all with different effects...

Here is the whole thing...

world
mob = /mob/player

mob
Stat()
statpanel("Pack",src.contents) //inventory
player
icon = 'mob.dmi'
icon_state = "male"
var
ic = 0 //items count
maxic = 45 //max items allowed
verb
get()
var {obj/O; obj/topO}
for(O in usr.loc) topO = O
if(topO)
topO.get()
..()
drop()
for(var/obj/O in src)
O.drop()
..()
turf
dirt
icon = 'turfs.dmi'
icon_state = "dirt"

obj
verb
get()
drop()
armor
item
special
group
hair
icon = 'hair.dmi'
max_num = 50

var
num = 1
max_num

New()
src.suffix = "x[src.num]"
..()

get()
set src in usr.loc
var
obj/group/O = locate(src.type) in usr
obj/group/P = 0
if(!O)
usr << "STUPID"
src.Move(usr)
src.NumUpdate()
else
for(O)
if(!O.num >= O.max_num)
P = O
if(!P)
usr << "MOTHER"
src.Move(usr)
src.NumUpdate()
else
usr << "FUCKER"
P.NumAdd(src.num)
P.NumUpdate()
del src

verb
drop_all()
var/obj/group/O = locate(text2path("[src.type]")) in usr.contents
for(O)
O.loc = usr.loc

drop()
src.drop_all()

proc
NumUpdate()
var
new_num = src.num-src.max_num
obj/group/O = new src.type
if(src.num <= 0)
del src
if(new_num > 0)
src.num = src.max_num
O.Move(src.loc)
O.num = new_num
O.NumUpdate()
else ..()
src.suffix = "x[src.num]"

NumAdd(n as num)
src.num += n
NumUpdate()

NumSubtract(n as num)
src.num -= n
NumUpdate()