Structure Not Found

Just starting out? Need help? Post your questions and find answers here.
Pet Shop Idle
New User
New User
Posts: 1
Joined: Mon Sep 01, 2025 3:17 am

Structure Not Found

Post by Pet Shop Idle »

I am new to PureBasic and am working on an idle game. I'm creating a function to initialize all gadget structures so that I can build the necessary gadgets from the widget structure data. I'm getting the error "structure Widget not found," even though I've included the file and confirmed the name is correct, including capitalization. Any help would be greatly appreciated.

Link to code: https://www.dropbox.com/scl/fi/b6sjbiqy ... p60q7&dl=1
infratec
Always Here
Always Here
Posts: 7613
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Structure Not Found

Post by infratec »

A module is isolated so you need an extra include inside of the module:

Code: Select all

DeclareModule Widgets
  
  IncludeFile "Structures.pb"
  
  Dim PetGadget.Widget(6)
  Dim ContGadget.Widget(6)
  
  Declare InitGadgets()
 
EndDeclareModule
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Structure Not Found

Post by miso »

Hello, and welcome to the forums. Modules are encapsulated, so they are not being modified with codes (or structures can't be used) that are outside a module. There are tricks to do it though. For a small idle game, you can add the structures to all of your modules that needs them.

(I like modules and they are powerful, but for learning experience and for a small little game, they are not absolutely necessary.)

Anyway, don't worry. First steps are always like that. Feel free to ask (there will be more questions, but also there will be someone who will happily answer it).
Post Reply