Jump to content
RyanTurner

AddAction get the Origin Object

Recommended Posts

I've been trying to figure out if it's or not possible, when adding addAction to an object that has a variable associated to it (in the editor). 

When it executes a SQF file if it's there a way to grab the origin object variable. Example Teleporter1 or Teleporter2

Share this post


Link to post
Share on other sites

I may not have the answer but I think it would help to:

1. Give the varName of the object that has the addAction.

2. What do you mean grab? then do what?

Share this post


Link to post
Share on other sites

addAction

 

say:

teleporter1 addAction [ "teleport test", { params ["_target", "_caller", "_actionId", "_arguments"];  hint format ["the object is: %1, the caller is %2", _target,_caller]; _caller setPos [worldSize/2,worldSize/2,0] }, nil, 1.5, true, true, "", "true", 50, false, "", "" ];

 

if you write as shown:

params ["_target", "_caller"]; (at least)

 

_target is the variable for the object (teleporter1 for example) and _caller is the caller, usually the player triggering the action.

 

  • Like 1

Share this post


Link to post
Share on other sites

How do I use this values on SQF?

Share this post


Link to post
Share on other sites

Create a file named "init.sqf" on your mission's main folder and throw those lines inside it, for starters, at least to feel the first taste and see whether it goes as you intended. And tht way you will have a script file to improve and modify, providing the results and/or errors you get. 😎

Share this post


Link to post
Share on other sites
13 hours ago, RyanTurner said:

How do I use this values on SQF?

what do you mean? sqf is a file, where you can add an action by addAction, or triggered by addaction itself (see Leaopard20 remark at bottom of the link I wrote above).

You can pass parameters to an sqf like this:

params ["_aa","_bb","_xx"]; [_aa,_bb,_xx] execVM "yourpathFromMissionFolder\yourfile.sqf";

 

See also:

Introduction_to_Arma_Scripting

If you follow and learn most of the links, you'll improve your skill for scripting.

Share this post


Link to post
Share on other sites

My problem here is how learning how the stupid addaction works, and everoyne has showed me the wiki, i dont get it because im shown 10 arguments in it and shitty examples in the bottom.

I can make a simple addaction to the object with a title and run a sqf file that teleports to X mark.

I can't figure out is how to run / call that sqf file within the addaction with arguments sent over to the sqf.

 

Share this post


Link to post
Share on other sites
def teleportScript(teleporterOrigin):
    import random
    
    if teleporterOrigin == "start":
        arrayEndMarkers = ["markEnd1", "markEnd2", "markEnd3"]
        arrayEndMarkersChoose = random.choice(arrayEndMarkers)
        


teleporterOrigin = input("Which teleport are you using? (Start / End): ")

teleporterOrigin = teleporterOrigin.lower()

teleportScript(teleporterOrigin)


I know this is not SQF, and doesn't get any player or object position, but while i theorical can get the idea of getting the origin (teleport start or end, in this case for exampel is an input), and i run the function with the arguments of the origin of the teleport, depending on that, choose a 1 random marker position of an array, than teleport the player

Share this post


Link to post
Share on other sites


_object = _this select 0;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×