Nilom's Forum Posts

  • You do not have permission to view this post

  • You can create a text object and set its text to JSON.Get(".yourstringlocation").

  • Not sure if I understood what you want.

    Do you save Ajax.lastdata inside the JSON? Normally you would catch a response with Ajax and not with JSON.

    For "ignoring part of a string" you could use tokenat().

  • My first guess would be to use functions for this.

  • Thanks. That's a good starting point!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey there!

    I just wanted to know:

    How many kb/s (kilobytes per second) do you think are reasonable in a real time multiplayer game of around 8-10 people?

    I would like to know that per peer and then for the host.

    Currently I have one moving object per player and tested it with 7 players (1 host, 6 peers) and the host has about ~9-12 kb/s up.

    And there are still many movable objects missing.

  • Not really sure exactly how you plan to save and load all the data

    I will save to and load them from Mongodb using the Realm Web SDK.

    Depending on your needs you might be able to get away with something easier though.

    If your data objects don't have nested properties (properties which are objects or arrays with more data in them), you can rather easily use Object.assing to create a new object with the properties from a list objects.

    I think I will need nested objects. One of the templates could look like this:

    {
    	templates: {
    		"weapons": {
    			"background_color": "100,0,0",
    			"name": {
    				"x": 25,
    				"y": 5,
    				"font_size": 16,
    				"font_style": "bold"
    			},
    			"picture": {
    				"x": 5,
    				"y": 20,
    				"width": 50,
    				"height": 50
    			},
    			"text": {
    				"x": 10,
    				"y": 100,
    				"font_size": 10,
    			}
    		}
    	}
    }

    I do not know beforehand how many of these properties a template will have because the player can insert more than one text or more pictures in the items.

    Using this approach you can allow the player to select a base item, then a specific one, merge them and the result becomes the new item.

    This sounds like what I'm trying to do. Too bad .assign doesn't work with nested objects. It looks clean and simple without 2 huge code blocks just to link an object to another one.

    Thank you again for the example! I looked into classes. They seem to be almost the same thing as Prototypes. Maybe better readable.

    Now I wonder if I'm overcomplicating things and if I really need this. Or if I should just store the templates as a JSON in a document inside Mongodb and just create all the text objects, sprites etc. from the selected template and then just let the player be able to edit from there.

  • DiegoM Many thanks for the detailed reply! Your way of organizing the common properties and classes looks way better.

    I'm not sure if deep merge is what I wanted to do. Basically I do not know how I can set an object to have a prototype to lookup for default values.

    This is what I meant. There are many different ways listed and I'm not sure which one to choose.

    An important detail that I forgot to mention is that I need to be able to manipulate the objects prototypes at runtime.

    Explanation:

    The player will be able to create new items and he can create them from templates that he created beforehand.

    For example let's say he creates a new item called Allmighty Wizard Staff. Because he already created a template staff before he now defines that the Allmighty Wizard Staff uses this template. So when he creates 30 more staffs he doesn't need to define all the default values again.

    Now I want the app to be able to set the Allmighty Wizard Staffs prototype to staff.

    WackyToaster Could this be achieved with classes?

    Or does this mean that I should use Object.setPrototypeOf()?

    Thanks for helping me!

  • Hello there!

    I wonder how objects can inherit/copy other objects keys/values.

    I watched some videos and read through some explanation pages about prototypes, constructors and stuff, but found it a bit confusing.

    Some of them say don't do that. Don't use this. Since ES6 this is obsolete. This is old. Even though you can still do this, you should do that instead etc. etc. .

    Maybe someone can explain this to me how it can be done before I spend another 5 hours finding the up-to-datest or best way to inherit one objects properties into another ones.

    What I'm trying to do is as follows: I want to have objects that are "templates" for other objects.

    Let's have an example. An RPG.

    There could be a template with the key weapons, one with the key armors, spells and one with the key items.

    This are just fantasy values but the JSON could look like this:

    {
    	"templates": {
    		"rarities": {
    			"colors": {
    				"common": "80,80,80",
    				"rare": "0,0,80",
    				"epic": "90,0,80"
    			}
    		},
    		"weapons": {
    			"color": "100,0,0",
    			"name": {
    				"x": 25,
    				"y": 5,
    				"font_size": 16,
    				"font_style": "bold"
    			},
    			"text": {
    				"x": 10,
    				"y": 50,
    				"font_size": 12,
    				"font_style": ""
    			},
    			"picture": {
    				"x": 0,
    				"y": 20,
    				"width": 50,
    				"height": 50
    			},
    			"attack": {
    				"x": 40,
    				"y": 5,
    				"font_size": 18,
    				"font_style": "bold",
    				"icon": "sword"
    			}
    		},
    		"spells": {
    			"color": "0,0,100",
    			"name": {
    				"x": 25,
    				"y": 5,
    				"font_size": 16,
    				"font_style": "bold"
    			},
    			"text": {
    				"x": 10,
    				"y": 120,
    				"font_size": 12,
    				"font_style": "italic"
    			},
    			"picture": {
    				"x": 0,
    				"y": 20,
    				"width": 50,
    				"height": 100
    			},
    			"cost": {
    				"x": 40,
    				"y": 5,
    				"font_size": 18,
    				"font_style": "bold",
    				"icon": "mana"
    			}
    		}
    	}
    }

    Now if I create new weapons in the JSON I do not want to always define where the x and y positions of the weapons name should be or where it's picture should be etc. .

    {
    	"items": {
    		"weapons": {
    			"1": {
    				"name": "Axe",
    				"text": "Great for cutting trees.",
    				"attack": 5,
    				"rarity": "common"
    			},
    			"2": {
    				"name": "Rusty Sword",
    				"text": "Not a great sword at all.",
    				"attack": 7,
    				"rarity": "common"
    			},
    			"3": {
    				"name": "Rusty Greatsword",
    				"text": "A greatsword which is not a great sword either.",
    				"attack": 10,
    				"rarity": "common"
    			}
    		}
    	}
    }
    

    1) How can I inherit the templates properties? Is there a way how I can have all of the entries under the key "weapons" have the properties of the weapons template or do I have to "link" the weapon template to each of the weapons individually?

    Oh and bonus question:

    2) Should I instead of an ID as the key name use the weapons name as the key name? Or an array?

    {
    	"weapons":{
    		"Axe": {
    			"text": "Great for cutting trees.",
    			"attack": 5,
    			"rarity": "common"
    		},
    		"Rusty Sword": {
    			"text": "Not a great sword at all.",
    			"attack": 7,
    			"rarity": "common"
    		},
    		"Rusty Greatsword": {
    			"text": "A greatsword which is not a great sword either.",
    			"attack": 10,
    			"rarity": "common"	
    		}
    	}
    }
    

    Thanks for reading and thank you for explaining it to me. :D

  • Good idea.

  • lennaert

    Thank you for this different point of view. I think this makes the most sense to me now.

    I like to safe time on edits and modifications. I do a lot of edits because I am kind of a of perfectionist.

    I will do that as follows:

    Host group:

    • Authoritarian events

    Peer group:

    • "Streamed" events

    (Semi) common group:

    • Events that share the same logic but behave differently for host and peers
  • Okay what you say makes sense.

    I will strictly separate the events because if I have a bug one day that might allow people to cheat or mess up everything.

  • Hey there!

    I wonder which of these schemas I should use:

    1)

    • Have a group for all events that are host only
    • Have a group for all events that are peer only
    • And have a group for all common events which are exactly the same

    2)

    • Have a group for all events that are host only
    • Have a group for all events that are peer only
    • And have a group for all common events which are mostly the same and just use is host or is peer for the adaptions

    Example for 2):

    On peer message
    		ChatAppend("[" & Multiplayer.FromAlias & "]: " & Multiplayer.Message)
    	Is host
    		Broadcast message to other peers
    

    Should I strictly separate host events and peer events or should I save on the amount of events needed?

    How do/would you do it?

    Thank you in advance!

  • You can define global variables in the main.js script inside runOnStartup to have it run before the layout.

  • Okay I will discard this idea and just use different JSON objects.