Jump to content

Scripting Help


Abramul

Recommended Posts

I have made a plugin that SHOULD create an object at the player's location, and then make it follow the player. Of course, since I'm asking for help, obviously it isn't working right. Here're the relevant scripts:

begin callscript
>short placed = 0
>while(1)
>>if(placed==0)
>>>placeatPC MyObject 1 100 0
>>>disable MyObject
>>>set placed to 1
>>endif
>>if(ScriptRunning Movescript==0)
>>>startscript Movescript
>>endif
>>if(OnPCEquip==1)
>>>enable MyObject
>>else 
>>>disable MyObject
>>endif
>endwhile
end callscript
begin Movescript
>while(1)
>>float posx
>>float posy
>>float posz
>>set posx to Player (getPos x)+*xoffset*
>>set posy to Player (getPos y)+*yoffset*
>>set posz to Player (getPos z)+*zoffset*
>>position posx posy posz 0
>endwhile
end Movescript

When I load the game, I get two errors, both in callscript: one says something about EXPRESSION not found, the other something about RIGHT EVAL

For some reason, warnings.txt doesn't exist, so I don't have a dump from that. Tried COCing to the cell these are used in, and got a freeze. Should I slice the whiles?

 

EDIT: BAD tabs, BAD! noticed that my float declares are inside the while (in Movescript). Would that affect anything?

Link to comment
Share on other sites

You've seen my scripts. You've commented on my scripts. I don't see how this can happen.

 

Really, even a non-scripter can see that this is a grammarial distster. I could spend hours writing up a post that attempts to find out what you're trying to do here, and then attempts to correct the mistakes, but half-way through, I would realize that you're trying to do something impossible and stupid, like have an object position itself within arbitrarily named interior cells.

 

Really, should I expect any better from some kid who entered in "float" in the console and expected a random object to go wafting up in the breeze?

Link to comment
Share on other sites

So, should I use the command that teleports to a position in the current cell, or should I set it up to move towards the player?

 

*axisoffset* would be a specific number value. I want it to stay a specific distance ABOVE the player. (Actually, this might even act as a cliff racer shield!) The first round of testing, I was trying the callscript, hadn't coded the movescript yet. As it turned out, it kept creating new objects! (hence the placed variable)

 

What math arguments will scripts accept? If I can use a square root, that would make things a lot easier.

Link to comment
Share on other sites

You could try something like this, although there would still be problems with clipping, and you'd still need to account for PC height (that's not to mention the potential problems of having two of these things out in the wild):

 

Begin "OMG_MIE_MAGIKAL_REENG!!1.lsc"

If ( Player->GetEquipped "OMG_MIE_MAGIKAL_REENG!!!1" );A "> 0" is assumed here.  Note that whitespace in conditions is *not* optional.  
 StartScript "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc"
Else
 StopScript "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc"
EndIf

End

 

Begin "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc"

Short ShieldinRange
Short WaitOneFrame

If ( WaitOneFrame == 1 )
 If ( ShieldinRange == 0 )
   PlaceatPC "OMG_CLEFF_RACAR_SHEELD!!!11!" 1 100 0
 EndIf
ElseIf ( CellChanged )
 Set WaitOneFrame to 1
EndIf

End

 

Begin "OMG_CLEFF_RACAR_SHEELD!!!11!.lsc"

Float XPos
Float YPos
Float ZPos

If ( ScriptRunning "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc" )
 If ( CellChanged )
   Set "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc".ShieldinRange to 1
 EndIf
 Enable
Else
 Disable
EndIf

Set XPos to ( Player->GetPos X )
Set YPos to ( Player->GetPos Y )
Set ZPos to ( Player->GetPos Z )
Set ZPos to ( ZPos + 100 )

SetPos X XPos
SetPos Y YPos
SetPos Z ZPos

End

Link to comment
Share on other sites

Begin "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc"

Short ShieldinRange
Short WaitOneFrame

If ( WaitOneFrame == 1 )
If ( ShieldinRange == 0 )
  PlaceatPC "OMG_CLEFF_RACAR_SHEELD!!!11!" 1 100 0
EndIf
ElseIf ( CellChanged )
Set WaitOneFrame to 1
EndIf

End

 

I tried something like that. That's why I have the placed variable.

The way you have it, you'll end up with one in each cell you go through.

I think I'll just make it homing.

Link to comment
Share on other sites

That's the only way to do it, you fool. You cannot have an already existing object moved into a cell with an arbitrary name. The only thing that you can do to accomplish your goal is place an object within a cell that the PC is already in.

 

...And I was originally hoping that you'd catch this on your own time and it would prove to be a valuable experience (the value of which was not to be lessened by the fact that I had even brought attention to the things that needed to be changed in a prvious post), but now my hope for that is quickly diminishing, thanks to your suggestions -- the shields' local scripts need to do one additional thing, and the executive script needs to accomodate this:

 

Begin "OMG_CLEFF_RACAR_SHEELD!!!11!.lsc"

Float XPos
Float YPos
Float ZPos

If ( ScriptRunning "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc" )
 If ( OMG_CLEFF_RACAR_SHEELD!!!11!.xsc".ShieldinRange )
   Disable
 ElseIf ( CellChanged )
   Set "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc".ShieldinRange to 1
 EndIf
 Enable
Else
 Disable
EndIf

Set XPos to ( Player->GetPos X )
Set YPos to ( Player->GetPos Y )
Set ZPos to ( Player->GetPos Z )
Set ZPos to ( ZPos + 100 )

SetPos X XPos
SetPos Y YPos
SetPos Z ZPos

End

 

Begin "OMG_CLEFF_RACAR_SHEELD!!!11!.xsc"

Short ShieldinRange
Short WaitOneFrame

If ( WaitOneFrame == 1 )
 If ( ShieldinRange == 0 )
   PlaceatPC "OMG_CLEFF_RACAR_SHEELD!!!11!" 1 100 0
 EndIf
ElseIf ( CellChanged )
 Set WaitOneFrame to 1
EndIf

Set ShieldinRange to 0
Set WaitOneFrame to 0

End

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...