ID:149674
 
There doesn't seem to be anyway to accomplish this a fast way other than with a switch but I decided to see if anyone knows a trick.

this is essentially what I want to do:
mouse_pointer_icon = '[mob.dir].dmi'

Then I'd have icons named 1, 2,4, ect.

I can see why it won't allow this because it must check to see if the icon exists at compile time. It would just be a little time saver.
English wrote:
There doesn't seem to be anyway to accomplish this a fast way other than with a switch but I decided to see if anyone knows a trick.

this is essentially what I want to do:
mouse_pointer_icon = '[mob.dir].dmi'

Then I'd have icons named 1, 2,4, ect.

I can see why it won't allow this because it must check to see if the icon exists at compile time. It would just be a little time saver.

I've noticed client.mouse_pointer_icon has a few limitations that don't really mesh well with the current icon system. It needs icons in various states, but dynamically-generated icons won't work well for that.

In theory there are a few ways you could get around your particular problem. file("[mob.dir].dmi") might work (I've never tried it, but I believe this is just the runtime equivalent of single quotes) as long as you package the .dmi files with your project.

As for me, I'd try a different route:
mouse_pointer_icon = fcopy_rsc(new /icon('pointer.dmi',dir=mob.dir))

I think that should reduce a 4- or 8-directional icon set to just one direction, which means you could define a single icon file with directional icons, and then strip it down. (Of course it'd be better to strip it down during initialization, and assign each icon set to a var or a list, so you don't have to make the same call every time the player changes direction.)

Lummox JR
In response to Lummox JR
Both worked :)

I used the first way because it seemed easier but then settled on the second way because I only need one icon file for it and it's easier to change states that I can see all at once than states in different files.

Here is the end result:
//global list for all icon_directions
icon_list = list("[NORTH]" = new /icon('highlight.dmi',icon_state="[NORTH]"),...)

//Then I have this in MouseDrag()
mouse_pointer_icon = icon_list["[mob.dir]"]

Thanks for the tips!