Calling a Script in a Script

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Calling a Script in a Script

Post by Mysterious »

Sorry about this. In LOG 1 you called a Script function in a Script like this:

function help()

script_entity_1.Helpscript()
end

It would then run a function called Helpscript in script_entity_1 This does not seem to work anymore. Does anyone know how? thxs :)
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Calling a Script in a Script

Post by cromcrom »

maybe :

Code: Select all

function help()

script_entity_1.script.Helpscript()
end
A trip of a thousand leagues starts with a step.
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Calling a Script in a Script

Post by Mysterious »

Thxs Crom Crom :) do I have to do this below to get a dagger to spawn on the Altar.

Code: Select all

function ratscomplete1()

hudPrint("RATIGIN: Ahhh thank you and here is your reward, friends.")
spawn("dagger",5,10,12,0,0,"daggerat") -- Can this be easier, rather than all the coordinates---
altar_4.surface:addItem(daggerat.item)
	end
EDIT: Hows the Merchant thing going :)
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Calling a Script in a Script

Post by Lark »

If the script is invoked from an object at the spawn location, then you can use the fact that the first argument to the script is the calling object and you can reference its coordinates:

Code: Select all

function ratscomplete1(caller)
  hudPrint("RATIGIN: Ahhh thank you and here is your reward, friends.")
  spawn("dagger", caller.go.level, caller.go.x, caller.go.y, caller.go.facing, 
    caller.go.elevation, "daggerat") -- Reference caller's coordinates---
  altar_4.surface:addItem(daggerat.item)
  end
You still use the coordinates, but you don't have to keep modifying them every time you move things around. I also thought saw a shortcut where you can spawn something at the location of another object, but I can't find it in the forum right now. I hope this helps. -Lark
Post Reply