ID:1935661
 
(See the best response by Kaiochao.)
Code:
world
New()
..()
Gatherbuilds()

obj/var
builtobjects

var
list
buildables
buildselect


proc
Gatherbuilds()
buildables = new
for(var/x in typesof(/obj/buildable)-/obj/buildable)
buildables += new x

obj/buildable
var

index=""
owner
Click()
var/player/p=usr
builtobjects+=1
if(p.buildon==1)
if(p.building==0)
p.building=1
for(var/obj/buildable/B in buildables)
buildselect+=B
p<<"You've selected [B]."
B.loc=locate(p.x,p.y,p.z)

else
p.building=0
alert(p,"Would you like to build on this land for [p.buildamount]?","","Yes","No")
if("Yes")
if(p.zenni<=p.buildamount)
p.zenni-=p.buildamount
p.buildamount=0
else
alert("Not enough money!")
if("No")
for(var/obj/buildable/B in view())
del(B)
else
p<<"Building not toggled!"
return



//else
// alert("Not enough zenni!")
First_Ash
icon='Ash1.dmi'
Second_Ash
icon='Ash2.dmi'
Third_Ash
icon='Ash3.dmi'
Fourth_Ash
icon='Ash4.dmi'
Fifth_Ash
icon='Ash5.dmi'

Brick_WallOne
icon='BrickWall1.dmi'
Brick_WallTwo
icon='BrickWall2.dmi'
Brick_WallThree
icon='BrickWall3.dmi'
Brick_WallFourth
icon='BrickWall4.dmi'
Brick_WallFifth
icon='BrickWall5.dmi'
Brick_WallSix
icon='BrickWall6.dmi'
Brick_WallSeven
icon='BrickWall7.dmi'
Brick_WallEight
icon='BrickWall8.dmi'


Problem description:

runtime error: type mismatch: First Ash (/obj/buildable/First_Ash) += First Ash (/obj/buildable/First_Ash)
proc name: Click (/obj/buildable/Click)
source file: Buildables.dm,36
usr: Moise (/player)
src: First Ash (/obj/buildable/First_Ash)
call stack:
First Ash (/obj/buildable/First_Ash): Click("Building", "default.info1", "icon-x=84;icon-y=23;left=1")


I get this via Clicking an obj in my Building Tab, been trying to find out what's wrong, anyone else can help figure this out?
I feel like this code is trying to stack every obj in obj/buildable or in buildables underneath me instead of just one...
Well, that particular runtime error comes from you not initializing the 'buildselect' list.

Once you've fixed that, you might notice that a for() loop is not what you want there.
Buildselect isn't initialized
obj/var
builtobjects

var
list
buildables
mob/var
list/buildselect = list(new/obj/buildable)


proc
Gatherbuilds()
buildables = new
for(var/x in typesof(/obj/buildable)-/obj/buildable)
buildables += new x

obj/buildable
var

index=""
owner
Click()
var/player/p=usr
builtobjects+=1
if(p.buildon==1)
if(p.building==0)
p.building=1
if(p.buildoccupied==0)
for(var/obj/buildable/B in buildables)
p.buildselect+=B
p.buildoccupied=1
p<<"You've selected [B]."
B.loc=locate(p.x,p.y,p.z)
else
p.buildselect=null
for(var/obj/buildable/B in buildables)
p.buildselect+=B
p<<"You've selected [B]."
B.loc=locate(p.x,p.y,p.z)



else
p.building=0
alert(p,"Would you like to build on this land for [p.buildamount]?","","Yes","No")
if("Yes")
if(p.zenni<=p.buildamount)
p.zenni-=p.buildamount
p.buildamount=0
else
alert("Not enough money!")
if("No")
for(var/obj/buildable/B in p.client.screen)
del(B)
else
p<<"Building not toggled!"
return


It gather's every obj/build and stacks it-atop each other.

:/ Might've messed up abit here.
In response to HaxRp
HaxRp wrote:
It gather's every obj/build and stacks it-atop each other.

What do you think this line does:
for(var/obj/buildable/B in buildables)
In response to HaxRp
You know what it does, but you don't see why it's doing what it's supposed to do?
In response to Kaiochao
Kaiochao wrote:
HaxRp wrote:
It gather's every obj/build and stacks it-atop each other.

What do you think this line does:
> for(var/obj/buildable/B in buildables)
>


True, but I want it to recognize the "B" that I click instead of every B in the buildables list.
In response to Kaiochao
Kaiochao wrote:
You know what it does, but you don't see why it's doing what it's supposed to do?

confused on how to fix it*
src is the 'B' you want. src is the object you clicked.
In response to Kaiochao
Oh..wow, nvm. Just caught on.
In response to Super Saiyan X
Super Saiyan X wrote:
src is the 'B' you want. src is the object you clicked.

Yeah just remembered that after giving it a hard look, thanks. xD
Furthermore, you don't want to move src itself.
Src is the object you clicked - you want to create a new object of the same type as the object you clicked.
Had to bring this back up, fixxed the problem involving src, but now it gives me another runtime error.

runtime error: Cannot create objects of type /obj/buildable/First_Ash.
proc name: Click (/obj/buildable/Click)
source file: Buildables.dm,39
usr: Oi (/player)
src: First Ash (/obj/buildable/First_Ash)
call stack:
First Ash (/obj/buildable/First_Ash): Click("Building", "default.info1", "icon-x=99;icon-y=15;left=1")

mob/var
building=0
buildamount=0
buildoccupied=0
world
New()
..()
Gatherbuilds()

obj/var
builtobjects

var
list
buildables
var
list/buildselect


proc
Gatherbuilds()
buildables = new
for(var/x in typesof(/obj/buildable)-/obj/buildable)
buildables += new x

obj/buildable
var

index=""
owner
Click()
var/player/p=usr
builtobjects+=1
if(p.buildon==1)
if(p.building==0)
p.building=1
if(p.buildoccupied==0)

buildselect+= new src
p.buildoccupied=1
p<<"You've selected [src]."
src.loc=locate(p.x,p.y,p.z)
else
buildselect=null
buildselect+= new src
p<<"You've selected [src]."
src.loc=locate(p.x,p.y,p.z)
// this
new src

// should be
new type

But really, this entire code has a bunch of unnecessary redundancies contained inside itself, and the logic behind it isn't clear.

When a player clicks an /obj/buildable in their statpanel, what should happen? From the looks of it, you're selecting the object, but for some odd reason, you're also changing its location as if you wanted to build it. Why are you doing both? What's the point of selection?
Best response
This is as simple as it gets for building from a statpanel:
var
buildables[] = new_typesof(/obj/buildable)

proc
new_typesof(parent)
. = list()
for(var/type in typesof(parent)-parent)
. += new type

obj/buildable
Click()
usr << "You build [src]."
new type (usr.loc)
In response to Kaiochao
If you want to create the buildable whenever you move, you just have to modify it a tiny bit and add on a couple extra things.
var
buildables[] = new_typesof(/obj/buildable)

proc
new_typesof(parent)
. = list()
for(var/type in typesof(parent)-parent)
. += new type

obj/buildable
// when clicked, select it
Click()
// only select buildables from the list (not from the map)
if(src in buildables)
var player/p = usr
p.BuildSelect(type)

player
var
// a way to remember what this player is building, if anything
build_type

Move()
. = ..()

// if we successfully moved and we're building something, build it
if(. && build_type)
Build()

proc

// when a player selects a build type,
BuildSelect(Type)

// remember what that type is,
build_type = Type

// and immediately build it (unless it's nothing)
if(Type) Build()

Build()
src << "You build [new build_type (loc)]."

There's no way to deselect a buildable yet, but you'd just call BuildSelect() without anything in the parentheses (AKA call it without arguments).
It doesn't seem to spawn anything via movement.

player
var/build_type
Move(loc, dir)

if(frozen || combat && combat.resting || !combat || combat.is_jumping|| training )
return 0

if(combat.block)
dir = dir
return 0

var/mob/user = src

user.moving = 1

user.move_delay = user.move_del
if(. && build_type)
Build()
if(user.combat.battlemode)
user.move_del -= 1.2
if(user.fly==1)
user.icon_state="Flight"


.=..(loc,dir)

user.last_moved = world.timeofday


spawn(user.move_delay)
if(user) user.moving = 0


var/tag/teleport/teleport = locate() in user.loc
if(teleport)
teleport.Access(src)
proc
BuildSelect(Type)
// remember what that type is,
build_type = Type

// and immediately build it (unless it's nothing)
if(Type) Build()


Build()
var/mob/user = src
new build_type (user.loc)


world
New()
..()
new_typesof()

obj/var
builtobjects

var
buildables[] = new_typesof(/obj/buildable)

proc
new_typesof(obj/buildable)
. = list()
for(var/type in typesof(/obj/buildable)-/obj/buildable)
. += new type



obj/buildable
var

index=""
owner
Click()
if(src in buildables)
var/player/p=usr
if(p.buildon==1)
if(p.building==0)
p.building=1
if(p.buildoccupied)
p.buildoccupied=1
p<<"You've selected [src]."
p.BuildSelect(type)
new type (usr.loc)
else

p<<"You've selected [src]."
p.BuildSelect(type)
new type (usr.loc)
Page: 1 2