ID:2194306
 
(See the best response by Ter13.)
Code:
/*
LAYERS:
MOB_LAYER+10 Background
MOB_LAYER+11 Enemies
MOB_LAYER+12 Players
MOB_LAYER+13 Effects
MOB_LAYER+14 HUDbackground
MOB_LAYER+15 HUDtext
*/


obj/HUD
battleBG
icon = 'images/battle/background/Cave.jpg'
layer = MOB_LAYER+10
screen_loc = "8,14:16"

battlePARTICIPANTS
layer = MOB_LAYER+11

battleFX
layer = MOB_LAYER+13

battleHUD
layer = MOB_LAYER+14
battlestatsHUD
icon = 'images/battle/HUD/battlestatshud.png'
screen_loc = "8,22"
battlemenuHUD
icon = 'images/battle/HUD/battlemenuhud.png'
screen_loc = "8,12"
battlepriorityHUD
icon ='images/battle/HUD/battlepriorityhud.png'
screen_loc = "8,13:8"

battleTEXT
layer = MOB_LAYER+15
battlestatsTEXT
battlemenuTEXT
battlepriorityTEXT

battleFRAME
layer = MOB_LAYER+16
battlestatsFRAME
icon = 'images/battle/HUD/battlestatsframe.png'
screen_loc = "8,22"
battlemenuFRAME
icon = 'images/battle/HUD/battlemenuframe.png'
screen_loc = "8,12"
battlepriorityFRAME
icon ='images/battle/HUD/battlepriorityframe.png'
screen_loc = "8,13:8"

var/obj/HUD/battleBG = new()
mob/var/obj/HUD/battleBG/battleBG

//Character's stats in fight
var/obj/HUD/battlestatsHUD/battlestatsHUD
var/obj/HUD/battleFRAME/battlestatsFRAME
mob/var/obj/HUD/battleHUD/battlestatsHUD/battlestatsHUD
mob/var/obj/HUD/battleFRAME/battlestatsFRAME/battlestatsFRAME

//Order in which each mob attacks
var/obj/HUD/battleHUD/battlepriorityHUD
var/obj/HUD/battleFRAME/battlepriorityFRAME
mob/var/obj/HUD/battleHUD/battlepriorityHUD/battlepriorityHUD
mob/var/obj/HUD/battleFRAME/battlepriorityFRAME/battlepriorityFRAME

//Battle selection menu
var/obj/HUD/battleHUD/battlemenuHUD
var/obj/HUD/battleFRAME/battlemenuFRAME
mob/var/obj/HUD/battleHUD/battlemenuHUD/battlemenuHUD
mob/var/obj/HUD/battleFRAME/battlemenuFRAME/battlemenuFRAME

mob/var/tmp/inbattle = 0

mob
//Commands only here for testing purposes
verb/Fight()
createbattlehud()

verb/Endfight()
removebattlehud()

proc/createbattlehud()
if(inbattle==0)
inbattle=1
src.battleBG=new
src.client.screen+=battleBG

//Character's stats in fight
src.battlestatsHUD=new
src.battlestatsFRAME=new
src.client.screen+=battlestatsHUD
src.client.screen+=battlestatsFRAME

//Order in which each mob attacks
src.battlepriorityHUD=new
src.battlepriorityFRAME=new
src.client.screen+=battlepriorityHUD
src.client.screen+=battlepriorityFRAME

//Battle selection menu
src.battlemenuHUD=new
src.battlemenuFRAME=new
src.client.screen+=battlemenuHUD
src.client.screen+=battlemenuFRAME

proc/removebattlehud()
if(inbattle==1)
inbattle=0
src.client.screen-=battleBG

src.client.screen-=battlestatsHUD
src.client.screen-=battlestatsFRAME

src.client.screen-=battlepriorityHUD
src.client.screen-=battlepriorityFRAME

src.client.screen-=battlemenuHUD
src.client.screen-=battlemenuFRAME

verb/rotatestuff()
//will be needed for different view angles, each time changing to a quarter of the battleBG icon
battleBG.icon.Shift(EAST,20,1)


Problem description:

Shift doesn't work somehow. I don't know how I can make it work, since I want to have a battle background image that loops around and I can turn around. For some reason, it sees Shift not as a built-in proc but expects a defined proc to run. The manual doesn't give me any examples and I don't really know if I messed up the syntax or something.

I get these error messages:
loading Training.dme
loading interface.dmf
fightsystem.dm:124:error: battleBG.icon.Shift: undefined proc
Training.dmb - 1 error, 0 warnings (12/31/16 5:24 pm)


Besides, happy new year, everyone.
Do you have Shift() defined for icons?

icon
proc
Shift()
// do stuff


Shift() isn't a part of the default BYOND setup.
Actually, it is.
Best response
Okay, what's going on here is that a resource reference isn't the same thing as an /icon datum.

'herpderp.dmi' <- this is a resource reference

icon('herpderp.dmi') <- this is an /icon datum.

You also can't live-shift an icon.

When you display an icon datum, it is converted to a resource reference. Icon operations cannot be performed on resource references because they are not /icon datums.

Instead of:

battleBG.icon.Shift(EAST,20,1)


Do this:

var/icon/i = icon(battleBG.icon)
i.Shift(EAST,20,1)
battleBG.icon = i


I think though, that you will find that Icon operations are slow, bloat the dynamic RSC, and aren't well suited for runtime usage.

Icon operations are best done during initialization and never again after. You'll more than likely want to find a different way to do what you are trying to do that doesn't use icon operations.
In response to Flick
I stand corrected
Thanks Ter13, I'll see for another possibility to do this, possibly using flick() and just having an icon file that is the background rotating or trying something with Gliding.
Try animate() with pixel_w.
Thanks for the help. While it works on some icons and doesn't give me any errors, weirdly enough it has no effect on the battleBG object. Weirdly enough, everything else applies to it,since I put in a small maptext to see if it works. I basically exchanged shift() with this:
mob
verb/rotatestuff()
//will be needed for different view angles, each time changing to a quarter of the battleBG icon
animate(battleBG,pixel_w=60, time=3, loop=1, easing=SINE_EASING, maptext="animate test")
Oh hey, yeah, that's my bad. I didn't think before I said that.

pixel_x, pixel_y, pixel_w, and pixel_z do not affect positioning of objects in the screen.

animate(battleBG,transform=matrix(60,0,MATRIX_TRANSLATE), time=3, loop=1, easing=SINE_EASING)


Transform works in the screen.
Thanks man, works perfectly!

Edit: Just tried changing the vars a bit to see if all is alright and it doesn't loop the image actually. It moves it forward though, which isn't bad for a start. Didn't see it directly, since the map and the screen is a bit bigger than the image itself. I'll try seeing what I can do. ^^'