SphereCommunity
type in function - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: type in function (/Thread-type-in-function)

Pages: 1 2


type in function - seafish - 10-28-2013 11:44 PM

Hello!
How can I put type in function? Example:
Code:
[function f_ohoh]
newnpc=c_dragon
act.p=<p>  
act.m=0,1,-20
type=t_haha
act.attr=010
...

I have an error in console - Undefined keyword 'type'


RE: type in function - XuN - 10-29-2013 12:10 AM

Type is ONLY for items, you can't assign types to NPCs, you have to create [EVENTS ] for them, also the ATTR is an item value,you want the dragon to be 'static' and never move? use tag.nomovetill 99999999999

Also if you are running newer versions use this code instead
serv.newnpc=c_dragon
new.p=<p>
new.m=0,0,-20
new.events +e_yournewevent //you have to create it
new.tag.nomovetill=99999999999

The serv.newnpc/newitem will create for you this npc or item and will make it the default object for NEW, so you don't have to use ACT: wich may conflict with other systems.


RE: type in function - seafish - 10-29-2013 12:28 AM

Thank you! But how to add function after On=@create (for npc's) I would like to make event, example:
[events e_hoho]
ON=@create
new. f_ohoh

right?


RE: type in function - XuN - 10-29-2013 12:37 AM

ON=@Create does NOT work in events because events are added after the npc is created... BUT you are already creating this npc when you call it from this first function, so you dont need to use @Create, you simply use new.f_ohoh and it's done.


RE: type in function - Mordaunt - 10-29-2013 12:38 AM

Perhaps if you explained what exactly the function is supposed to do, a better solution can be offered.


RE: type in function - seafish - 10-29-2013 12:48 AM

okay, its not a problem.
1. its typedef:
Code:
[typedef t_wall]
on=@timer
if (<p.z> < <morez>)
m=0,0,1
timerd={1 3}
endif
return 1

2.
Code:
[function f_test]
newnpc=c_dragon
new.p=<p>  
new.m=0,1,-20
new.events +
new.timerd=1

It's for npc's - they growing from the earth more slowly (from the one of the topic's from spherecommunity.net)
Give me some second hand please, tell me how to create from typedef t_wall event for the npc's ?


RE: type in function - XuN - 10-29-2013 12:55 AM

Code:
[function f_Test]
serv.newnpc=c_dragon
new.p=<p>
new.f_ztimerfix -20

[function f_ztimerfix]
if (<args>)
tag.real_z=<p.z>
move 0 0 <args>
timerf 0,f_ztimerfix
else
if (<p.z><<tag.real_z>)
  p.z +=1
  timerf 0,f_ztimerfix
else
  tag.real_z
endif
endif

Decimals are not available in timerf, but you can check this out,


RE: type in function - seafish - 10-29-2013 01:26 AM

thanx! but when creates c_Dragon - he appears under the ground, not on surface! And there is some error
Code:
Undefined symbol '' Line 41
Line 41 - if (<args>)


RE: type in function - XuN - 10-29-2013 03:13 AM

if !(<isempty <args>>)


RE: type in function - seafish - 10-29-2013 04:53 AM

Thank you senior, there are no errors now! But npc still sits underground