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 AppGameKit Corner / Code works until I move it into another agc file(not the main)

Author
Message
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 20th Jun 2017 01:17 Edited at: 20th Jun 2017 01:19
Curious if anyone can help me out here. I have moved my code to another agc file that I include in the main. A certain line stopped working, and I have no idea what.
This line:
if GetObjectExists( cloneIDs[t,1,0].door )
wallID = objectspherecast(0, GetObjectX( cloneIDs[t,1,0].door ), 1.0, GetObjectZ( cloneIDs[t,1,0].door ), GetObjectX( cloneIDs[t,1,0].door ), 1.0, GetObjectZ( cloneIDs[t,1,0].door ), 0)
if GetObjectExists( wallID ) then DeleteObject(wallID)
endif

The odd thing is it does exist, and when I printc( cloneIDs[t,1,0].door ) there is an object ID...

main.agc - where it works (its line 171)



LoadRandomDungeon.agc - everything else works except this line(line 164)



This is completely bizarre. I've tried many things, and I have come to the conclusion that is not returning as an object existing. I know this is like finding a needle in a haystack, but maybe there is something I don't understand about #include...
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Jun 2017 02:20
I would say it probably has something to do with persistence.
i would make sure i define wallID as a global up the top of you program
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 20th Jun 2017 15:16
Or at least initialize wallID inside the function. What kind of error are you getting? Is it a compiler error or is it during runtime?
13/0
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 23rd Jun 2017 22:54 Edited at: 23rd Jun 2017 23:00
Quote: "when I printc( cloneIDs[t,1,0].door ) there is an object ID..."


Quote: "wallID = objectspherecast(0, "


Check your object ID, "cloneIDs[t,1,0].door" or "0"?
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 29th Jun 2017 00:46
Cybermind, the "error" was during runtime, not a compiler error. It would just lay the door on top of the wall, instead of deleting the wall like it used to.

I no longer use any of that code, since I am learning AppGameKit as I find more efficient ways of coding I usually rewrite that portion to be more efficient. I have recreated it the generator. But, I am still curious as to what I was not understanding.

Why would I need to initialize it in the function? I do not understand this. It worked when included in the main before, and I have never needed to declare anything inside a function any other way.

Also, why include as global? It is not a global. It only pertains to that function. I am just trying to understand. I have many rooms, and setting this as global would not be a good idea, imo. I just wanted that variable for that function.

I cannot test it for the doorID. Because that is the object that should not be deleted. So, of course, that will be hit, because I am setting it on top of the wall.

It worked perfectly before moving it over. It was supposed to delete the wall, and replace it with a door. Which it did. Until I moved it into its own AGC file. Then it just placed the door on the wall.

Login to post a reply

Server time is: 2024-11-22 07:43:38
Your offset time is: 2024-11-22 07:43:38