~Advanced Scripting and Editor Help
- Mysterious
- Posts: 226
- Joined: Wed Nov 06, 2013 8:31 am
Re: ~Advanced Scripting and Editor Help
Now this is where Akroma takes over and blows us all away - Rem his last Mod?
Re: ~Advanced Scripting and Editor Help
Hey Snowy, I really need your help.
I started to look in to scripting yesterday and I have managed to do some activation of torches, text particles et cetera.
I've read the information on the Modding section but I have my first real road block, and google didnt help me this time.
I am trying to get an alcove to spawn a water flask (the water is just a test)
I created a script like this
function addWater()
mine_alcove_3.surface:addItem(water_flask_1.item)
end
and as you probably already know, I get this result
function addWater()
mine_alcove_3.surface:addItem(water_flask_1.item) <- Attempt to index global "water_flask_1" (a nil value) x
end
I assume that when the script is trying to create the water flask, it can't find it, cause I haven't indexed it.
I also assume that I should use the "define object" function in a global script that I have somewhere on the level, but I have no clue how to do that.
I would really appreciate some help, because this would open up the world to me. Once I know how to summon objects I can start to do all kind of cool puzzles. (After I learned how to check a surface for a certain object, the puzzles will get even cooler)
Thanks in advance, mate.
regards
Daniel
I started to look in to scripting yesterday and I have managed to do some activation of torches, text particles et cetera.
I've read the information on the Modding section but I have my first real road block, and google didnt help me this time.
I am trying to get an alcove to spawn a water flask (the water is just a test)
I created a script like this
function addWater()
mine_alcove_3.surface:addItem(water_flask_1.item)
end
and as you probably already know, I get this result
function addWater()
mine_alcove_3.surface:addItem(water_flask_1.item) <- Attempt to index global "water_flask_1" (a nil value) x
end
I assume that when the script is trying to create the water flask, it can't find it, cause I haven't indexed it.
I also assume that I should use the "define object" function in a global script that I have somewhere on the level, but I have no clue how to do that.
I would really appreciate some help, because this would open up the world to me. Once I know how to summon objects I can start to do all kind of cool puzzles. (After I learned how to check a surface for a certain object, the puzzles will get even cooler)
Thanks in advance, mate.
regards
Daniel
- Mysterious
- Posts: 226
- Joined: Wed Nov 06, 2013 8:31 am
Re: ~Advanced Scripting and Editor Help
Yo bro yeah water_flask_1 is not defined so do this:
errr I hope imam right on this yeah
Code: Select all
function addWater()
mine_alcove_3.surface:addItem(water_flask.item)
end
Re: ~Advanced Scripting and Editor Help
Mysterious wrote:Yo bro yeah water_flask_1 is not defined so do this:
errr I hope imam right on this yeahCode: Select all
function addWater() mine_alcove_3.surface:addItem(water_flask.item) end
I don't understand. That's exactly what I did, which didnt work cause the water_flask isnt defined.
Or am I missing something ?
Regards
Daniel
Re: ~Advanced Scripting and Editor Help
How do you code a working mimic in its 'dormant' state, in a set location with loot?
One that you try to open only to stick your head into its mouth and have it get up an attack
One that you try to open only to stick your head into its mouth and have it get up an attack
Re: ~Advanced Scripting and Editor Help
use " ", such as "water_flask"
Finished Dungeons - complete mods to play
Re: ~Advanced Scripting and Editor Help
Im so sorry, but I am totally lost
I tried
function addWater()
mine_alcove_3.surface:addItem "water_flask"()
end
and
function addWater()
mine_alcove_3.surface:addItem "water_flask"
end
and
function addWater()
mine_alcove_3.surface:addItem"water_flask.item"()
end
and
function addWater()
mine_alcove_3.surface:addItem"water_flask".item()
end
and
function addWater()
mine_alcove_3.surface:addItem"water_flask.item"
end
and
function addWater()
mine_alcove_3.surface:addItem(water_flask.item)
end
and
function addWater()
mine_alcove_3.surface:addItem("water_flask.item")
end
and
function addWater()
mine_alcove_3.surface:addItem("water_flask".item)
end
And all are wrong. Can anyone write the working code for this? It looks like it should be simple but I can't get the game to understand what a water flask is...
Or am I working the wrong angle here?
I'm trying to learn basic scripts by copying and testing. But this one just refuse to work... and it seems so simple. It must be a mechanic I am unaware of. Like defining objects or where to put " " when objects are undefined.
Also Komag, might it be that Grimrock 2 added .item after all items, so now you need to write water_flask.item et cetera that is screwing up the script when it tried to understand what "water_flask" is ?
I tried
function addWater()
mine_alcove_3.surface:addItem "water_flask"()
end
and
function addWater()
mine_alcove_3.surface:addItem "water_flask"
end
and
function addWater()
mine_alcove_3.surface:addItem"water_flask.item"()
end
and
function addWater()
mine_alcove_3.surface:addItem"water_flask".item()
end
and
function addWater()
mine_alcove_3.surface:addItem"water_flask.item"
end
and
function addWater()
mine_alcove_3.surface:addItem(water_flask.item)
end
and
function addWater()
mine_alcove_3.surface:addItem("water_flask.item")
end
and
function addWater()
mine_alcove_3.surface:addItem("water_flask".item)
end
And all are wrong. Can anyone write the working code for this? It looks like it should be simple but I can't get the game to understand what a water flask is...
Or am I working the wrong angle here?
I'm trying to learn basic scripts by copying and testing. But this one just refuse to work... and it seems so simple. It must be a mechanic I am unaware of. Like defining objects or where to put " " when objects are undefined.
Also Komag, might it be that Grimrock 2 added .item after all items, so now you need to write water_flask.item et cetera that is screwing up the script when it tried to understand what "water_flask" is ?
Re: ~Advanced Scripting and Editor Help
mine_alcove_3.surface:addItem(water_flask_1.item)
you're not referencing the globally defined object. you reference your object. so most likely "_1" if you only spawned one, thus far.
you're not referencing the globally defined object. you reference your object. so most likely "_1" if you only spawned one, thus far.
Last edited by NutJob on Fri Oct 24, 2014 7:58 pm, edited 1 time in total.
- SnowyOwl47
- Posts: 148
- Joined: Fri Sep 12, 2014 10:41 pm
Re: ~Advanced Scripting and Editor Help
@dancodan WOAH ok I see a ton of responses to this and your getting confused hmmmm well I see your problem.
With alcoves you have to say
Thats what you do I'm pretty sure.
And you never do anything like Whatever your setting adding or whatever should be inside the () always. Sometimes you would say And nothing gets put in the ()
With alcoves you have to say
Code: Select all
alcove_name.surface:addItem("water_flask")
And you never do anything like
Code: Select all
monster_name.monster:setMaxHealth"100"()
Code: Select all
monster_name:destroy()
- JohnWordsworth
- Posts: 1397
- Joined: Fri Sep 14, 2012 4:19 pm
- Location: Devon, United Kingdom
- Contact:
Re: ~Advanced Scripting and Editor Help
I'm going to add an additional line of code to the pile! (This one has actually been tested in the editor - so I can confirm it definitely works).
So, from my testing, you need to add an "item component" to a surface. The item component has to belong to a game object that actually exists, so you can either link to one that's already in the game (and it will move to the surface) or you can spawn a new item and place it in the alcove (which I assume is what you want to do).
The above script will...
1. Spawn a new water flask with the bit of code: spawn("water_flask").
2. Take the item component of that water flask using .item.
3. Get the surface component of the mine alcove and add the item component of the flask to the surface component of the alcove.
Sounds a bit convoluted, but it just requires understanding that a "component" is like like a "part" of a game object and you need to use the components for a lot of things now instead of just simple game components.
Code: Select all
mine_alcove_3.surface:addItem(spawn("water_flask").item);
The above script will...
1. Spawn a new water flask with the bit of code: spawn("water_flask").
2. Take the item component of that water flask using .item.
3. Get the surface component of the mine alcove and add the item component of the flask to the surface component of the alcove.
Sounds a bit convoluted, but it just requires understanding that a "component" is like like a "part" of a game object and you need to use the components for a lot of things now instead of just simple game components.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.