Forums

Topic: Petit Computer

Posts 2,581 to 2,600 of 9,620

randomous

If you take a look at my Village demo http://db.tt/53xhb7Fw , it loads in about 16000 values from a GRP file. The loading screen in the beginning of the game will give you an idea of how long it takes to load those values. Note that these 16000 values are all 0-255, so it's not like they're big integers or anything. It's also loading about 1000 values from DATA segments (ints and strings), but that time is so negligible, it doesn't even factor into the loading time. I'm not trying to advocate my Village game by the way, it's just a good example of the time it takes to load a bunch of crap from a large data "structure".

Edited on by randomous

randomous

damolii

Anyone know how to put wait and spanim together
@hairmanban19 I will finish the music for you.
@bluerobin2 formula did not work. Thx though

I don't have a 3DS so what do I put here? -Damolii

Gimmemorecoinz

Slow forum is slow. xD Is going to bed soon. Then I wont be online for atleast 20 hours.

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

mystman12

Is there a way to get simple whole answers from dividing? I'm trying to get the player's location, and divide it by 16, but I just want to know how many times 16 goes into the number and not the actual decimal answer.

I like makin' games!
Future Pinball games!
Petit Computer games!!
and SmileBASIC games!
Waiting for Kirby Air Ride 2. One day, it will come. One day...

3DS Friend Code: 0259-0292-5888 | Nintendo Network ID: mystman12 | Twitter:

randomous

Just use floor, it truncates (removes) the decimal:

FLOOR(X / Y)

For instance:

FLOOR(7 / 5) = 1, regular answer=1.4
FLOOR(12 / 5) = 2, regular answer=2.4
FLOOR(33 / 4) = 8, regular answer=8.25

randomous

Sniper101

What do DIM and DATA mean and how and why would you use them?

Sniper101

3DS Friend Code: 2208-4619-7423

randomous

@Sniper101 https://www.nintendolife.com/forums/dsiware/petit_computer?sta...

As for why you need either of those: DIM is really important because arrays are a basic element of programming. Without it, you'd have to uniquely name every single value ever, even if they are all part of the same thing (for instance, all the prices in a shop). DATA is not necessary at all, but it makes assigning static values to arrays easier. Instead of going:

MYARRAY(0)=5
MYARRAY(1)=4
...
MYARRAY(999)=67

You could just have a huge DATA chunk in your program and just read all the values in a loop, like in the example link.

Edited on by randomous

randomous

Gimmemorecoinz

okay I have an important question about how the == operator works inside of Petit computer. The question is, is if mid$(sentence$, T, 1)==" " the same as saying "if there's a space character at this point in the string" using mid$

I'm asking this because I need to get and seperate words from within a long string. I was experimenting with it while I was on the bus with my 3DS at one time not so long ago. The mid$ command seemed to return the wrong location within a for loop of all the spaces, where I have a call to a subroutine called gosub addspaces and a counter that is global and non static, which keeps track of what space in the sentence were at.

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Discostew

Gimmemorecoinz wrote:

okay I have an important question about how the == operator works inside of Petit computer. The question is, is if mid$(sentence$, T, 1)==" " the same as saying "if there's a space character at this point in the string" using mid$

I'm asking this because I need to get and seperate words from within a long string. I was experimenting with it while I was on the bus with my 3DS at one time not so long ago. The mid$ command seemed to return the wrong location within a for loop of all the spaces, where I have a call to a subroutine called gosub addspaces and a counter that is global and non static, which keeps track of what space in the sentence were at.

Are you taking into account that mid$ returns a number between 0 and StringLength-1 inclusive, or -1 if it does not find a match?

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

randomous

Gimmemorecoinz wrote:

okay I have an important question about how the == operator works inside of Petit computer. The question is, is if mid$(sentence$, T, 1)==" " the same as saying "if there's a space character at this point in the string" using mid$

I find it easier to use INSTR. It returns the position of the next occurrence of a character or sequence within a string. For instance:

INSTR("This is a sentence", " ")

The second argument is the sequence you're searching for within the first argument. In this example, INSTR would return a 4, since that is the first occurrence of the " " (space) character within the phrase "This is a sentence". For an example, there's a textwrap program that I made here:

https://www.nintendolife.com/forums/dsiware/petit_computer_tut...

Edited on by randomous

randomous

ramstrong

Gimmemorecoinz wrote:

okay I have an important question about how the == operator works inside of Petit computer. The question is, is if mid$(sentence$, T, 1)==" " the same as saying "if there's a space character at this point in the string" using mid$

I'm asking this because I need to get and seperate words from within a long string. I was experimenting with it while I was on the bus with my 3DS at one time not so long ago. The mid$ command seemed to return the wrong location within a for loop of all the spaces, where I have a call to a subroutine called gosub addspaces and a counter that is global and non static, which keeps track of what space in the sentence were at.

Parsing is actually a very complicated subject. But if all you want is splitting words, that can be easily done with WordCount algo.

TEXT$="HAPPY FAMILIES ARE ALL ALIKE. "
TEXT$=TEXT$+"UNHAPPY FAMILIES ARE EACH UNHAPPY IN THEIR OWN WAY. "
CLS:N=0:STATE=0
?TEXT$
FOR I=0 TO LEN(TEXT$)-1
CTEXT$=MID$(TEXT$,I,1)
IF CTEXT$!=" " AND STATE==0 THEN STATE=1:W1=I:'START WORD
IF CTEXT$==" " AND STATE=1 THEN STATE=0:W2=I:GOSUB@ACT:'ENDWORD
NEXT
END

@ACT
?N,W1;"-";W2;": ",MID$(TEXT$,W1,W2-W1)
N=N+1
RETURN

Petit Computer Journal
Old site http://ramstrong.blogspot.com

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

Gimmemorecoinz

Discostew wrote:

Gimmemorecoinz wrote:

okay I have an important question about how the == operator works inside of Petit computer. The question is, is if mid$(sentence$, T, 1)==" " the same as saying "if there's a space character at this point in the string" using mid$

I'm asking this because I need to get and seperate words from within a long string. I was experimenting with it while I was on the bus with my 3DS at one time not so long ago. The mid$ command seemed to return the wrong location within a for loop of all the spaces, where I have a call to a subroutine called gosub addspaces and a counter that is global and non static, which keeps track of what space in the sentence were at.

Are you taking into account that mid$ returns a number between 0 and StringLength-1 inclusive, or -1 if it does not find a match?

I thought mid$ returned a true string.

Ie:
Split_this$="hello this is a string test"

first$=mid$(Split_this$, 0, 5)

first$ should now equal hello.
what i want to do is create an array, that's bigger than the amount of strings I'll possibly find within user input, then store each word inside one of those array indices. using a counting trick.

Then .. I want to search through the words in the specific order they were found, and then do another pass, using a different script, checking for different symbols and meanings.
like basically.. it's easy in another language I use called playbasic which has a splittoarrayfunction
It splits an entire array into tokens based on an identifier , the first starting point of the index and the arrayname.
It uses the array to store whatever it finds seperated by any delimiter character/s of your choice.
mm.. so essentially it's like saying "foundwords$(55)="this is a long sentence about a post that I'm making. I think that it might not be fully understood by some people because I fail at explaining some of these things.. but I think that's okay too because I'm glad I'm still getting some help on here"

basically...
each of those words would be stored within one of the indexes of the same array and the splittoarray function also returns the amount of tokens it found which you can use, so you dont get blank array entries or out of range errors.

All I'm trying to do is find a way to accomplish the same task in petit computer, in short.
Any help is appreciated. I'm not actually trying to store the location of the words I want to store a list of all the words found in the same order they were found in an entirely seperate array and retrieve the amount of words found from a function that does this. I don't find it that hard but I had no idea mid$ only returned a boolean ?? o.0

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Pixelrobin

I need idea for new game. Toyed with drawing houses and stuff in a field. Any ideas from that? I was thinking a minecraft redstone simulator.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

Gimmemorecoinz

Bluerobin2 wrote:

I need idea for new game. Toyed with drawing houses and stuff in a field. Any ideas from that? I was thinking a minecraft redstone simulator.

how about a card battle game?

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Pixelrobin

@mystman12 I looked over it, and I might make something similar thanks!

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

damolii

Good news guys!! Almost finished my minecraft music pack!!! I'm a bit behind on my actual game coding though. Cannot figure out what I am doing wrong It will be nice when it is finished though

I don't have a 3DS so what do I put here? -Damolii

Pixelrobin

What happens when you save two programs with the same name to the SD card?

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

randomous

@Gimmemorecoinz I guess you didn't see my previous post (or didn't want to read it). That's fine, I figured I'd just post the code directly instead of linking you to the program that does exactly what you want to do. Here's the code:

DIM WORDS$(100)
I=0

PHRASE$="Words are nice man."

@LOOP
POS=INSTR(PHRASE$," ")
IF POS==-1 GOTO @END
WORDS$(I)=LEFT$(PHRASE$,POS)
I=I+1
PHRASE$=RIGHT$(PHRASE$,LEN(PHRASE$)-POS-1)
GOTO @LOOP

@END

IF LEN(PHRASE$) THEN WORDS$(I)=PHRASE$:I=I+1

Now, WORDS$ contains the various words that were in the string (in the order they were found). I is the number of words you found. The delimiter is only space, but you can change it to whatever you want. PHRASE$ is the string we're parsing. Basically what happens is: POS stores the location of the next space within the PHRASE$. It is -1 if there are no more spaces, so we jump out of the loop (GOTO @END). Then, we extract the word from the phrase using the LEFT$ command and store it into our array WORDS$. LEFT$ says take the number of letters from the left of the word (POS) and return them. Then we increment I to show that we found a word. The next line uses RIGHT$ to take a certain number of letters off from the right (in string order though) and return them. What I'm basically doing "removing" the word from the PHRASE$ by only retrieving the characters that are to the RIGHT$ of the word. Then we loop. At the end, if we don't have a space as the last character, we'll have a bit of stuff left over in phrase. It's the last word, so just get it. This is the "simple" way to do it, but I would suggest doing it character by character instead of word by word. If you do it character by character, it's easier to specify multiple delimiters and to throw out unwanted characters (such as periods).

randomous

Please login or sign up to reply to this topic