Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - bx83

#161
I tried getting rid of them as global variables, and writing like this:

Code: ags


//no var declarations


function ShowSaveGUI() {
  DynamicSprite *buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 192, 342);
  if (buttonSavePic1 != null) buttonSaveSlot1.NormalGraphic = buttonSavePic1.Graphic;
  
  DynamicSprite *buttonSavePic2 = DynamicSprite.CreateFromSaveGame(2, 192, 342);
  if (buttonSavePic2 != null) buttonSaveSlot2.NormalGraphic = buttonSavePic2.Graphic;
  
  DynamicSprite *buttonSavePic3 = DynamicSprite.CreateFromSaveGame(3, 192, 342;
  if (buttonSavePic3 != null) buttonSaveSlot3.NormalGraphic = buttonSavePic3.Graphic;
  
  gSaveLoad.Visible = true;
}


However, now I have it telling me:
"Local variable cannot have the same name as an import"
for first line: 'DynamicSprite *buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 192, 342);'

Searched for all other instances of buttonSavePic1 - they're only in this line. Confounded.
#162
No. I haven't exported it or imported in .ash.
#163
I'm wanting to create the save-game system of 3 screenshotted games above.
However I keep getting "Attributes of identifier do not match prototype" on the first line of code (DynamicSprite *buttonSavePic1;). Not sure what this error means (other than I can program Basic but not C++ :P)

global.asc:
Code: ags
DynamicSprite *buttonSavePic1;
DynamicSprite *buttonSavePic2;
DynamicSprite *buttonSavePic3;

function ShowSaveGUI() {
  buttonSavePic1 = DynamicSprite.CreateFromSaveGame(1, 171, 96);
  if (buttonSavePic1 != null) buttonSaveSlot1.NormalGraphic = buttonSavePic1.Graphic;
  
  buttonSavePic2 = DynamicSprite.CreateFromSaveGame(2, 171, 96);
  if (buttonSavePic2 != null) buttonSaveSlot2.NormalGraphic = buttonSavePic2.Graphic;
  
  buttonSavePic3 = DynamicSprite.CreateFromSaveGame(3, 171, 96);
  if (buttonSavePic3 != null) buttonSaveSlot3.NormalGraphic = buttonSavePic3.Graphic;
  
  gSaveLoad.Visible = true;
}


function buttonSaveSlot1_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  SaveGameSlot(1, "Save 1");  
  Wait(GetGameSpeed()*1/2);
  gSaveLoad.Visible=true;
}

function buttonSaveSlot2_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  SaveGameSlot(2, "Save 2");  
  Wait(GetGameSpeed()*1/2);
  gSaveLoad.Visible=true;
}

function buttonSaveSlot3_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  SaveGameSlot(3, "Save 3");  
  Wait(GetGameSpeed()*1/2);
  gSaveLoad.Visible=true;
}

function btnSave_OnClick(GUIControl* control, MouseButton button)
{
  gPanel.Visible = false;
  mouse.UseDefaultGraphic();
  gIconbar.Visible = true;
  Wait(1);
  
  ShowSaveGUI();
}


function buttonLoad1_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(1);
  mouse.UseModeGraphic(eModePointer);
  gIconbar.Visible=true;
}

function buttonLoad2_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(2);
  mouse.UseModeGraphic(eModePointer);
  gIconbar.Visible=true;
}

function buttonLoad3_OnClick(GUIControl *control, MouseButton button)
{
  gSaveLoad.Visible=false;
  RestoreGameSlot(3);
  mouse.UseModeGraphic(eModePointer);
  gIconbar.Visible=true;
}


Apart from the other 27 minor bugs in this code, can anyone help me with the error?
#164
I've included a bit of code in a room which manually animates an object, and plays 'linked' sounds for each frame; it then adjust the volume depending on the players position and closeness to the object.
The sounds are played at full volume for the first second; what should I do to keep the sound consistent?

Code: ags
function SoundDistDS(int x, int y, int radius, int minVolume)
{
  int Volume=0;
  int dx = 610 - x;   //hard coded in pos of darkseeds sign
  int dy = 515 - y;
  int d_squared = dx*dx + dy*dy;

  if(d_squared >= (radius * radius))
    Volume = minVolume;
  else
    Volume = FloatToInt(100.0 - (Maths.Sqrt(IntToFloat(d_squared))/IntToFloat(radius)) * (100.0 - IntToFloat(minVolume)));
    
  return Volume;
}


function PlaySoundDS(int animFrame)
{
  switch (animFrame) {
    case 0: ds_chan=aNeon_1.Play(eAudioPriorityNormal, eOnce);break;
    case 1: ds_chan=aNeon_2.Play(eAudioPriorityNormal, eOnce);break;
    case 2: ds_chan=aNeon_1.Play(eAudioPriorityNormal, eOnce);break;
    case 3: ds_chan=aNeon_2.Play(eAudioPriorityNormal, eOnce);break;
    case 4: ds_chan=aNeon_1.Play(eAudioPriorityNormal, eOnce);break;
    case 5: ds_chan=aNeon_2.Play(eAudioPriorityNormal, eOnce);break;
    case 6: ds_chan=aNeon_1.Play(eAudioPriorityNormal, eOnce);break;
    case 7: ds_chan=aNeon_2.Play(eAudioPriorityNormal, eOnce);break;
    case 8: ds_chan=aNeon_1.Play(eAudioPriorityNormal, eOnce);break;
    case 9: ds_chan=aNeon_2.Play(eAudioPriorityNormal, eOnce);break;
    case 10: ds_chan=aNeon_3.Play(eAudioPriorityNormal, eOnce);break;
    case 11: break;
    case 12: break;
    case 13: break;
  }

  ds_chan.Volume=SoundDistDS(cJulius.x, cJulius.y, 300, 3);
}

function late_repeatedly_execute_always()
{
  //Display("wa %d, yctr %d", wa, yctr);
  wa++;
  if (wa>20) {
    wa=0;
    yctr++;
    if (yctr>13)
      yctr=0;
   
    ViewFrame *vf;
    vf=Game.GetViewFrame(10, 0, yctr);
    oDarkSeedsSign.Graphic=vf.Graphic;
    PlaySoundDS(yctr);
  }
}


function room_Load()
{
  ...
  oDarkSeedsSign.SetView(10);

  wa=0;//global
  yctr=0;//global
...
}


#165
Also simpler code:

Code: ags
transCtr++;
  if (transCtr > 5) {
    transCtr=0;
    int y=0;
        
    //do calculations
    for (int x=0; x<12; x++) {
      
      y=x+6;
      
      if (x==10) Display("b4 load out: for %d, dir %d trans %d obj %d",x, stardir[x], stars[x], object[y].Transparency);
      stars[x]=object[y].Transparency;
      if (x==10) Display("a4 load out: for %d, dir %d trans %d obj %d",x, stardir[x], stars[x], object[y].Transparency);
      
      if (stars[x]+stardir[x]<0) {
        stars[x]=0;
        stardir[x]=1;
      }
      if (stars[x]+stardir[x]>100) {
        stars[x]=100;
        stardir[x]=-1;
      }
      
      stars[x]+=stardir[x];
      if (x==10) Display("a4 calcs for %d, dir %d trans %d",x, stardir[x], stars[x]);
      
      if (x==10) Display("b4 obj trans %d array %d",object[y].Transparency, stars[x]);
      object[y].Transparency=stars[x];
      if (x==10) Display("a4 obj trans %d array %d",object[y].Transparency, stars[x]);
    }
   
    Display("obj trans %d", object[16].Transparency);
  }
#166
So what do I do? I just want numbers 0..100 stored as they are.
#167
I'm trying to have the Transparency for 12 objects bob between 0 and 100, so they act like lights dimming and growing fuller. Each should have a sin wave pattern: growing stronger, growing weaker, growing stronger, etc.
For this example I've only picked the 10th object.

Everything except the last few lines acts as expected.


The code:

Code: ags
function room_RepExec()
...
  transCtr++;
  //every 5th loop, run this code
  if (transCtr > 5) {
    transCtr=0;
    
    //load out temporarily
    for (int z=0;z<12;z++) {
      stars[z]=object[z+6].Transparency;
      if (z==10) Display("load out: for %d, dir %d trans %d",z, stardir[z], stars[z]);
    }
    
    //do calculations
    for (int x=0; x<12; x++) {
      
      if (x==10) Display("b4 for %d, dir %d trans %d",x, stardir[x], stars[x]);
      
      if (stars[x]+stardir[x]<0) {
        stars[x]=0;
        stardir[x]=1;
      }
      if (stars[x]+stardir[x]>100) {
        stars[x]=100;
        stardir[x]=-1;
      }
      
      stars[x]+=stardir[x];
      if (x==10) Display("a4 for %d, dir %d trans %d",x, stardir[x], stars[x]);
    }
    
    //load back in
    for (int y=0;y<12;y++) {
      object[6+y].Transparency=stars[y];
      if (y==10) Display("%d %d ?",object[6+y].Transparency, stars[y]);
      if (y==10) Display("load back in: for %d, dir %d trans %d",y, stardir[y], stars[y]);
      if (y==10) Display("so %d is now trans %d - matching %d?",y, object[6+y].Transparency, stars[y]);
    }
    
    Display("trans %d", os11.Transparency);
  }
...




Example output:

note: dir, or stardir[counter], is direction - growing weaker or stronger by having 1 or -1 added to transparency.


load out: for 10, dir 1 trans 96 <--load values into array
b4 for 10, dir 1 trans 96          <--before doing calculations
a4 for 10, dir 1 trans 97          <--after doing calculations
98 97 ?                                  <-- is the value of object 10's transparency (that we got the value out of) equal to value 10 of the array of transparency counters, after we made it equal to it? Nope - wtf?
load back in: for 10, dir 1 trans 97   <-- put damaged value back in object 10, etc.
so 10 is now trans 98 - matching 97?
trans 98

load out: for 10, dir 1 trans 98
b4 for 10, dir 1 trans 98
a4 for 10, dir 1 trans 99
100 99 ?
load back in: for 10, dir 1 trans 99
so 10 is now trans 100 - matching 99?
trans 100.  <-- loop doesn't grow weaker

load out: for 10, dir 1 trans 100
b4 for 10, dir 1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100

load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100

load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100

ad infinitum


The problem seem to be, 1 is added always to object[6+y].Transparency on the last 4 Display() lines, but I can't see how. For instance, it's object[10].Transparency=stars[y], not object[10].Transparency+=stars[y], so i don't see how it could have happened.

note: 6+y just means object indexes are 6 more than the counter, so the 10th object (which is actually object 11 out of 12 not using zero index), is object[16]. I included this pointless complexity because I obviously don't know what's the code's doing, and you might :/

????
#169
I remove all the items in the inventory, updateinventory(), don't show the user; add a couple of item back, updateinventory(), don't show user.

Finally, when the user clicks the inventory and makes it visible, the inventory is 'up' 1 row; it doesn't sit with the first line of items at the top, rather they are one row upwards, hidden. How can I manually update and reposition it so the first row sits flush and can be seen?
#170
His name, from his perspective as an ancient Jew, was Yeshua Ben Jusef / "God". (Joshua, son of Joseph/God)
#171
Um....
"What is Jesus Christ's real name?"

(not a joke)
#172
1858
The "shit we have to build a sewage system, they've got flushing toilets now" period.
#173
Do you have a link to that publication?
#174
"On September 29, 1913, Rudolf Diesel, inventor of the engine that bears his name, disappears from the steamship Dresden while travelling from Antwerp, Belgium to Harwich, England. On October 10, a Belgian sailor aboard a North Sea steamer spotted a body floating in the water; upon further investigation, it turned out that the body was Diesel’s. There was, and remains, a great deal of mystery surrounding his death: It was officially judged a suicide, but many people believed (and still believe) that Diesel was murdered."

You got it :)
#175
André Citroën
Étienne Lenoir
Siegfried Marcus
Alexander Winton
George B. Selden
Arthur Constantin Krebs
George Foote Foss
Milton Reeves
Robert William Thomson

??
#176
John Boyd Dunlop.
#177
Thank you, works :)

One more bit of fun; I've found https://www.adventuregamestudio.co.uk/forums/index.php?topic=55545.0, which is a great Timer script to replace standard timers in AGS.
To define a global timer (with a name), how do I do it?

.ash
Code: ags
Timer              *GVTimers[20];
export GVTimers;

.asc
Code: ags
import Timer              *GVTimers[];


error: .ash, expected variable or functions after import, not 'Timer'

ps. only 20 indices because that's the maximum amount of timers that can run simultaneously.
#178
Thankyou for this, just what I was looking for :)


As usual, having trouble defining things...

.asc
Code: ags
enum eGVInt {
  eFirst=0, 
  eSecond=1,
  eThird=2
};


function game_start()
{
  GVInt = new int[999];
........
}

export eGVInt;


.ash
Code: ags
import int eGVInt;


error: "eGVInt is already defined" (referring to line 'enum eGVInt {', first line in .asc)
#179
I had my definitions wrong, sorry everyone.

Code: ags
Timer *MyTimer;

function room_Load()
{
  MyTimer = Timer.StartLocalRT(12.0, eTimerPause, eOnce);
}
SMF spam blocked by CleanTalk