"Create new object" issue

I'm kind of new, and I'm creating a somewhat complicated game. I want the player to combine two objects to create a new object that they will need to use later on, but every time I try to combine them in my test runs, it says "Error running script: Error compiling expression '': SyntaxError: Unexpected end of fileLine: 1, Column: 1"
I'm very confused because the "create new object" script has two parts, one being the name of what you want to create, the other being type, which it says is optional. I've tried filling the type line in, but it just gives another error message.
I have no idea what's wrong. What do I need to do to stop the error message?


the second parameter/argument for the 'create' Function/Script refers to giving it an 'Object Type / Type'.

http://docs.textadventures.co.uk/quest/scripts/create.html

create (argument/parameter 1)
create (NAME/ID_OF_YOUR_NEW_OBJECT)
~OR~
create (argument/parameter 1, argument/parameter 2)
create (NAME/ID_OF_YOUR_NEW_OBJECT, OBJECT_TYPE/TYPE_FOR_YOUR_NEW_OBJECT)


explaining Object Type / Type is a bit difficult as it's a bit more advanced concept if you're new to coding...

http://docs.textadventures.co.uk/quest/elements/type.html
http://docs.textadventures.co.uk/quest/types.html
http://docs.textadventures.co.uk/quest/tutorial/using_inherited_types.html

you can find/create Object Types / Types through the GUI~Editor, here:

left side/pane's "tree of stuff" :
Advanced -> Object Types -> (set it up)

Object Types / Types in quest are its 'groups / user-level classes'.

an Object Type / Type, holds/contains: Attributes, and other Object Types / Types (inheritance) through 'Inherited' Attributes

so, what is an Object Type / Type ???

the best way to explain it, is by showing it (in code, sorry but it's quick):

instead of doing this (YUCK! UGH!):

// npc 1-5 are all similar to each other (only their 'alias' String Attribute is different and of course their name/ID Attributes must be different/unique):

<object name="npc1">
  <attr name="alias" type="string">Joe</attr>
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</object>

<object name="npc2">
  <attr name="alias" type="string">John</attr>
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</object>

<object name="npc3">
  <attr name="alias" type="string">Jim</attr>
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</object>

<object name="npc4">
  <attr name="alias" type="string">Jeff</attr>
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</object>

<object name="npc5">
  <attr name="alias" type="string">James</attr>
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</object>

we can do this (much better!):

// npc 1-5 are all similar to each other (npc1_type):

(only their 'alias' String Attribute is different and of course their name/ID Attributes must be different/unique)

<object name="npc1">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">Joe</attr>
</object>

<object name="npc2">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">John</attr>
</object>

<object name="npc3">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">Jim</attr>
</object>

<object name="npc4">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">Jeff</attr>
</object>

<object name="npc5">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">James</attr>
</object>

<type name="npc1_type"
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</type>

and we can go further with it (having more/multiple groups/types/classes of npcs):

// npc 1-5 are all similar to each other (npc1_type)
// npc 21-25 are all similiar to each other (npc2_type)

<object name="npc1">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">Joe</attr>
</object>

<object name="npc2">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">John</attr>
</object>

<object name="npc3">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">Jim</attr>
</object>

<object name="npc4">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">Jeff</attr>
</object>

<object name="npc5">
  <inherit name="npc1_type" />
  <attr name="alias" type="string">James</attr>
</object>

<object name="npc21">
  <inherit name="npc2_type" />
  <attr name="alias" type="string">Mike</attr>
</object>

<object name="npc22">
  <inherit name="npc2_type" />
  <attr name="alias" type="string">Matt</attr>
</object>

<object name="npc23">
  <inherit name="npc2_type" />
  <attr name="alias" type="string">Mark</attr>
</object>

<object name="npc24">
  <inherit name="npc2_type" />
  <attr name="alias" type="string">Moe</attr>
</object>

<object name="npc25">
  <inherit name="npc2_type" />
  <attr name="alias" type="string">Mordred</attr>
</object>

<type name="npc1_type"
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">light</attr>
  <attr name="iris_color" type="string">light blue</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">yellow</attr>
  <attr name="hair_type" type="string">straight</attr>
  // etc etc etc Attributes
</type>

<type name="npc2_type"
  <attr name="sex" type="string">male</attr>
  <attr name="species" type="string">human</attr>
  <attr name="race" type="string">european</attr>
  <attr name="skin_type" type="string">skin</attr>
  <attr name="skin_color" type="string">olive</attr>
  <attr name="iris_color" type="string">green</attr>
  <attr name="eye_color" type="string">white</attr>
  <attr name="pupil_color" type="string">black</attr>
  <attr name="hair_color" type="string">brown</attr>
  <attr name="hair_type" type="string">curly</attr>
  // etc etc etc Attributes
</type>

so for examples, we could do:

create (npc6, npc1_type)
create (npc26, npc2_type)
create (npc31, npc3_type) // pretend we created a 3rd Object Type / Type


think of an Object Type / Type, as like a basket of many eggs (Attributes), which we can give to our Objects (instead of giving each Attribute individually 1 at a time, we give the basket, so they get all of those 'eggs':Attributes in the basket:Object Type/Type)

think of it this way:

I can give you 100 $1 bills for a total of $100 dollars
or
I can give you a bag with 100 $1 bills in it

we both would rather use the bag method for the exhange, as both of us wouldn't want to wait to exchange 100 $1 bills individually 1 at a time.


an Object Type / Type is a quick way to give many same Attributes to many Objects.

(an even quicker way, is for having scripting do it for you: having the computer/quest to do it for you... but let's not go there yet)


Hello I'm pretty new when it comes to a lot with quest but I am making a crafting game and i make the actual object and store it in a room that has no use nor exits(Works like a folder). Then make a command or call a function that if player has object1 in inventory and if player has object2 in inventory , then move object3 to inventory or room. And if you want object1 and object2 to be removed from inventory just move each item to that unused room/folder :)
Hope I explained it well enough for you to understand. I am also making a basic survival series that go over a lot of basics (not the best by any means) but codes do work and start beginners like myself off. Here is the link https://m.youtube.com/watch?v=-WNRvCpw3qo here I just babble on about what I'll be going over. Anyway ever want to talk quest just pm me.

Mike


oh ya, about combining objects (thanks for reminding me onimike):

as onimike said/implied, there's no actual way to combine Objects.

you can create the effect, by using some checking of/for those two specfiic Objects (or even just Attributes and their Values - you don't need to actually use the physical Objects to do simple stuff, anyways), and then if he checking is met, providing a 3rd Object as the so-called "combined" Object (and if need be, hiding/moving/removing the two other Objects or adjusting the 2 Attributes' Values).


you got to start thinking about the concept of illusion:

tkae for example: buying/selling

// the only Object we're going to move, is the bought/sold Object, there's no 'gold/silver coin' Objects at all

// Buying:

sword.parent = shop_owner // the shop owner has the sword, which you want to buy from him

if (player.cash >= sword.price) { // if true, you have enough cash, and thus you buy the sword
  player.cash = player.cash - sword.price // you pay for the sword (you lose X cash, which is equal to the price of the sword)
  shop_owner.cash = shop_owner.cash + sword.price // you pay for the sword (the shop owner gains X cash, which is equal to the price of the sword)
  sword.parent = player // you now have the sword
} else {
  msg ("Sorry, but this sword isn't free, come back when you got enough cash for it.")
}

the 'cash' Attribute's Values for you and the shop owner, was adjusted, no actual 'silver/gold coins or cash' Objects being moved around, only the 'sword' Object was moved from shop owner to you.

// Selling:

sword.parent = player

if (shop_owner.cash >= sword.price / 2) { // you only get to sell it back for only half its price, lol
  shop_owner.cash = shop_owner.cash - sword.price / 2
  player.cash = player.cash + sword.price / 2
  sword.parent = shop_owner
} else {
  msg ("Unfortunately, the shop owner doesn't have enough cash to buy it back off of you.")
}

think about using Attributes, and adjusting/manipulating their values, to give the illusion of doing things.

with that said, Objects are extremely useful, though that full potential of usefulness is for much more advanced programming...

if you don't need Objects, than use Attributes and just adjust/manipulate their Values.


Thank you so much, this really helps!


if you want to see more/better examples of using Object Types / Types:

(warning: I like to be descriptive in my labels/names and love using underscores and hate using upper case, for my convention/system for labeling/naming things. You can label/name however you want, the below is just my own personal convention/system for labeling/naming)

(see below: this is why scripting is best.... laughs... too much coding/typing to be doing it manually... even if Object Types do help a bit with the amount of work compared to not using them --- EEK!, it's still a lot of manual work. Scripting is best, as the computer/quest does it for you, hehe. Sorry, but there's no law, saying computers can't be our slaves, wink --- at least not yet... lol. Whoa... that's an interesting concept... if computers, get rights, then human programming of computers comes to a DEAD STOP... lol. Never realized that!)

<type name="character_type">
  <attr name="level" type="int">1</attr>
  <attr name="experience" type="int">0</attr>
  <attr name="cash" type="int">0</attr>
  <attr name="life_display_string_attribute" type="string">1/1</attr>
  <attr name="current_life_integer_attribute" type="int">1</attr>
  <attr name="maximum_life_integer_attribute" type="int">1</attr>
  <attr name="mana_display_string_attribute" type="string">0/0</attr>
  <attr name="current_mana_integer_attribute" type="int">0</attr>
  <attr name="maximum_mana_integer_attribute" type="int">0</attr>
  <attr name="condition_string_attribute" type="string">normal</attr>
  <attr name="damage_integer_attribute" type="int">1</attr>
  <attr name="strength_integer_attribute" type="int">0</attr>
  <attr name="endurance_integer_attribute" type="int">0</attr>
  <attr name="dexterity_integer_attribute" type="int">0</attr>
  <attr name="agility_integer_attribute" type="int">0</attr>
  <attr name="speed_integer_attribute" type="int">0</attr>
  <attr name="luck_integer_attribute" type="int">0</attr>
  <attr name="piety_integer_attribute" type="int">0</attr>
  <attr name="intelligence_integer_attribute" type="int">0</attr>
  <attr name="spirituality_integer_attribute" type="int">0</attr>
  <attr name="mentality_integer_attribute" type="int">0</attr>
  <attr name="leadership_integer_attribute" type="int">0</attr>
  <attr name="charisma_integer_attribute" type="int">0</attr>
  <attr name="alignment_integer_attribute" type="int">0</attr>
  <attr name="personality_integer_attribute" type="int">0</attr>
  <attr name="perception_integer_attribute" type="int">0</attr>
  <attr name="deception_integer_attribute" type="int">0</attr>
  <attr name="creativity_integer_attribute" type="int">0</attr>
  <attr name="changedcurrent_life_integer_attribute" type="script"><![CDATA[
    if (this.current_life_integer_attribute > this.maximum_life_integer_attribute) {
      this.current_life_integer_attribute = this.maximum_life_integer_attribute
    } else if (this.current_life_integer_attribute < 0) {
      this.current_life_integer_attribute = 0
    }
    if (this.current_life_integer_attribute = 0) {
      this.condition_string_attribute = "dead"
    }
    this.life_display_string_attribute = this.current_life_integer_attribute + "/" + this.maximum_life_integer_attribute
  ]]></attr>
  <attr name="changedmaximum_life_integer_attribute" type="script"><![CDATA[
    if (this.current_life_integer_attribute > this.maximum_life_integer_attribute) {
      this.current_life_integer_attribute = this.maximum_life_integer_attribute
    }
    this.life_display_string_attribute = this.current_life_integer_attribute + "/" + this.maximum_life_integer_attribute
  ]]></attr>
  <attr name="changedcurrent_mana_integer_attribute" type="script"><![CDATA[
    if (this.current_mana_integer_attribute > this.maximum_mana_integer_attribute) {
      this.current_mana_integer_attribute = this.maximum_mana_integer_attribute
    } else if (this.current_mana_integer_attribute < 0) {
      this.current_mana_integer_attribute = 0
    }
    this.mana_display_string_attribute = this.current_mana_integer_attribute + "/" + this.maximum_mana_integer_attribute
  ]]></attr>
  <attr name="changedmaximum_mana_integer_attribute" type="script"><![CDATA[
    if (this.current_mana_integer_attribute > this.maximum_mana_integer_attribute) {
      this.current_mana_integer_attribute = this.maximum_mana_integer_attribute
    }
    this.mana_display_string_attribute = this.current_mana_integer_attribute + "/" + this.maximum_mana_integer_attribute
  ]]></attr>
</type>

<type name="player_type">
  <attr name="changedcondition_string_attribute" type="script">
    if (this.condition_string_attribute = "dead") {
      msg ("GAME OVER")
      finish
    }
  </attr>
</type>

<type name="npc_type">
</type>

<type name="human_type">
</type>

<type name="elf_type">
</type>

<type name="orc_type">
</type>

<type name="animal_type">
</type>

<type name="equipment_type">
  <attr name="price_integer_attribute" type="int">0</attr>
  <attr name="weight_integer_attribute" type="int">1</attr>
  <attr name="durability_integer_attribute" type="int">100</attr>
  <attr name="quantity_integer_attribute" type="int">1</attr>
  <attr name="equip" type="script">
  </attr>
  <attr name="unequip" type="script">
  </attr>
</type>

<type name="weapon_type">
  <attr name="damage_integer_attribute" type="int">1</attr>
  <attr name="reach_integer_attribute" type="int">1</attr>
  <attr name="quickness_integer_attribute" type="int">1</attr>
</type>

<type name="one_handed_type">
  <attr name="body_stringlist_attribute" type="simplestringlist">right_hand</attr>
</type>

<type name="two_handed_type">
  <attr name="body_stringlist_attribute" type="simplestringlist">right_hand;left_hand</attr>
</type>

<type name="sword_type">
</type>

<type name="katana_type">
</type>

<type name="claymore_type">
</type>

<type name="armor_type">
  <attr name="defense_integer_attribute" type="int">0</attr>
</type>

<type name="shield_type">
   <attr name="body_stringlist_attribute" type="simplestringlist">left_hand</attr>
</type>

<type name="melee_type">
</type>

<type name="ranged_type">
</type>

hopefully you kinda get the idea... (way too much work to fill in all the Attributes, so that's why lots of Object Types are empty of Attributes, lol), and I didn't show any Object Types within Object Types (inheritance/nesting/layers), as that's more work too, and I think it generally works a bit better to not have them inside of other Object Types... meh


here's a quick example:

<object name="masamune_1_object">
  <inherit name="equipment_type" />
  <inherit name="weapon_type" />
  <inherit name="melee_type" />
  <inherit name="one_handed_type" />
  <inherit name="katana_type" />

  <attr name="alias" type="string">masamune</attr>
  
  // this (below) will over-ride the 'damage_integer_attribute' Attribute and its Value of '1' from the 'weapon_type' Inherited Attribute (Object Type / Type):

  <attr name="damage_integer_attribute" type="int">50</attr>

  // (so, this 'masamune_1_object' Object will do 50 damage, not 1 damage)

</object>

P.S.

there's also XanMag's 'tutorials and templates' ("tutorial 2") demo game, which you can play/study:

http://textadventures.co.uk/forum/games/topic/5940/quest-tutorials-and-templates-published

(I've not got around to trying it, but I think generally each different room you can go to is a different lesson for how to do stuff / how to make/do stuff for your own game making)

as there's a big gap between the quest tutorial and trying to make a game on your own. XanMag tries to help bridge that gap with this demo game of his for people new to quest.


I think I understand... so you make the object types based on attributes you want the object to have? Or am I completely lost now?


Yes you're correct, so let say you have food lets say a apple, pear, can food, etc. and you want these all to have health(INT), hunger(INT) and IsOld(BOOL) as attributes. Lets say you have many different foods but want them all to have those same attributes, so make a 'Object Type' calling it "Food Data" (Remember Objects and Object Types are different and can be found in tab under Advanced) Well in out Object Type Food Data we can add these 3 attributes to it. Then go to each of our objects click the 'Attributes' Tab and then under "Inherited Types" click Add button and find our object type 'Food Data'. Now under Attributes directly under Inherited Types you will see the attributes from Food Data, Health, Hunger, IsOld and can change these for each food you add it to.

Makes get for weapons, foods, npc stats and other things you are making multiple of and don't want to make 1000 of the same attributes for each item or if any experience with any other coding usually called Variables.


Thank you! That makes so much sense!


I'm confused again. Where do I go to create the object type? onimike said objects and object types are under the advanced tab but I don't believe I have that tab and if I do then I haven't found it.


I've decided to ditch the "create object" idea and use an empty room for storage and switch the objects out when the player combines them (as onimike suggested earlier). Thank you for your help!


you don't have to use/have Object Types to create Objects and give them Attributes:

create ("potion")
potion.type_string_attribute = "life potion"

the, potion.type_string_attribute = "life potion", in code, is achieved this way with the GUI~Editor:

run as script -> add new script -> 'Objects' section/category -> 'Create Object' Script -> Name: potion

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable potion.type_string_attribute = [EXPRESSION] "life_potion"

Object Types:

to create an Object Type:

on the left side is the 'tree of stuff', the bottom of it is 'Advanced'. click on 'advanced' to see the stuff inside of it, one of those things is 'Object Types', click on 'Object Types' and choose to 'add' an Object Type.

Object Type Name: whatever

than, find the Object Type you created (you may need to click on it in the "tree of stuff" if it's not a window already with the ability to add your attributes) and add your Attributes to it.


Adding/attaching the Object Type to 'whatever' Object(s):

left side's tree of stuff -> click on the Object you want to add your Object Type to, and click on that Object's 'Attribute' Tab, then find the 'Inherited' Attribute box in the middle, and click on the 'add' button for it, and just type in the name of your Object Type (or select it from the drop down menu if there is one and if its on it). Now, that Object has that Object Type, and thus that Object has all of that Object Type's Attributes, too. repeat for any other Objects you also want to have this Object Type and its Attributes for it.


When in editor mode on the left hierarchy where all your tabs are like Rooms,Functions, Timers,Game,Object, etc. at very bottom of list is a Advanced Tab with a + next to it. Click the + and it opens up all extra things like Library,Object Types, Templates etc. Now you can click Object Type button which open a new main panel which will say Object Types at top, then directly under that there is a '+Add' button, click add then name it, now add attributes.

https://postimg.org/image/4m71ciwu5/

Not sure if I mentioned it here but I am making basic tutorials on using Quest, I am by no means near as good as hegemonkhan as I deal with basically the editor if interested heres link to channel https://www.youtube.com/channel/UCGSCL0CED0oIG8J1mKyDoMw

Hope it helps
Mike


Looking where you both said, I have no "Advanced" button. If you both have Quest downloaded onto your computers, that may be the issue because I haven't downloaded it and am using the internet version. If that is not the case then I have no clue where the button is.


Oh yeah I suggest downloading it, works better, faster and has more options.


Duly noted. Thank you!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums