ID:146728
 
BYOND Version: 341.877

Operating System: Windows ME

Detailed Problem Description:
I've already solved this one, I believe. Not sure if it's a bug, or just a lack of implementation, or what.

Anyways. My goal here was to make a make a procedure that allows you to select different portions of the map and output each turf's icon in that selection to a new icon with different icon states. For an example of where this might be used, you may wish to employ it for aid when converting a large .png down to separate .dmi files.

The problem came in with the new icon. It seems var/icon/I = new() doesn't work as I would've hoped. The result returns true with isicon(), yet I would have no luck when attempting to make additions to that icon via the Insert() procedure.

Fair enough. But, I encountered more problems. It also seems that isicon() does not return true when using file() with double quotations to locate an icon that may or may not exist, regardless of if the returned file ends up being a valid icon or not.


Code Snippet to Reproduce Problem (enclose in DM tags):

turf/Click()
var/icon/I = new()
if(isicon(I))
world << "Yep"
else
world << "Nope"

I.Insert(icon(icon,icon_state),"insert icon_state")
fcopy(I,"result.dmi")


Have a look at result.dmi to see what happened.


Does the problem occur:
Every time? Or how often? Every Time
Koshigia wrote:
var/icon/I = new()

icon/New() takes a file argument at the very least. You can't simply create a blank one by not passing it a file (although that would be nice).

I suggest making a file called blank.dmi which includes just a single transparent icon as the default state.

Lummox JR
In response to Lummox JR
I already fixed the problem. I was more concerned with telling you that, regardless of the coding problem, isicon() returns true on something that isn't a valid icon (could be a problem to some... I happened to investigate why), and that a valid icon returned with the file() procedure does not return true with isicon(). If neither of those would be considered a 'bug', at the least this could be considered a feature request and not a 'coding problem'.

icon/New() takes a file argument at the very least. You can't simply create a blank one by not passing it a file (although that would be nice).

I suggest making a file called blank.dmi which includes just a single transparent icon as the default state.

Koshigia
In response to Koshigia
Koshigia wrote:
I already fixed the problem. I was more concerned with telling you that, regardless of the coding problem, isicon() returns true on something that isn't a valid icon (could be a problem to some... I happened to investigate why), and that a valid icon returned with the file() procedure does not return true with isicon(). If neither of those would be considered a 'bug', at the least this could be considered a feature request and not a 'coding problem'.

icon/New() takes a file argument at the very least. You can't simply create a blank one by not passing it a file (although that would be nice).

I suggest making a file called blank.dmi which includes just a single transparent icon as the default state.

Koshigia



I was interested in what code u got for the finished product. Could you please post it, it could help some other people who had the same problem.
In response to ElderKain
mob/verb/AppendToIcon()
var/tmp/a = input("Name of icon (please do not include extension!)?") as text

if(fexists("[a].dmi"))
switch(input("This file already exists and BYOND cannot append to it. Would you like \
to overwrite this icon? (Note: Problems might arise if this icon is open \
in dream maker. It is reccomended that you edit this file with only one \
program at a time.)"
,"Alert!") in list("No","Yes"))
if("No") return

var/icon/I = new('blank_icon.dmi')


var/tmp/list/options = list("Auto","Manual")
var/tmp/list/icon_states = new
switch(input("How would you like to have the icon_states named?") in options)
if("Auto")
var/tmp/count = 0
for(var/turf/T in sel_turfs)
count ++
icon_states += "[count]"

if("Manual")
for(var/turf/T in sel_turfs)
usr << browse(icon(T.icon,T.icon_state))
icon_states += input("Please name the icon_state for the icon displayed in \
your browser."
) as text

for(var/turf/T in sel_turfs)
I.Insert(icon(T.icon,T.icon_state),icon_states[sel_turfs.Find(T)])


usr << "Saving icon..."
fcopy(I,"[a].dmi")
usr << "Finished"


That's what I have so far... haven't touched it since reporting the bugs (And this has yet to be placed back in the bugs forum).

Koshigia