mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2009
Posts: 2
S
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Oct 2009
Posts: 2
Im playing a game, where you need Sciencepoints (SP) to get a Science done. SP are produced from Labs. The more Labs, the more SP are produced an hour. Ofc, the time to do a science changes, when you build more Labs. To do the sciencework on "Flying", you need 1000 Sciencepoints. If you have an income of 100 SP an hour, you need 10h to get it done.

If you build a Lab every 8h, you will have done 800 SP of the "Flying"-job, till your income reaches 110 SP/h. For the last 200 SP you will need less then 2h.

What i want to do with mIRC:
How much time is needed to get a Science Job done, when i keep building Labs?

And thats where i stand (theoretical):
The Mathematical term for the Calculation is a "Growth", i dont know the correct English term for the kind of growth it is ...

Trigger line: !forschen "SP needed" "SP per Lab/h"
"SP per Lab" is needed because different kind of Labs (big ones, small ones) produce a different amount of SP/H

A lab is beeing build every 8h

$2 = SP needed
$3 = Sp per Lab/h

var %SPleft $calc($2 - ($3 * 8)) <= SP left after 8hours
$calc(%SPleft / $3) <= Time needed till the Job (SP left) is done.

k, here we are. thats easy, it could be done in one line, i just used 2 to show the two parts of the calculation.

What I think mIRC should do, but what i cant script ;):
Use the %SPleft from Step 1 and do the $calc again (I'm building a second lab directly after the first one is done).

The Script should loop the Calculation till SPleft reachs Zero, and then prompt how long it will take to finish Science ... This should be possible to be calculated from the times of loops aka the amount of labs build.

I hope you can help me =) I just started scripting and did some stuff I'm really proud off, but thats just something I dont know how to do wink

MFG
Stichlasser

Joined: Oct 2009
Posts: 2
S
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Oct 2009
Posts: 2
Ok, so heres what i got so far ...

Code:
# $1 !timeleft/trigger
# $2 SciencePoints needed
# $3 SP produced at start of the Process
# $4 Time till next Lab is build. refered to as building loop.
# $5 SP/h that is gained when a Lab is build.
# 

on *:input:#kilrathy-iw: {
  if ($1 == !timeleft) { 
    if ($calc($2 - ($3 * $4)) >= 0) { ; the script starts 
      var %time 0 ; %time variable to see how many "goto-steps" where done
      var %sph $3 ; SP produced at start of the Process is set to variable %sph 
      var %step2 $2 ; SP needed is set to variable %step2
      goto step1 
      :step1 
      var %step1 $calc(%step2 - (%sph * $4)) ; calculates the SP that is left after the first building loop
      if (%step1 <= 0) { msg $chan %time ; stops the script if SP left is smaller then 0 (no more SP needed = Science done)
      halt }
      else { inc %time 1 ; if Science isnt done yet, building loop timer goes up an
        goto step2 ; we go on to the same calc with the values of the previous step
      }
      :step2 inc %sph $5 , increase the amount of produced SP/h by the new gained production after a single building loop. 
      var %step2 $calc(%step1 - (%sph * $4)) ; same as in step1
      if (%step2 <= 0) { msg $chan %time ; same as in step1
      halt }
      else { inc %time 1
        inc %sph $5
      goto step1 ; here the loop starts }
    }
  }
}


it doesnt work at all.
ok, if times to short at the beginning, it works wink else its just looping even when theres a halt in there ...

Joined: Jul 2008
Posts: 236
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Jul 2008
Posts: 236
start by putting your comments on separate lines to your code. mIRC doesn't like that. also put end braces } on their own lines.

Last edited by s00p; 11/10/09 03:17 PM.
Joined: Feb 2003
Posts: 26
M
MRN Offline
Ameglian cow
Offline
Ameglian cow
M
Joined: Feb 2003
Posts: 26
And mixing ":step2" and other commands AND comments is also not good.



Link Copied to Clipboard