SphereCommunity
sand cly mining 1.1 script - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: sand cly mining 1.1 script (/Thread-sand-cly-mining-1-1-script)



sand cly mining 1.1 script - kn4tseb - 06-03-2014 07:10 AM

Hello boys, im trying to implement this great script idea but im getting some issues with functions, its a bit more advance of my current knowledge so i cant find what's wrong with it... it works 'till "success" function, i will post it and any help will be appreciate it.

i will only paste Sand mining side:

when it success it makes the animation of mining, create the invisible copper coin, and nothing else happens
i also get some errors @ console:
17:32:ERROR:Timer expired without DECAY flag 'sand' (UID=040016a7e)?
17:32:ERROR:Timer expired without DECAY flag 'sand' (UID=040016a7c)?

PHP Code:
ON=@TARGON_GROUND
IF (<serv.map(<src.targp.x>,<src.targp.y>,<src.targp.z>,<src.targp.m>).type>==t_rock)
    RETURN 
0
ENDIF
IF (<
serv.map(<src.targp.x>,<src.targp.y>,<src.targp.z>,<src.targp.m>).type>==t_sand)
    IF (<
DISTANCE <SRC.TARGP>> >= 3)    
        
SRC.SYSMESSAGE That is too far away, try mining closer
        
RETURN 1
    
ENDIF
    IF  !<
SRC.CANSEELOS <SRC.TARGP>> 
        
SRC.SYSMESSAGE I cannot see thathow am i supposed to mine it?
        RETURN 
1
    
ENDIF
    
LOCAL.MINE=(<SRC.MINING>/100)    
    IF (<
R2> < <EVAL <LOCAL.MINE>>)
        
src.f_sand_success
    
ELSE
        
src.f_sand_fail
    
ENDIF
    RETURN 
1
ENDIF

[FUNCTION 
f_sand_success]
SRC.TIMERF 1f_check_sand_resources
IF !(<SRC.CTAG0.RESOURCE>)
    
SRC.ANIM 11
    sfx 0340
    NEWITEM
=i_coin_copper
    
NEW.ATTR=attr_move_never|attr_invis|attr_decay
    
NEW.MORE2=i_sand
    
NEW.AMOUNT=<EVAL {3 6}>
    NEW.
TIMER=60*10
    
NEW.P=<SRC.TARGP>
    
SRC.CTAG.RESOURCE=<NEW.UID>
    RETURN 
1
ENDIF
IF (<
UID.<SRC.CTAG0.RESOURCE>.AMOUNT> > 0)
    
SRC.TIMERF 1f_sand_mine_action
    
RETURN 1
ELSE
    
SRC.SYSMESSAGE There is nothing here to mine.
ENDIF

[FUNCTION 
f_check_sand_resources]
SRC.ANIM 11
sfx 0340
CTAG
.RESOURCE=
VAR.
RESOURCE=
VAR.
OLD_ACT=<ACT.UID>
NEWITEM=i_memory
NEW.P=<TARGP>
NEW.
f_check_sand_resources_p
NEW.REMOVE
IF (<VAR0.RESOURCE>)
    
CTAG.RESOURCE=<VAR0.RESOURCE>
ENDIF
VAR.
RESOURCE=

[FUNCTION 
f_check_sand_resources_p]
FORITEMS 0
    
IF (<BASEID>==i_coin_copper)
        IF (<
MORE2>==i_sand)
            VAR.
RESOURCE=<UID>
        ENDIF
    ENDIF
ENDFOR

[FUNCTION 
f_sand_mine_action]
IF (<
SRC.CTAG0.anim> <= 3)
    
SRC.ANIM 11
    SRC
.SFX 0340
    SRC
.CTAG0.anim += 1
    TIMERF 1
f_sand_mine_action
ELSE
SRC.CTAG.ANIM=
f_sand_mine
ENDIF

[FUNCTION 
f_sand_mine]
TRY 
UID.<SRC.CTAG0.RESOURCE>.AMOUNT=<UID.<SRC.CTAG0.RESOURCE>.AMOUNT> +-1
TRY UID.<SRC.CTAG0.RESOURCE>.UPDATE
SRC
.ANIM 11
sfx 0340
NEWITEM
=<UID.<SRC.CTAG0.RESOURCE>.MORE2>
NEW.
BOUNCE
ENDIF 



RE: sand cly mining 1.1 script - Extreme - 06-03-2014 12:05 PM

Set attr_decay on items.


RE: sand cly mining 1.1 script - kn4tseb - 06-03-2014 12:25 PM

done, no more errors, thanks; but script still doesnt work >.<
when it "success", some "invisible" copper coins are created at <TARGP> i suppose its some kind of memory so that tile will not be able to mine for a time... but i miss it when fallowing functions are called... specially with the CTAG, because one the coins are created nothing else happens, i can even mine the same spot as much as i can..

if i could only understand what it does, would be a huge step forward learning this ^^


RE: sand cly mining 1.1 script - Extreme - 06-03-2014 02:12 PM

Look if this help you




RE: sand cly mining 1.1 script - kn4tseb - 06-03-2014 02:55 PM

gonna check them, thank you ^^