Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Dart_Tech

Registered:
Posts: 30
Reply with quote  #1 
So I have been digging deeper and deeper into scripting a mini sandbox and have ran into a issue.

I have many button events using if_gm_button to do stuff. However, I have reached a point where I have a piece of script that does something really neat, but I want 2 or 3 buttons to call it as well as perform their respective function.

I know VB.NET and I would put the code I want into a Sub then call it from the button events, however I cant seem to find a equivalent to sub in this language.

How can I have one event call another event? I don't want to copy and paste the same code into 2 different sections.

Thanks!
ryleyra

Registered:
Posts: 2,459
Reply with quote  #2 
Set a flag variable and have it execute the event. For instance:

<event>
<if_gm_button name="Thing 1" />
    <set_variable name = "do_the_thing" value="1"/>
</event>

<event>
<if_gm_button name="Thing 2" />
    <set_variable name = "do_the_thing value="1"/>
</event>

<event>
<if_gm_button name="Thing 3" />
    <set_variable name = "do_the_thing" value="1" />
</event>

<event>
<if_variable name="do_the_thing" comp="EQUALS" value="1"/>
    ... do your stuff here
    <set_variable name = "do_the_thing" value="0"/>
</event>
Dart_Tech

Registered:
Posts: 30
Reply with quote  #3 
Ok thanks, ill play around with a variable and see what I can get to work.

Also, another thing that is stumping me hard is how to get the GM cursor xyz coordinates into varables. Not the selection but the spinning blue cursor. I noticed all objects have a positionX, positionY, and positionZ property. You can set these to move stuff around, I can make a temporary Generic Mesh or object at the GM cursor location but how can I load the coordinates to that temporary object in variables?

There is a "set_object_property" but there is no "get_object_property".

I wish I could do something like:

Code:
<create type="genericMesh" use_gm_position="yes" name="DEL" meshFileName="dat\mine.dxs" textureFileName="dat\2B_diffuse.png" />
<set_variable name="xPos_Temp" value="DEL.positionX" />
<destroy DEL />


Even easier would be a way to do:

Code:
<set_variable name="xPos_Temp" value="use_gm_position.positionX" />


How do you handle that in Artemis?
ryleyra

Registered:
Posts: 2,459
Reply with quote  #4 
Quote:
Originally Posted by Dart_Tech

Also, another thing that is stumping me hard is how to get the GM cursor xyz coordinates into varables. Not the selection but the spinning blue cursor. I noticed all objects have a positionX, positionY, and positionZ property. You can set these to move stuff around, I can make a temporary Generic Mesh or object at the GM cursor location but how can I load the coordinates to that temporary object in variables?


I answered that in your "GM Move Ship" thread, but I'll just go ahead and repost it here:

Quote:

I'll add that there is another option, but it is extremely time consuming. Create your object, at the GM position, and then go through a loop that tests an x, y, and z (or just x and z) variable for greater than or less than the object's current location. Increment your variables and try again. Eventually you should locate the object and can use the variables to set your ship's heading. It can take several seconds to locate the object, based on the granularity of your increment value, so I'm suggesting it only to show that it CAN be done. Hopefully someday Thom will give us a way to read a property into a variable.


As I said, it would be so much easier with a get_object_property command, but for now I've had luck with a "shadow variable" that constantly updates as the ship moves. The problem is it has to increment fast enough to keep up with the ship with it uses Jump Drive, and if you don't specify the location when you create the ship, finding it in the first place. But your increment has to be small enough that when you place an object it isn't too far away from the ship's true location.

I think it should also be possible to update the location variable with a larger increment if it is far away from the known location, and by a small amount when it is close, but that takes more code.

You might check out the mission that comes with my mod "Strike Force Seven" for an example of this. It is used in a bunch of places, most notably for the "Death Blossom" from the movie "The Last Starfighter". It tracks the Gunstar and when it triggers the Death Blossom (by loading a mine) it places a whole field of mines at the Gunstar's location.

Fish Evans

Registered:
Posts: 350
Reply with quote  #5 
yes simple answer is you cant.. there are work arounds depending on what your tryign to do?
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.