Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Types wont accept some values?

Author
Message
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2003 04:21
Ok, I dunno wassup with this. For my player entitys I setup a Type to contain all their info. There can be a maxium of 16 players, so I dim an array(15) of Player. Now, I have my own seperate function for loading objects - it basically just uses the next free object id and then returns that value (the object id) for storing so you can refrence the object later. Now I have this code:



That works fine (and the objects are loaded okay ect ect) but when you try to manipulate an object through Players(PlayerID).BaseID ect it fails saying illegal object number. My first thought was my loadobject function was failing to return a value.. but thats not the case. Whats happening is that Players(PlayerID).BaseID is failing to keep the integer value thats passed back to it. I tried printing the contents of BaseID and TurretID, they were both 0. And then I tried this:



and printed them both. Most intresting! A contains the expected value returned from the function fine. But Players(PlayerID).TurretID still contains 0.. despite me quite simply telling it to = a right there and then. Whats going on here? Anyone got any clue? This has got me completly baffled :/
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2003 05:45
I fixed it - My array was declared in arrays.dba. It seems that if i want an array to be globaly remembered... i have to dim it in the main project file (despite the fact it was declared as global). Ohwell, i think thats just a little lame.. but im glad it was that easilly fixable

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Apr 2003 16:08
That's hopefully being fixed by Lee in Patch 5 - I made a small suggestion on how to fix this that he liked

Basically, included files never run the code that builds the array to the size you specify, so all arrays in included files are empty and all variables declared in included files are set to zero.

A work-around for you though - have an initialise function that you can call to build your array for you:



It's important to declare the array as global both at the top of your file, and in your function. Otherwise even stranger things start to happen.

Login to post a reply

Server time is: 2024-11-24 10:32:44
Your offset time is: 2024-11-24 10:32:44