ID:165389
 
Hello there.

I have been atempting to make a vesatile map maker for games.
Basically at the moment it functions like a building game on swap maps. Although the system i use at the moment is quite simple: (Click the Object you want to build in the mapping panel and it is built underneath you.) I wish to make it easier by using swapmaps
BuildFilledRectangle(turf/T1, turf/T2, item)
procedure.

In short what I want it to do is as followed:

I want:
turf/T1
to be defined by the player clicking on a locations on screen, I then want
turf/T2
to be were the player releases their mouse.
item
shall be whatever object was clicked on in the player's Mapping objects panel.

I know this is possible as it is coded into a map maker for another BYOND game.

Prehaps one o the experts could help me out or even, Lummmoz Jr.

Relevent Code blocks that will probably need to be modifed for me to acheive this may be:
mob
player
New()
..()
for(var/O in typesof(/obj/buildable/)-(/obj/buildable)) src.Buildables+=new O
var/tmp/list/Buildables=list()
var/canbuild=1


obj
buildable
var/owner="No one"
Click()
if(src in usr.Buildables)
if(usr.canbuild)
var/obj/buildable/O = new src.type(usr.loc)
O.owner=usr.key
// view(usr) << "[usr.name] builds an [O.name]."
else
if(src in view(usr))
usr << "[src.owner] built this."
verb
delete()
set src in oview(10)
set category = null
if(src.owner == usr.key || usr.ckey == "lyndonarmitage1")
del src
if(usr.ckey == "lyndonarmitage1")
owner<<"An admin has deleted one of your tiles."
else if (src.owner != usr.key && usr.ckey != "lyndonarmitage1")
usr<<"Can't delete that!"


mob
Stat()
statpanel("Stats")
stat("ByondKey:", "[src.ckey]")
stat("Location:", "[usr.x],[usr.y],[usr.z]")
// statpanel("Inventory",contents)
// stat("","You'r Inventory is were all your picked up stuff goes")
if(src.canbuild && src.z !=1 ) statpanel("Mapping Objects", src.Buildables)


That is almost all the code except for the objects themse;ves, icons and swapmap verbs.


Thanks in advance, Lyndon
You should be able to use MouseDrag to get your T1 and T2, look it up in the reference.
In response to Hazman (#1)
Ah Mousedrag.
I was looking up MouseUp and MouseDown.
May I ask which versoion to pick, should it be atom or Client as it is the client who is doign the clcking?

Also Thanks I suspect I can do the other thing by simply using a variable.
In response to Lyndonarmitage1 (#2)
If you want to build a filled rectangle using MouseDrop() do this.

turf
MouseDrop(turf/a,turf/b)
for(var/turf/T in block(a,b))
new whatevertype(T)
In response to Xx Dark Wizard xX (#3)
Works almost fine :D thanks Mr Wizard
Now I just need to edit it a bit also, it only fills multiple squares and not single ones as well.

:D thankies again
In response to Lyndonarmitage1 (#4)
turf
Click()
..() // just so if you have other clcik procs they still workd
new whatevertype(src.loc)


Do you want lines, circles rings boxes and stuff also ? I made a pretty decent building system.
In response to Xx Dark Wizard xX (#5)
if you could, yes please :D
And, I am having a problem building ontop of other things besides turfs:

mob/var/buildable
atom
MouseDrop(atom/a,atom/b)
if(usr.canbuild)
for(var/atom/T in block(a,b))
if(!usr.buildable)
return
new usr.buildable(T)


I have fiddled with it By the way trying to fix it by using atom instead of turf, still no effect but I did get choosing to work :)
In response to Lyndonarmitage1 (#6)
mob/var/buildable
atom
MouseDrop(atom/a,atom/b)
if(usr.canbuild)
for(var/atom/T in block(a,b))
if(!usr.buildable)return
if(T.tag != "owned by [usr.ckey]")continue
new usr.buildable(T)
T.tag = "owned by [usr.ckey]"


If, I do give it to you, you should include credit to me and loduwijk, and you need abyss dragons math lib.
In response to Xx Dark Wizard xX (#7)
That coding doent work all for some odd reason =/

my previous one worked but not on other obj/buildables prehaps I should chnage it so that selcting selects a different obj or turf altogether:
obj
buildable
var/owner="No one"
Click()
if(src in usr.Buildables)
if(usr.canbuild)
usr.buildable = src.type




I have teh math lib and I would of course include credit
In response to Lyndonarmitage1 (#8)
Ack, I wont reply for a couple of hours
In response to Lyndonarmitage1 (#9)
Lyndonarmitage1 wrote:
Ack, I wont reply for a couple of hours

Just page me when you want it, You will need some variables and stuff and it is pretty length (300 lines).
In response to Xx Dark Wizard xX (#7)
You shouldn't use the tag var like that. That will make every turf in the block [seemingly permanently] immune to garbage collection, which isn't something you should do.
Just use some other built in var (suffix?) if you want, but really just a custom var will do.

Also try and be sure about that little 'code exchange' people. Both of you should learn to code better before either giving code to others or just using code without learning it; Dark Wizard might as well just release it if that's the purpose.
In response to Kaioken (#11)
I don't want to release it publicly, it requires a lot of vars and stuff and isn't that flexible.
In response to Xx Dark Wizard xX (#12)
Xx Dark Wizard xX wrote:
I don't want to release it publicly, it requires a lot of vars and stuff and isn't that flexible. I may release it but it will need some tuning up and use min and max.
In response to Xx Dark Wizard xX (#10)
I am Back, can u help now please?
In response to Kaioken (#11)
Kaioken wrote:
You shouldn't use the tag var like that. That will make every turf in the block [seemingly permanently] immune to garbage collection, which isn't something you should do.

Where exactly do you get this from? The garbage collector generally doesn't collect turfs anyways, because they're always referenced by world.contents.
In response to Audeuro (#15)
Audeuro wrote:
Where exactly do you get this from?

The DM Reference ("tag var (datum)")wrote:
Any object with a non-empty tag is immune to garbage collection, since the tag is treated as an implicit reference to that object.
In response to Android Data (#16)
The DM Reference ("garbage collection")

Turfs and areas do not currently get garbage collected.
In response to Audeuro (#17)
Audeuro wrote:
The DM Reference ("garbage collection")

Turfs and areas do not currently get garbage collected.

From my point of view, your post read as "where do you get the idea that tags nullify garbage collection?".
In response to Audeuro (#15)
Audeuro wrote:
Where exactly do you get this from?

A non-empty tag counts as a reference to the object. Makes enough sense to me.

The garbage collector generally doesn't collect turfs anyways, because they're always referenced by world.contents.

xD What a load of crap! Think before you post. If the garbage collector counted world.contents as references, no atoms would be garbage collected.

Anyway, turfs aren't currently garbage collected.
Also, it's generally good to know - in this case he used block() so it actually didn't count since it returns turfs only and they don't currently get garbage collected, however if you use something like range(), it is not the case, and you should be aware of this.

Either way, you shouldn't be setting the tag var (pretty much all default built-in vars) just for 'custom flags' like that, unless you actually use that var's functionality.
Page: 1 2