I'm trying to do timer func "wait" in object script and I don't know why it doesn't work. It also doesn't display errors.
My code of function:
protected func FxWaitStart(){
timewait=36*3;
return 1;
}
protected func FxWaitTimer(object target){
if(waitt==false){
Log("It doesn't display");
return 1;
}
else{
SetYDir(0);SetXDir(0);
timewait--;
if(timewait==(36*3)){
CustomMessage("3", target, NO_OWNER);
}
if(timewait==(36*2)){
CustomMessage("2", target, NO_OWNER);
}
if(timewait==(36*1)){
CustomMessage("1", target, NO_OWNER);
}
if(timewait<0){
waitt=false;
timewait=36*3;
}
return 1;
}
}
waitt and timewait are local variables.
protected func Initialize()
{
AddEffect("Wait", this, 100, 1);
}
What i have to change ?
I
My code of function:
protected func FxWaitStart(){
timewait=36*3;
return 1;
}
protected func FxWaitTimer(object target){
if(waitt==false){
Log("It doesn't display");
return 1;
}
else{
SetYDir(0);SetXDir(0);
timewait--;
if(timewait==(36*3)){
CustomMessage("3", target, NO_OWNER);
}
if(timewait==(36*2)){
CustomMessage("2", target, NO_OWNER);
}
if(timewait==(36*1)){
CustomMessage("1", target, NO_OWNER);
}
if(timewait<0){
waitt=false;
timewait=36*3;
}
return 1;
}
}
waitt and timewait are local variables.
protected func Initialize()
{
AddEffect("Wait", this, 100, 1);
}
What i have to change ?
I
I guess timewait should be an effect-variable. Also, message 3 will not display, look at the order of assignment, decrement and check of timewait.
See also:
command_target:
[opt] Command target. If specified, all callbacks are executed in this object. Otherwise the callbacks are made without any object context.
See also:
command_target:
[opt] Command target. If specified, all callbacks are executed in this object. Otherwise the callbacks are made without any object context.
But Log() also doesn't display despite that it's not use timewait :/.
So func at all don't run. :\
So func at all don't run. :\
Then probably the command_target thing applies. I'm not entirely sure, but your functions are protected (does that even still exist?), which iirc means they can only be called by the engine or the object itself, with object context.
I remove the acces modifer (protected) and func began to work. But the messages still don't display.
I change target to command_target:
AddEffect("Wait", nil, 100, 1,this);
func FxWaitTimer(object command_target){
if(waitt==false){
return 1;
}
else{
SetYDir(0);SetXDir(0);
if(timewait==(36*3)){
CustomMessage("3", command_target, NO_OWNER);
}
if(timewait==(36*2)){
CustomMessage("2", command_target, NO_OWNER);
}
if(timewait==(36*1)){
CustomMessage("1", command_target, NO_OWNER);
}
if(timewait<0){
waitt=false;
timewait=36*3;
}
timewait--;
return 1;
}
}
I change target to command_target:
AddEffect("Wait", nil, 100, 1,this);
func FxWaitTimer(object command_target){
if(waitt==false){
return 1;
}
else{
SetYDir(0);SetXDir(0);
if(timewait==(36*3)){
CustomMessage("3", command_target, NO_OWNER);
}
if(timewait==(36*2)){
CustomMessage("2", command_target, NO_OWNER);
}
if(timewait==(36*1)){
CustomMessage("1", command_target, NO_OWNER);
}
if(timewait<0){
waitt=false;
timewait=36*3;
}
timewait--;
return 1;
}
}
Hm, maybe you should acquire a debugger in which you can evaluate the function step by step, see what your variables are, etc. I think, the eclipse plugin can do that.
Or, you do it the oldschool way and just add a ton of
Or, you do it the oldschool way and just add a ton of
Log()
s, printing every variable and every state.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill