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.

Author
Message
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 5th Jan 2011 15:13
i am having issues geting the scancode and keystate comands to work and the error mesage says that the peramiters are wrong but i dont know how to change them.
if scancode (x)=(1) then clear world

tsm
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Jan 2011 18:06

ScanCode returns the number of a key being pressed,
KeyState returns whether a specific key is being pressed.

(I'm also assuming Clear World is a pseudoname, just as an example)

My signature is NOT a moderator plaything! Stop changing it!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jan 2011 18:40
@scancode issues,
Do you really want that to be your forum name? When you decide on a different one, email me and let me know - just copy the link from your profile button into the email, and your new name.

theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 6th Jan 2011 14:36
the program is still not allowing me to run the program
the error mesage says "can not understand command at line..."
if Keystate (x) = 1 Then ClearWorld

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 6th Jan 2011 14:49
the comand clearworld is supposed to delete everything to make it posible to add a second level

tsm
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Jan 2011 15:15
If you have a function called 'ClearWorld' then you call it like so:


Your entire line should be:


theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 7th Jan 2011 14:59
i have given my code and need help with where to put the keystate commands



tsm
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Jan 2011 16:30
Quote: "i have given my code and need help with where to put the keystate commands "

it depends on what you want them to do, and when in the program you want to do them!

My signature is NOT a moderator plaything! Stop changing it!
Mugen Wizardry
User Banned
Posted: 7th Jan 2011 16:43
If you want your keystate to detect a key PRESS and not a key HOLD (which is default in dbpro), use this pseudo code in your loop:



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Jan 2011 20:21 Edited at: 7th Jan 2011 20:23
(Not that this was his question but...)
Quote: "myoldkey=mykey
mykey=keystate(x) `replace x with keystate number
if myoldkey<>mykey
if mykey
`do stuff
endif
endif"

That's slightly incorrect as it will only work for 1 key.

What I did, is create two arrays to store the keypresses of every key. (I just created an array from 1 to 300 for simplicity)

So, I had OldKeyState( 300 ) and NewKeyState( 300 )

Every loop, I iterate through every array element and set OldKeyState( Id ) to be whatever was in NewKeyState( Id ), then Set NewKeyState( Id ) to be KeyState( Id )

What this does, is keep a track of what keys were pressed last time, (In OldKeyState) and get the new keypress and save them to NewKeyState.

To Check if you have a keypress, you check NewKeyState( Key ) And to check for a key release, check that NewKeyState( Key ) = 0 And OldKeyState( Key ) = 1.

My signature is NOT a moderator plaything! Stop changing it!
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 10th Jan 2011 14:31
i want the keystate stuff to clear the world so i can add a second level.

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 10th Jan 2011 14:31
ps thanks to the moderator for changing my name for me

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 11th Jan 2011 14:41
Mobiius how do i do what you are saying i should do?

tsm
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th Jan 2011 15:26
Thats not really a question anyone but you can answer.

You need to write code which will do what you ask, (which only you can do) as for a keystate to call it, look at the very first code snippit I posted.

Quote: "If Keystate(x) = 1 Then ClearWorld"


You need to add this code into your current code. You change the X in the keystate command to match the scancode of the key you want to trigger the change of level, and 'ClearWorld()' is a name of a function YOU have created. You can call this function anything you want, but first you need to create this function.

I can't run the code you've provided as I don't have the media, but you need to have a look through it and decide at what point do I want to be able to change to the next level? Then you need to write the code to do it.

My signature is NOT a moderator plaything! Stop changing it!
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 13th Jan 2011 14:54
i appreciate your patience with my ignorance and my code works properly. this thankyou goes out especialy to Mobiius who was the first to start helping me with the errs in my game

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 13th Jan 2011 15:04
what does it mean when the error says
Quote: "can not close nest at line 447"


tsm
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jan 2011 19:22
It means you have something like this without a matching endif:



or this without a closing next



etc.

Check your code and make sure that every "if", "for", "do", "function", etc, has the appropriate closing statement.

To do this quickly it helps if you've carefully indented your code so you can spot the closing statements easily. If you haven't indented your code then do it now.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Jan 2011 19:56
Quote: "this thankyou goes out especialy to Mobiius who was the first to start helping me with the errs in my game"

No Worries! Glad to help.

My signature is NOT a moderator plaything! Stop changing it!
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 14th Jan 2011 14:40
this is where the err is ocuring

ive changed it to

there is still an error that says variable if is invalad at line 447

tsm
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 14th Jan 2011 18:03
when use use the IF command followed with THEN, you don't need ENDIF.

Example

works:
IF x = 1 THEN x = 2

---
Doesn't work:
IF x = 1
x = 2

----

Works:

IF x = 1
x = 2
ENDIF

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jan 2011 19:37
The original error may be before the do loop block.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2011 01:17
@ theSPACEmafia:

Why is the label _newmatrix within the DO/LOOP? If you GOTO or GOSUB to _newmatrix you'll create an error simply because DO is before the label. And "end if" is one word "endif" but it shouldn't be used at all unless you have an IF statement without a "then".

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Jan 2011 12:00
True. But does that give the close nest error?
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2011 17:33
I just tested it and it doesn't produce an error. I guess it's just looks really bad.

You're right it's higher up in the code maybe close to where it GOTOs or GOSUBs from.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 16th Jan 2011 17:44
From what I can see at the end you have an if statement, you use the then option, then next line you use endif. You only need to use end if if you do not use then.
For instance

If scancode()=1 then game=1

could be

if scancode()=1
game=1
endif

Both do the same thing, using endif just gives you more freedom to add more conditions or more variable alterations etc. A nesting error means the program is trying to run or close a loop that is not correctly defined.

http://s6.bitefight.org/c.php?uid=103081
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Jan 2011 18:39
Quote: "Why is the label _newmatrix within the DO/LOOP?"


Nothing wrong with that, after all such a construct is more or less the same as a label and a GOTO.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Jan 2011 14:28
Interesting. I expected that to fail when you do this:



But it doesn't.

Looks like a recipe for an ultimate coding disaster to me.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Jan 2011 14:33
Yeah, nothing good will come from coding like that! I think we just discovered how to make goto's even worse! lol

My signature is NOT a moderator plaything! Stop changing it!
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Jan 2011 08:48
Lets just hope no other newbies try it.

theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 18th Jan 2011 14:40 Edited at: 18th Jan 2011 15:12
i cant find any unended statments in my code so maby my computer just hates me but if u see any errs let me know plz


tsm
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Jan 2011 16:07
There's at least one problem. Every "do" must have a matching "loop". Look at this part again:

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2011 07:17
The major one is line 422 needs a LOOP that closes the DO of line 145. The rest of the problem is the area Green Gandalf highlighted.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Jan 2011 12:59
I thought that was the error that I highlighted.
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 19th Jan 2011 14:48 Edited at: 19th Jan 2011 14:58
i fixed that error but now there is a new one
i have edited my code and now the error is the comand next sc is out of place at line 351 but that is where it has ben since i started using this code can you help me? the section is


tsm
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2011 17:10
@ Green Gandalf:

One line above what you highlighted.



@ theSPACEmafia:

You forgot two ENDIFs. Since you use only one space for indention (like I do) it's easy to see when you've accidentally forgot to close a loop because you'll see two spaces instead of just one (like how next sc and next bu are two spaces out).



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Jan 2011 17:20
@Grog Grueslayer

I see.

@theSPACEmafia

You've been told several times in this thread what you need to check but you are still expecting us to do your basic checking for you. Please do it yourself next time - or at least convince us you've tried.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2011 18:20
@ Green Gandalf:

I would suggest to him to turn on his IDEs autoclose loops but you're 100% right... he does need to learn to do it the hard way first.

theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 20th Jan 2011 14:37
what does it mean when the error says lable does not exist but the lable says
Quote: "gosub endloop"


tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 20th Jan 2011 14:38 Edited at: 20th Jan 2011 14:42
im sorry that im an uber noob in this program which is why i appreciate your help

tsm
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Jan 2011 15:40
It means the subroutine labelled endloop: doesn't exist. You need to have a subroutine block something like the following at the end of your code:

theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 21st Jan 2011 14:34
thank you that error is gone now but the nest error is back so im going to check my code.

tsm
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jan 2011 17:02
You might find it helpful to make the indenting more obvious, e.g two or three spaces rather than just one.

As a last resort count the number of times "for" appears in your code and check you have the same number of "next"s. Ditto for the other pairs such as do/loop and if/endif (and watch out for the occasional if/then which might confuse the issue).

Let us know how you get on. We know it's a chore but it's something we all have to get used to. Once you get used to it you should find you don't make those errors so often.
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 24th Jan 2011 14:44
im just going to assume that the program hates me because the code looks fine to me but it still wont work

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 24th Jan 2011 14:47
nevermind my the program hates me because i almost have the code working

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 24th Jan 2011 14:52
i changed my mind again the program hates me

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 24th Jan 2011 14:55
i finaly got it to work XD

tsm
theSPACEmafia
15
Years of Service
User Offline
Joined: 5th Jan 2011
Location: somewherez majikalz
Posted: 24th Jan 2011 15:00
I LIED it seaced operation darkbasic was teasing me

tsm
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Jan 2011 19:42
Wow! A 5 post multipost! World record?

My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jan 2011 22:30
On two counts at least: 1. minimal useful content; 2. maximal number of posts.

Login to post a reply

Server time is: 2026-07-16 12:19:33
Your offset time is: 2026-07-16 12:19:33