View unanswered posts | View active topics It is currently Fri May 17, 2024 11:12 am



Reply to topic  [ 140 posts ]  Go to page Previous  1 ... 6, 7, 8, 9, 10  Next
 Quick Console Commands 
Author Message

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post Why me?!
Code:
for actor in MovableMan.Actors do actor.GlobalAccScalar = 0 end


Why does everything I try fail?!


Fri Feb 13, 2009 2:33 am
Profile WWW
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Quick Console Commands
For that last one there, GlobalAccScalar doesn't work. I've tried relentlessly.
And for the one before that, it's a syntax problem. Don't forget your semicolons after a statement ;)


Fri Feb 13, 2009 4:26 am
Profile WWW

Joined: Sat Jun 16, 2007 8:04 pm
Posts: 42
Reply with quote
Post Re: Ok, I think this is the last request... Maybe...
zalo wrote:
Thanks, that worked great! Just as I had expected!

Ok, here's my second problem.
I removed all the unnecessary code in between to shorten the post. What have I done wrong?
The function never executes even after I killed the activator. The battle never starts :( .

I'm trying to make some sort of fun Arena. Like when you kill your opponent(s)
it instantly teleports you to another part of the map, and a new battle.

NP. There is a small error in your code. Actually my last post contained a solution to your problem before you even posted yours, lol. Funny that :P (Yeah it was pretty long-winded post, i don't wonder if you didn't read it).

Anyway, the problem lies here:
Code:
if Round1 == 1 then
function Round1()
end

The proper way to call a function is: Round1(), not: function Round1(). The latter one is a function declaration. (In case you didn't know the difference). Experimentation is a great way to learn but if you combine that with some short tutorials or references about language syntax and general knowledge (about the things you are currently working on), that might help you a lot.

That arena idea sounds good, keep working on it.

TheLastBanana wrote:
Code:
for actor in MovableMan.Actors do if actor.Team == 1 then x = actor end end; ActivityMan:GetActivity():SwitchToActor(x,0,1);

I didn't know that is possible O_O Fun :)

Great stuff all these scripts.


Sat Feb 14, 2009 9:58 am
Profile
User avatar

Joined: Mon Jun 04, 2007 5:55 am
Posts: 1627
Location: Ohio
Reply with quote
Post Re: Quick Console Commands
I have a question on this.

Using Lua, can you export all loaded instance names? as in, create a list of every actor and held device?

If so, why has noone made a Lua-script to create a random actor, with a random gun, in a random dropship, for the AI Spawns? Or has this actually been done?


Sun Feb 15, 2009 2:07 am
Profile YIM WWW

Joined: Sat Jun 16, 2007 8:04 pm
Posts: 42
Reply with quote
Post Re: Quick Console Commands
I have been wondering the same thing. I'm currently going through the function dump script output that Kylegar provided for us, but i can't seem to access these functions... they don't seem to be global, and the index number before the function (in the function dump script output) isn't telling me anything.

Perhaps GetDataModule(), GetPreset(), GetModuleID() and others might make it possible to retrieve PresetNames from loaded modules. They have to be kept somewhere afterall...but where? Could there be data somewhere that is accessible like the functions?

Spawning random stuff would be very usefull for skirmish, but we can't do it at the moment. But nothing is preventing anyone from creating skirmish-like mission script. You could also add some extra to spice it up.


Tue Feb 17, 2009 12:56 pm
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: Quick Console Commands
ScifiSpirit wrote:
I have been wondering the same thing. I'm currently going through the function dump script output that Kylegar provided for us, but i can't seem to access these functions... they don't seem to be global, and the index number before the function (in the function dump script output) isn't telling me anything.

Perhaps GetDataModule(), GetPreset(), GetModuleID() and others might make it possible to retrieve PresetNames from loaded modules. They have to be kept somewhere afterall...but where? Could there be data somewhere that is accessible like the functions?

Spawning random stuff would be very usefull for skirmish, but we can't do it at the moment. But nothing is preventing anyone from creating skirmish-like mission script. You could also add some extra to spice it up.


The wiki can answer part of your question(Pretty much all of it actually, why doesn't anyone read this? Dumb.)

http://www.datarealms.com/wiki/index.php/Lua_Functions

Although any attempt on GetDataModule will produce a crash similar to

---------------------------
Cortex Command.exe - Application Error
---------------------------
The exception unknown software exception (0xc0000005) occurred in the application at location 0x0048ecd2.


Click on OK to terminate the program
---------------------------
OK
---------------------------

the rest work fine. GetPreset takes three strings or two strings and a number, GetModuleID takes a string including .rte. Ex: "Ronin.rte"


Really it seems that it wouldn't be too much of a task to make dropships drop random actors a script finds in the modules.


Tue Feb 17, 2009 9:24 pm
Profile

Joined: Sat Jun 16, 2007 8:04 pm
Posts: 42
Reply with quote
Post Re: Quick Console Commands
Actually i do read the wiki, read it after i posted, but somehow missed the last PresetMan line. Thanks for the info.

I would have posted another script here but i'm having trouble with while loops that are kept running by timers. Hangs CC every time. I'm not sure if it's actually CC hanging, or if CC actually is working just fine but the script just enters infinite loop. I however suspect the former. So instead of the script itself, here is a little problem to solve if anyone feels like solving it. If i solve it myself, i'll post the solution ASAP.

Example:
(Don't run this if you don't want your CC to hang)
Code:
Sometimer = Timer(); while not Sometimer:IsPastSimMS(10000) do print("Going strong...."); end


That's all it takes. You don't see the loop even starting because it doesn't print anything, so that's why i suspect it's not the while loop that has the error. Checking the timer inside the loop and using a standard variable instead as a while expression does not help. Also, LeftTillSimMS produces the exact same results.

EDIT:
After some testing, i came to the conclusion that the code above practically causes an infinite loop. Not in theory, but the looping seems to deprive CC AND the timers of all processing power, and therefore they do not progress and the conditions are never met. I tried a fixed 20 000 iteration loop and even that took some time to complete (And CC halted while it was running). I started a timer before the loop and printed it's value after the loop had finished, and the result of Sometimer:LeftTillSimMS(0) was 0! So there seems to be no way of using timers as while loop conditions, not directly at least. And i guess you can't use the UpdateActivity function in skirmish games. Seems to be the only proper way of using timers.

Another weird thing was, that the game does not print() out stuff after the first iteration, but only after all of them have been completed. That's why i thought the loop never started when it actually did. Probably the same reason as to why the timer didn't progress. So everything in host app stops while Lua loops are running? If so, that's good to know.


Sun Feb 22, 2009 5:55 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Quick Console Commands
ScifiSpirit wrote:
stuff.


whilst a while loop is running nothing else will, so it's kinda stupid to have a while loop like you have there, unless you use another thread.

replace while with if, I think this is what you want:
Code:
blah = 0; Sometimer = Timer(); if Sometimer:IsPastSimMS(10000) and blah == 0 then print("Going strong...."); blah = 1;end


also you put while not Sometimer:IsPastSimMS(10000), which means run the while loop if it is not past the time you set, I assumed this was a mistake so I took out the "not" part.


Mon Feb 23, 2009 6:21 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Quick Console Commands
The amount of MS on a timer is increased with a formula involving the FPS.
In order to get the FPS, the frame has to be incremented and then the computer has to see how many seconds have passed.
The script you've written in Lua is executed every frame, including the while loop. Until the while loop has stopped, the frame doesn't advance.
So, simply put, the timer will never go beyond 10000 MS because the frame never advances as it is waiting for the timer to go beyond 10000 MS. As Robolee said, you want to check every frame, not in a loop every frame. That should fix your problem ;)


Mon Feb 23, 2009 11:09 pm
Profile WWW

Joined: Sat Jun 16, 2007 8:04 pm
Posts: 42
Reply with quote
Post Re: Quick Console Commands
robolee wrote:
whilst a while loop is running nothing else will

Yeah i noticed that, i thought that the timers and console window would update independently of the play view.

robolee wrote:
replace while with if, I think this is what you want:
Code:
blah = 0; Sometimer = Timer(); if Sometimer:IsPastSimMS(10000) and blah == 0 then print("Going strong...."); blah = 1;end

Yeah that would be what i want, and i would have made it so if i would have UpdateActivity() at my disposal, but i was trying to make it work in skirmish games. I didn't think it to the end because that would make missions possible without the game calling UpdateActivity().

Also, the "not" part was not a mistake, as i wanted to run the script FOR a duration of 10 seconds, NOT after 10 seconds had passed. You see i was trying to make rain, but i forgot about Lord Tim's WeatherSystems :) Which is much more fun to play with than my script would have been i think. (But the water raindrops and hails are kinda slow. Snow is perfect. Tornado functions' arguments could have been fixed too. I hope Tim keeps working on this, it's good.)

TheLastBanana wrote:
The amount of MS on a timer is increased with a formula involving the FPS.

Didn't know that either, good to know. Thanks to both. So final answer is that the problem with that script can't be solved, without using UpdateActivity() in mission script.

Now this is fun:
Instant action!
Code:
for n=1, 5 do actor = CreateAHuman("Soldier Light"); actor.Team = 0; actor.Pos = Vector(1000 - (n * 50), 500); actor:AddInventoryItem(CreateHDFirearm("AK-47")); MovableMan:AddActor(actor); end; for n=1, 5 do actor = CreateAHuman("Soldier Light"); actor.Team = 1; actor.Pos = Vector(1000 + (n * 50), 500); actor:AddInventoryItem(CreateHDFirearm("AK-47")); MovableMan:AddActor(actor); end;


This same is fun too if you replace "50" with very low value, like 5, in "actor.Pos = Vector(1000 - (n * 50), 500);"
Adjust these coordinates to better suit the scene you're playing in.


Mon Mar 02, 2009 8:34 pm
Profile
User avatar

Joined: Sun May 18, 2008 8:30 am
Posts: 732
Reply with quote
Post Re: Quick Console Commands
Is it possible to add crafts to your inventory? If so, I want a string that adds a dropship(preferably on red team) to the current actors inventory just to see what happens.


Sat Mar 07, 2009 12:17 am
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: Quick Console Commands
CandleJack wrote:
Is it possible to add crafts to your inventory? If so, I want a string that adds a dropship(preferably on red team) to the current actors inventory just to see what happens.


A = ActivityMan:GetActivity():GetControlledActor(0); craft = CreateACDropShip("Dummy Drop Ship"); craft.Team = 0; A:AddInventoryItem(craft);
No hover device for you.


Sat Mar 07, 2009 5:20 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Quick Console Commands
You've been able to add dropships and rockets and anything at all really to actors for a while now.

AddInventoryDevice = Actor
CopyOf = Brain Case

Works.

You can also give Brains AHumans, or ACrabs AHumans.


Sat Mar 07, 2009 5:06 pm
Profile

Joined: Tue May 05, 2009 1:22 am
Posts: 1
Reply with quote
Post Re: Quick Console Commands
light soldier mid-air collision


Code:
local positionX = 400; local offSet = 200; for n = 1, 6 do actor = CreateAHuman("Soldier Light"); actor.Team = 0;  if n%2 == 1 then actor.Pos = Vector(positionX-offSet, (400 + 20 * n)); actor.Vel = Vector(50, 0); else actor.Pos = Vector(positionX+offSet, (400 + 20 * n-1)); actor.Vel = Vector(-50, 0); end; MovableMan:AddActor(actor); end;

positionX is where they should collide and offSet is how far apart they'll spawn.


Last edited by synt4x on Tue May 05, 2009 12:34 pm, edited 1 time in total.



Tue May 05, 2009 1:25 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Quick Console Commands
Code:
[code][/code]


Makes your code like nicer.


Tue May 05, 2009 5:21 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 140 posts ]  Go to page Previous  1 ... 6, 7, 8, 9, 10  Next

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.019s | 12 Queries | GZIP : Off ]