Jump to content

Photo

Help With Script


  • Please log in to reply
18 replies to this topic

#16 Mibbitable

Mibbitable

    Junior

  • Members

Posted 14 November 2017 - 01:06 AM

Yeah, I guess I just overthink things a lot and make problems harder than they should be.



#17 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 14 November 2017 - 04:49 AM

Yeah, I guess I just overthink things a lot and make problems harder than they should be.


Unless you are using the stats for something, remove them, and the init refs to them. Those were from one of my old test scripts for a stats menu.

I sent you a link to newer code that is much cleaner.

You do not need DrawInteger to display the XP. The entire purpose of storing it in a counter is to display it with normal passive subscreen mechanics. Download an older 'Legacy of Emperors' demo, and look at how the passive subscreen is constructed.

#18 Mibbitable

Mibbitable

    Junior

  • Members

Posted 14 November 2017 - 04:03 PM

All i'm using is Health and Magic, so I can delete all those others with no issue?



#19 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 15 November 2017 - 04:23 AM

[quote name="ZoriaRPG" post="1030714" timestamp="1510737821"]

You can delete them, but you must also delete anything that references them (e.g IncreaseStat() in the Level*() functions).

For XP, this specific revision of the script uses two counters, to display a value up to 99,999,999. The low counter (CR_XP) is for values 0 to 9999, and the high counter (XP_10K) is for the ten-thousands place, upward. I later rewrote that entire section of code to use a float, and to draw the float as a string, removing the decimal, and inserting commas.

With this code, you need omly add counters to your subscreen for each place-set, and align them so that the two counters appear to be one, as I did in the old LoE demos.


This is the sort of function to turn a float into a drawn long (with commas). I'm retyping it from memory, and there is probably a way to optimise it.



void FloatToLongStr (float f, int str)
{
   int buffer[14]: int buffer2 [14]; int com;
    ftoa(f,buffer); in len; int pos, int q;
    for ( q = 0; q < 14; ++q )
        if (buffer[q] == 0) break;
        if ( buffer[q] == '.')
        {
             buffer[q] = 0; continue; 
        }
        buffer2[pos] = buffer[q];
        ++pos; ++len; buffer[q] = 0;
    }
    //add command to get
    for (q = len; q >= 0; --q)
    {
     
         if ( q < len-2 && !q%3 ) { buffer[q] = `,`; ++com;}
         else buffer[q-com] = buffer1 [q];
    }
     //shift the output
     int zeros; int w;
     for (q = 0; q < 14; ++q)
     {
         if ( buffer[q]  == 0) continue;
          else
          {
               str[w] = buffer[q];
               ++w;
          }
          str[w] = 0;  //terminate
      }
}

Edited by ZoriaRPG, 15 November 2017 - 05:10 AM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users