Page 1 of 1

Structure Not Found

Posted: Mon Sep 01, 2025 5:19 am
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

Re: Structure Not Found

Posted: Mon Sep 01, 2025 8:37 am
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

Re: Structure Not Found

Posted: Mon Sep 01, 2025 9:38 am
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).