Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

JB007

9
Posts
4
Topics
A member registered Apr 18, 2020

Recent community posts

(3 edits)

Cosmo,

Would you kindly test this for me? --> VarsTest

It is a simple test program with a this.XXX_VAR in a script, room, and copy.
Just to see what access results come from where.

My console log reports the following showing that copy does not read the room or script variable, and room does not read the script variable.

from script1 -> script1 value -> 123
from copy1 -> room1 value -> undefined
from copy1 -> script1 value -> undefined
from room1 -> room1 value -> TestValue
from room1 -> script1 value -> undefined

(1 edit)

Hello Cosmo,
Does not seem to work for me. Here is a simple bit of test code. I have one room and one copy placed into it via the editor.
The COPY1 copy is not reading the value of ROOM_VAR.

ROOM1  (Code in CREATE)

this.ROOM_VAR="TestValue";
console.log("from room -> " + this.ROOM_VAR);

COPY1  (Code in CREATE) 

console.log("reading room value -> " + ct.room.ROOM_VAR);

The console log results when code is run:

reading room value -> undefined
 from room -> TestValue

So, it seems to me the COPY1 is created first, then the ROOM1, according to the order of the console log.
This would contradict the ct documents:

  1. room's oncreate event, which is emitted when a user starts a game or navigates to a new room;
  2. oncreate is applied for each copy;
  3.  ...


I am running the Linux version 1.21 64 bit if it helps.

(1 edit)

I just can't figure out how to get a value from a set constant or variable between rooms and copies, or copies to other copies. Does not matter what I try the results are always undefined values.

ROOM (within Create)

CONST X_OFFS=123;

THE COPY (within Create)

this.x=ct.room.X_OFFS+64 // <-- Does not work. Undefined

Even if I make CONST X_OFFS into this.X_OFFS the copy still does not pick up the value.

Can anyone make any sense please how best to share fixed constants between:

ROOM <> COPY

COPY <> ANOTHER_COPY

(1 edit)

Hi fellow devs,

I have gone around in circles trying to figure out how to access a function from another copy, and I either always get 'cannot access x from undefined' or 'x is not a function'

For example (Pseudo code) - Here I would like to call GetPiece function  that is another copy.

copy > Piece code =======================================================

var board=ct.types.list["Board"];

var p=board.GetPiece(3,4); // get the peice stored at position 3,4

copy> Board code =======================================================

function GetPiece(x,y){

    return x*y;             // pseudo example

}


I have tried putting the function in Create and OnStep but not joy.

Great to read that you are running with this suggestion. Perhaps extend this idea to the importing of sounds too? That is, have the option to use their file name (without extension).

Thank you Cosmo for the explanation.

I have a thought which immediately occurred to me when creating types. At the moment you create a new type, then pick a texture, followed by renaming the type.

Typically you might just want to use the same name as the texture (as per the tutorials), so a handy option could be to have a little button under the type name box which says, [Use textures name].

While following the Spacer shooter tutorial the IDE does not seem to know the  setTimeout() function. This function has a squiggly underlline and hovering over reveals:

Cannot find name ' setTimeout'

SNIPPET OF CODE:

 if (ct.room.lives <= 0) {
        this.kill = true;
        setTimeout(function() {
            ct.rooms.switch('Main');
        }, 1000);
    }

Although the game complies and plays without issue. I downloaded the current version 2 days ago as a Linux 64 bit release.