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 - NearExtinctionEvent

#1
Here's my code.

(the part in the header)
Code: ags
//make struct
managed struct EnemyStats {
    int hp;
    int atk;
    int def;
    int xpyield;
    int nameid;
    
    import static EnemyStats* Create(int hp, int atk, int def, int xpyield, int nameid);
  };

(the part in the body)
Code: ags
// i dont even know anymore
static EnemyStats::Create(int hp, int atk, int def, int xpyield, int nameid);
  {
    EnemyStats* e = new EnemyStats;
    e.Init(hp, atk, def, xpyield, nameid);
    return e;
  }
Code: ags
 // the actual stats builder
  
  EnemyStats* HumanWeak = HumanWeak.Create(30, 1, 4, 10, 1);

'HumanWeak' is the instance I'm trying to get globally, but I can't figure it out (as previously stated). Most of this is readapted from the code examples in the manual.
#2
I was attempting to use structs for an RPG I started building, and following the manual. The managed struct itself is defined in the header, and has the factory module from the examples in the manual. I used the factory module to create an instance, but I've had trouble getting it out of GlobalScript and into rooms.

When I have an import call in the header, I get the error 'Local variable cannot have the same name as an import'. When I attempt to run the factory in the header or room where I need the instance, I get the error 'cannot assign initial value to global pointer'.

How would I go about making this work?
SMF spam blocked by CleanTalk