Home   Help Search Login Register  

Author Topic: changing an existing action  (Read 1195 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
changing an existing action
« on: 26 Oct 2007, 00:14:24 »
suppose you want to make an action that does something, can you can do that something a certain number of times.

its similar to the laying mines action.

when an action like this is used:

player addaction ["Use this (3 Remaining)","usethat.sqs"]

i want it to change to:

player addaction ["Use this (2 Remaining)","usethat.sqs"]

the number remaining will be dependent on what the value of a variable is.

so what i need to know is how to modify an action without interfering with the action ID,
make the text in the action dependent on the variable (something like format),
and make the action immune to deletion in some way, i dont want the action deleted because the mission
it was used in had a function that deleted all actions.

ta

surdus
Campaigns are hard, I'll stick with scripting for now!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: changing an existing action
« Reply #1 on: 26 Oct 2007, 03:14:34 »
use a variable... like lets say set da variable called "uses"    lets say u set it to 3 like in :

uses = 3

and then u do a

player addaction [format ["Use this (%1 Remaining)",uses],"usethat.sqs"];

and everytime start da script

(_this select 0) removeaction (_this select 2)
uses = uses -1
? uses > 0 :player addaction [format ["Use this (%1 Remaining)",uses],"usethat.sqs"]

after dat put da script...

LCD OUT

[edit] ive been drunk yesterdayz... so i fixed couple of wrongs :P  :D
« Last Edit: 26 Oct 2007, 09:36:27 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: changing an existing action
« Reply #2 on: 26 Oct 2007, 03:23:18 »
i understand the format part, but you lost me with the rest.  i can do it and take your word for it that it works, but i dont actually know what it does, can you explain a little but please? :D
Campaigns are hard, I'll stick with scripting for now!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: changing an existing action
« Reply #3 on: 26 Oct 2007, 09:41:02 »
yeah :P

basicly u need 2 have a variable dat counts how many times u want da action 2 b uses (hence i called it uses) and i told u 2 set it to 3...

Quote
use a variable... like lets say set da variable called "uses"    lets say u set it to 3 like in :

uses = 3

now where u add da action u use da format command in da name of da action... so it uses da varaible 2 set da name

Quote
player addaction [format ["Use this (%1 Remaining)",uses],"usethat.sqs"];

now in da script itself u do da next steps....

1) remove da action... in an action script... (_this select 0) equals da object da action is attached 2.... (_this select 2) equals da action ID number

Quote
(_this select 0) removeaction (_this select 2)

2) reduce da amount of uses left

Quote
uses = uses - 1

3) check if dere still more uses availble... and add da action again if dere r

Quote
? uses > 0 :player addaction [format ["Use this (%1 Remaining)",uses],"usethat.sqs"]

dats it i think :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: changing an existing action
« Reply #4 on: 26 Oct 2007, 11:59:56 »
that works really well, thank you.

there are just 2 more questions, i could figure this out myself, but i wanna get this script released soon;

i need to make the number remaining, refresh when a trigger in game is activated. so it changes the action text.

i also need a way of making the action reappear incase the mission accidentally deletes it.

surdus

EDIT: actually on second thoughts forget about the making it immune to deletion part, since if the editor does accidenty delete it then its his/her own fault :P

but what would be handy, is the first one.

its just the same as with mines, only harder, when you use a mine, the number in the action menus goes down one, and when you pick up another mine, it goes up, so i want something like that. 

surdus again
« Last Edit: 26 Oct 2007, 23:21:08 by Surdus Priest »
Campaigns are hard, I'll stick with scripting for now!