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.

AppGameKit Classic Chat / Error Failed to set position

Author
Message
Olde Worlde Illusions
3
Years of Service
User Offline
Joined: 10th Oct 2021
Location:
Posted: 28th Nov 2021 05:39 Edited at: 28th Nov 2021 05:52
Hi,

I'm trying to create a simple board using a bunch of small squares and got the error message:


Here is the code the error is complaining about:


EDIT:
Round 2

No luck!

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Nov 2021 06:01
When width = 6 and height =8 you will get exactly the same number as width = 8 and height = 6
I think you might want to use a sequential number as the object id
also createobjectbox() should be CreateObjectBox(1+(w*h), 1, 1, 1) // Requires three 1s because width, height, depth
Olde Worlde Illusions
3
Years of Service
User Offline
Joined: 10th Oct 2021
Location:
Posted: 28th Nov 2021 06:44
Quote: "When width = 6 and height =8 you will get exactly the same number as width = 8 and height = 6
I think you might want to use a sequential number as the object id
also createobjectbox() should be CreateObjectBox(1+(w*h), 1, 1, 1) // Requires three 1s because width, height, depth"

Ok, thanks for the advice. I just started with AppGameKit and am hoping to win the e-books. It’s 1am here so I will try to fix it early in the morning. Is there a way to automatically allocate the id?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Nov 2021 07:21 Edited at: 28th Nov 2021 07:21
Quote: "Ok, thanks for the advice. I just started with AppGameKit "

Ask as many questions as you like! We are all happy to help.
Looking forward to your TD entry.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 28th Nov 2021 08:25 Edited at: 28th Nov 2021 08:46
Quote: "Is there a way to automatically allocate the id?"
yes. see HERE.

so, you'd do something like:

the idea is to let AppGameKit allocate the object IDs (my preference) but you'll need some way to reference those object IDs later.

so, if the boxes represent your map, make an array (ie, Map[4,4] ) for easy reference to those IDs.

if you want to change one of the boxes, say the box at 1,1 then the ID of that box would = Map[1,1]

this:

...finds the object id at a random location in the Map and changes its color, for example.

otherwise, do yourself a big favor and skim through the guides and the rest of the help files
Olde Worlde Illusions
3
Years of Service
User Offline
Joined: 10th Oct 2021
Location:
Posted: 28th Nov 2021 22:41


Quote: "error: Unexpected token "board_size", Array dimension must be an integer literal or a constant"
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Nov 2021 23:10 Edited at: 28th Nov 2021 23:13
When defining an array you can only use a literal or constant.
You can however do this;



Also I would recommend against making your type the same name as your variable. It tends to break the goto definition function within the IDE

Login to post a reply

Server time is: 2024-11-21 12:31:15
Your offset time is: 2024-11-21 12:31:15